An efficient split function

Andrew M. Kuchling akuchlin at cnri.reston.va.us
Mon May 10 11:40:36 EDT 1999


William S. Lear writes:
>Surprisingly, to me, the Python version far outperformed the Perl
>version.  Running on 1 million lines of input of 9 fields each, the
>Python version ran in just under 20 seconds, the Perl version in just
>under 40 seconds (this on a 400Mhz Pentium Linux box).

	Note that your use of split(/\|/) in Perl requires using the
regular expression engine, instead of a simple C splitting loop .  Try
using a literal string instead of a regex, as in split('|', ...); that
will probably even out the speeds.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Hey, Michael, you really don't want to go in there. No, really you don't. The
Truth hurts, you know...
    -- Closing lines of ENIGMA #3: "The Good Boy"





More information about the Python-list mailing list