"Delaney, Timothy C (Timothy)" <[EMAIL PROTECTED]> writes:

> 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.

In fact, in my test, the list comprehension won:

$ /usr/lib/python2.4/timeit.py -s "import string; slist=['aB'*100 for i in 
range(100)]" "map(string.upper, slist)"

1000 loops, best of 3: 522 usec per loop

$ /usr/lib/python2.4/timeit.py -s "slist=['aB'*100 for i in range(100)]" 
"[s.upper() for s in slist]"

1000 loops, best of 3: 461 usec per loop

Dan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to