string goes away
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Thu Mar 31 22:14:20 EST 2005
Andreas Beyer wrote:
> Yeeh, I was expecting something like that. The only reason to use
> map() at all is for improving the performance.
> That is lost when using list comprehensions (as far as I know). So,
> this is *no* option for larger jobs.
Try it and see. You'll probably be pleasantly surprised.
Note that you can use `str.upper` in map ...
/usr/bin> C:/Python24/python.exe -m timeit -s "strings = ['a']*1000"
"map(str.upper, strings)"
1000 loops, best of 3: 304 usec per loop
/usr/bin> C:/Python24/python.exe -m timeit -s "strings = ['a']*1000"
"[s.upper() for s in strings]"
1000 loops, best of 3: 331 usec per loop
Pretty damn close.
Tim Delaney
More information about the Python-list
mailing list