3 ms·
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(),
by Goladus 16y ago
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.
- RyanMcGreal 16y agoFrom 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.
- petdog 16y agoActually, 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