Re: faster than list.extend()

2009-11-17 Thread Peter Otten
Gabriel Genellina wrote: > En Mon, 16 Nov 2009 19:30:27 -0300, Hyunchul Kim > escribió: > >> I want to improve speed of following simple function. >> Any suggestion? >> >> ** >> def triple(inputlist): >> results = [] >> for x in inputlist: >> results.extend([x,x,x]) >> return r

Re: faster than list.extend()

2009-11-17 Thread Hyunchul Kim
Thank Tim, Raymond, and all. In my test, Tim's t1 was fastest and Raymond's triple3 is very near to Tim's t1. Anyway both of them took only 6~7% time of my original .extend() version. I think that following n_ple() is a good generalized function that was 1~3% slower than t1() and triple3() for "t

Re: faster than list.extend()

2009-11-16 Thread Jason Sewall
On Mon, Nov 16, 2009 at 6:28 PM, Raymond Hettinger wrote: > On Nov 16, 2:41 pm, Chris Rebert wrote: >> On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim >> >> wrote: >> > Hi, all. >> >> > I want to improve speed of following simple function. >> > Any suggestion? >> >> > ** >> > def triple(in

Re: faster than list.extend()

2009-11-16 Thread Gabriel Genellina
En Mon, 16 Nov 2009 19:30:27 -0300, Hyunchul Kim escribió: I want to improve speed of following simple function. Any suggestion? ** def triple(inputlist): results = [] for x in inputlist: results.extend([x,x,x]) return results ** These are my best attempts: def tri

Re: faster than list.extend()

2009-11-16 Thread Raymond Hettinger
On Nov 16, 2:41 pm, Chris Rebert wrote: > On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim > > wrote: > > Hi, all. > > > I want to improve speed of following simple function. > > Any suggestion? > > > ** > > def triple(inputlist): > >   results = [] > >   for x in inputlist: > >     results.

Re: faster than list.extend()

2009-11-16 Thread Tim Chase
Hyunchul Kim wrote: Hi, all. I want to improve speed of following simple function. Any suggestion? ** def triple(inputlist): results = [] for x in inputlist: results.extend([x,x,x]) return results ** Several ways occur to me: def t1(i): for x in i: yield

Re: faster than list.extend()

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim wrote: > Hi, all. > > I want to improve speed of following simple function. > Any suggestion? > > ** > def triple(inputlist): >   results = [] >   for x in inputlist: >     results.extend([x,x,x]) >   return results > ** You'd probably

faster than list.extend()

2009-11-16 Thread Hyunchul Kim
Hi, all. I want to improve speed of following simple function. Any suggestion? ** def triple(inputlist): results = [] for x in inputlist: results.extend([x,x,x]) return results ** Thank you in advance, Hyunchul -- http://mail.python.org/mailman/listinfo/python-list