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

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 hyunchul.mail...@gmail.com 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])

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

Re: faster than list.extend()

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim hyunchul.mail...@gmail.com 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 **

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:

Re: faster than list.extend()

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

Re: faster than list.extend()

2009-11-16 Thread Gabriel Genellina
En Mon, 16 Nov 2009 19:30:27 -0300, Hyunchul Kim hyunchul.mail...@gmail.com 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

Re: faster than list.extend()

2009-11-16 Thread Jason Sewall
On Mon, Nov 16, 2009 at 6:28 PM, Raymond Hettinger pyt...@rcn.com wrote: On Nov 16, 2:41 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim hyunchul.mail...@gmail.com wrote: Hi, all. I want to improve speed of following simple function. Any