
The actual work done in Python is swamped by start up time, so your benchmark is as much about comparing startup time as comparing time required to do the work. Interpreter startup time on my machine is about half the total wall clock time, 30% of the user time, and most of the system time. Interpreter startup time on the vast majority of systems, Python takes substantially longer to begin running (I believe because more files are loaded at startup).
#Python vs perl serial#

Now, I know that Perl and Python have some expected differences. The Python script spends most of its time on for line in fh the Perl script spends most of its time in if($_ eq "1000000").
#Python vs perl code#
I tried profiling both scripts, but there really isn't much code to profile.

Print "This is the millionth line: Python"įor whatever reason, the Python script takes almost ~8x longer: $ time perl read_ time python read_million.py Print "This is the millionth line: Perl\n"

My Perl script which processes this file is as follows: # read_ I have a gzipped data file containing a million lines: $ zcat million_ | head
