Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-06 Thread Mark P. Miller
Charles R Harris wrote: > I won't comment on the code itself. Tell us what you want to do and I > bet we can speed it up. > Here's a bit of sample code. It's actually very useful for my purposes. Are there good ways to express these ideas in numpy as opposed to using all of the nested loop

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-02 Thread Mark P. Miller
> > I won't comment on the code itself. Appreciate it :). Again, I'm just pointing out an example! I would guess that I'm not the only person using numpy in this sort of unsophisticated manner! Tell us what you want to do and I > bet we can speed it up. > > Chuck I'll probably do that in

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Charles R Harris
On 3/1/07, Robert Kern <[EMAIL PROTECTED]> wrote: Charles R Harris wrote: > Looks like function call overhead has gone way up or the cost of > returning a float vs an array has gone way up. The loop overhead is > about .01 and not significant. So something is definitely wrong here. > Time to go

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Robert Kern
Charles R Harris wrote: > Looks like function call overhead has gone way up or the cost of > returning a float vs an array has gone way up. The loop overhead is > about .01 and not significant. So something is definitely wrong here. > Time to go look in trac ;) It might have been when Travis put

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Charles R Harris
On 3/1/07, Mark P. Miller <[EMAIL PROTECTED]> wrote: OK...here goes. This code is going to look goofy, so please bear in mind that it is only an abstraction of what my real code does (which happens to provide interesting and meaning insights!). I've attached saved versions of my interactive py

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
OK...here goes. This code is going to look goofy, so please bear in mind that it is only an abstraction of what my real code does (which happens to provide interesting and meaning insights!). I've attached saved versions of my interactive python sessions that document the phenomenon. Again,

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Charles R Harris
On 3/1/07, Mark P. Miller <[EMAIL PROTECTED]> wrote: One more note (this perhaps may need a separate topic): I've been using the Enthought python edition that contains python 2.4.3 and numpy 0.9.9.2706. After Robert Kern pointed out that I should try numpy 1.0.1, I went ahead and installed it

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Robert Kern
Mark P. Miller wrote: > Now however, I'm seeing perhaps a more serious problem: The test > program that I'm working with went from taking ~80 seconds to run to > taking over 10 minutes to run. I've rolled back to my old numpy version > and confirmed that the old version was much faster. I a

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
One more note (this perhaps may need a separate topic): I've been using the Enthought python edition that contains python 2.4.3 and numpy 0.9.9.2706. After Robert Kern pointed out that I should try numpy 1.0.1, I went ahead and installed it (downloaded a few hours ago: "numpy-1.0.1.win32-py2.4

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Travis Oliphant
Mark P. Miller wrote: >>Ops, this seems a bug with your numpy version: >> >>In [46]:array1 = numpy.zeros((10,10),int) >>In [47]:array1.itemset((5,5),9) >>In [48]:array1 >>Out[48]: >>array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >> [0, 0, 0, 0, 0, 0, 0, 0, 0,

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Christopher Barker
Francesc Altet wrote: > Ops, this seems a bug with your numpy version: yup, it's a bug here too: >>> numpy.__version__ '1.0.1' this is the dmg for python2.5 on pythonmac.org/packages -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
>> > > Ops, this seems a bug with your numpy version: > > In [46]:array1 = numpy.zeros((10,10),int) > In [47]:array1.itemset((5,5),9) > In [48]:array1 > Out[48]: > array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >[0,

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Francesc Altet
El dj 01 de 03 del 2007 a les 12:47 -0700, en/na Mark P. Miller va escriure: > > try with > > > array1.itemset((5,5),9) > > > Yep...tried that. But I don't get it! > > >>> import numpy > >>> array1 = numpy.zeros((10,10),int) > >>> array1 > array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], >

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
> try with > array1.itemset((5,5),9) Yep...tried that. But I don't get it! >>> import numpy >>> array1 = numpy.zeros((10,10),int) >>> array1 array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Francesc Altet
El dj 01 de 03 del 2007 a les 12:03 -0700, en/na Mark P. Miller va escriure: > Sorry to pester, but is this the intended behavior of itemset? > > >>> array1=numpy.zeros((10,10),int) > >>> array1 > array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], > [0, 0, 0

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
Sorry to pester, but is this the intended behavior of itemset? >>> array1=numpy.zeros((10,10),int) >>> array1 array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0,

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Robert Kern
Mark P. Miller wrote: > Travis: Can you clarify this for me. The book doesn't have much detail > here and seems to differ from your notation (which gives me errors). > numpy 0.9.9.2706 This is the problem. You will need to upgrade to 1.0.1. -- Robert Kern "I have come to believe that the wh

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
Travis: Can you clarify this for me. The book doesn't have much detail here and seems to differ from your notation (which gives me errors). >> Getting single indices like this is a bit slower for NumPy then for >> lists because of all the possibilities that must be distinguished for >> array

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
>> ##imports >> import numpy as NP >>from numpy.random import randint >> #numpy array code >> array1 = NP.zeros((50,50), int) >> >> def random1(): >> c = array1(randint(10), randint(10)) >> >> > Is this a bug? You can't "call" an array. Did you mean, > array1[randint(10), randint(10)]?

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Charles R Harris
On 3/1/07, Mark P. Miller <[EMAIL PROTECTED]> wrote: I've been using Numpy arrays for some work recently. Just for fun, I compared some "representative" code using Numpy arrays and an object comprised of nested lists to represent my arrays. To my surprise, the array of nested lists outperforme

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Travis Oliphant
Mark P. Miller wrote: >I've been using Numpy arrays for some work recently. Just for fun, I >compared some "representative" code using Numpy arrays and an object >comprised of nested lists to represent my arrays. To my surprise, the >array of nested lists outperformed Numpy in this particular

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Travis Oliphant
Mark P. Miller wrote: >I've been using Numpy arrays for some work recently. Just for fun, I >compared some "representative" code using Numpy arrays and an object >comprised of nested lists to represent my arrays. To my surprise, the >array of nested lists outperformed Numpy in this particular

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
Interesting... I also tried the following and got similar results (using a 1,000 x 1,000 arrays). The time required to initialize the nested list array was much higher (but nonetheless small in the context of the overall time that my programs will run). But array element access is always fas

Re: [Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Perry Greenfield
On Mar 1, 2007, at 11:03 AM, Mark P. Miller wrote: > I've been using Numpy arrays for some work recently. Just for fun, I > compared some "representative" code using Numpy arrays and an object > comprised of nested lists to represent my arrays. To my surprise, the > array of nested lists outper

[Numpy-discussion] when and where to use numpy arrays vs nested lists

2007-03-01 Thread Mark P. Miller
I've been using Numpy arrays for some work recently. Just for fun, I compared some "representative" code using Numpy arrays and an object comprised of nested lists to represent my arrays. To my surprise, the array of nested lists outperformed Numpy in this particular application (in my actual