Yet another Python vs. Perl speed issue/question

Paul Prescod paulp at ActiveState.com
Tue Mar 13 17:52:14 EST 2001


nanotech at europa.com wrote:
> 
> All:
> 
> Python 2.0 on an HP (nice and big) takes ~30 seconds to lowercase all
> the lines in a 3meg file. Perl takes less than a second. What am I
> doing wrong?!?
> 
> Python
> ------
> import sys
> import string
> 
> stdin=sys.stdin
> lower=string.lower
> 
> print map(lower,stdin.readlines())

I'd suggest 

sys.stdin.read().lower()

-- 
Python:
    Programming the way
    Guido
    indented it.
       - (originated with Skip Montanaro?)




More information about the Python-list mailing list