Re: [Numpy-discussion] Optimization of loops

2008-10-23 Thread Pierre Yger
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thanks everybody for all your feedback !!! Ok, so first, I just must have to precise what was my problem and why I used Numpy. Because I want to extract only some ids in the lists. In fact, I've a test in my list implementation: for id, time in my_li

Re: [Numpy-discussion] Optimization of loops

2008-10-23 Thread Stéfan van der Walt
2008/10/23 Charles R Harris <[EMAIL PROTECTED]>: > In [4]: ind = [i for i,j in spikes] > In [5]: tim = [j for i,j in spikes] Just for interest's sake, 'zip' is an interesting function in that it works both ways around: In [26]: zip(*zip([1,2,3],[3,4,5])) Out[26]: [(1, 2, 3), (3, 4, 5)] So a pers

Re: [Numpy-discussion] Optimization of loops

2008-10-23 Thread Charles R Harris
On Wed, Oct 22, 2008 at 10:21 AM, Pierre Yger <[EMAIL PROTECTED]> wrote: > Hi all, > > This is my first mail to the mailing list, and I would like to know if > anybody > has a great idea about the use or not of Numpy and loops in Python. > > So here is my problem : I've a large list of tuple (id,

Re: [Numpy-discussion] Optimization of loops

2008-10-23 Thread Bryan Cole
> >> spikes = [(0, 2.3),(1, 5.6),(3, 2.5),(0, 5.2),(3, 10.2),(2, 16.2)] > > mysort(spikes) > > should return: > > [[2.3, 5.2], [5.6], [16.2], [2.5, 10.2]] > > Intuitively, the simplest way to do that is to append elements while going > through all the tuples of the main list (called spikes)

Re: [Numpy-discussion] (Late) summary of PEP-225 discussion at Scipy

2008-10-23 Thread Christopher Barker
Eric Firing wrote: > I think a stronger general numpy case might be made for the logical > operators than for matrix multiplication. An alternative approach, and > I think preferable to introducing new logical operators, is PEP 335: > http://www.python.org/dev/peps/pep-0335/. I like that! How