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 > **********
You'd probably be better off calling .append() 3 times instead of .extend() as it would avoid the creation of all those intermediate 3-element lists. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list