Print

Print


Is it just me, or is Python  s l o o o w  when compared to Perl?

I have two scripts, attached. They do EXACTLY the same thing in almost EXACTLY the same manner, but the Python script is almost 25 times slower than the Perl script:

  $ time bin/json2catalog.py sample/ > sample.db 2>/dev/null
  real 0m10.344s
  user 0m10.281s
  sys 0m0.059s

  $ time bin/json2catalog.pl sample/ > sample.db 2>/dev/null
  real 0m0.364s
  user 0m0.314s
  sys 0m0.048s

When I started learning Python, and specifically learning Python’s Natural Language Toolkit (NLTK), I thought this slowness was do to the large NLTK library, but now I’m not so sure. It is just me, or is Python really  s l o o o w ? Is there anything I can do to improve/optimize my Python code?

—
Eric Lease Morgan