Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Christopher Barker
On 1/27/11 3:54 PM, Sturla Molden wrote: > Lists allocate empty slots at their back, proportional to their size. So > as lists grows, re-allocations become rarer and rarer. Then on average > the complexity per append becomes O(1), which is the "amortised" > complexity. Appending N items to a list t

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Sturla Molden
Den 28.01.2011 00:33, skrev Christopher Barker: > > hmmm - that doesn't seem quite right -- lists still have to > re-allocate and copy, they just do it every n times (where n grows > with the list), so I wouldn't expect exactly O(N). Lists allocate empty slots at their back, proportional to thei

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Christopher Barker
On 1/27/11 1:53 PM, Sturla Molden wrote: But N appends are O(N) for lists and O(N*N) for arrays. hmmm - that doesn't seem quite right -- lists still have to re-allocate and copy, they just do it every n times (where n grows with the list), so I wouldn't expect exactly O(N). But you never kn

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Sturla Molden
Den 27.01.2011 22:47, skrev Sturla Molden: > > Please observe that appending to a Python list is amortized O(1), > whereas appending to a numpy array is O(N**2). > Sorry, one append to a numpy array is O(N). But N appends are O(N) for lists and O(N*N) for arrays. S.M. ___

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Sturla Molden
Den 27.01.2011 22:03, skrev Dewald Pieterse: > Is numpy.append so slow? or is the culprit numpy.where? Please observe that appending to a Python list is amortized O(1), whereas appending to a numpy array is O(N**2). Sturla ___ NumPy-Discussion mailing

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Dewald Pieterse
On Thu, Jan 27, 2011 at 4:33 PM, Dewald Pieterse wrote: > > > On Thu, Jan 27, 2011 at 4:19 PM, Christopher Barker > wrote: > >> On 1/27/11 1:03 PM, Dewald Pieterse wrote: >> >>> I am processing two csv files against another, my first implementation >>> used python list of lists and list.append to

Re: [Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Dewald Pieterse
On Thu, Jan 27, 2011 at 4:19 PM, Christopher Barker wrote: > On 1/27/11 1:03 PM, Dewald Pieterse wrote: > >> I am processing two csv files against another, my first implementation >> used python list of lists and list.append to generate a new list while >> looping all the data including the non-re

[Numpy-discussion] numpy.append & numpy.where vs list.append and brute iterative for loop

2011-01-27 Thread Dewald Pieterse
I am processing two csv files against another, my first implementation used python list of lists and list.append to generate a new list while looping all the data including the non-relevant data (can't determine location of specific data element in a list of list). So I re-implented the exact same