News for hackers. Stuff that matters.
Re:Python Patterns - An Optimization Anecdote by Goladus on Tuesday November 02, 2010 @08:06AM (#1860066)
This would be my default approach as well. I'd be interested to see how it compares-- my guess is that it would be equivalent to or slightly faster than f6(), and slower than the version that uses the array library.
Re:Python Patterns - An Optimization Anecdote by RyanMcGreal on Tuesday November 02, 2010 @08:46AM (#1860186)
From the article, I'm guessing the author was using a version <2.x.

Incidentally, I ran my function and f6 from the article on a list of 9600 integers using Python 2.6.3. f6 ran in 0.00303250832159 seconds and my function ran in 0.00421450212248 seconds.

Re:Python Patterns - An Optimization Anecdote by petdog on Tuesday November 02, 2010 @09:18AM (#1860275)
Actually, map is still faster:

    In [24]: timeit ''.join(map(chr, ll))
    100000 loops, best of 3: 3.91 us per loop

    In [25]: timeit ''.join([chr(i) for i in ll])
    100000 loops, best of 3: 5.85 us per loop

    In [26]: timeit ''.join(chr(i) for i in ll)
    100000 loops, best of 3: 7.79 us per loop