An efficient split function
William S. Lear
rael at see.sig
Mon May 10 13:06:36 EDT 1999
"Andrew M. Kuchling" <akuchlin at cnri.reston.va.us> writes:
> 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.
Thanks for the suggestion, which I had tried originally, but got
marginally worse performance than with the regexp. For some reason, I
did have to do split('\|') instead of split('|'), which I found curious.
As long as I'm not doing something entirely ridiculous...
Thanks again.
Bill
--
William S. Lear | Who is there that sees not that this inextricable labyrinth
r a e l @ | of reasons of state was artfully invented, lest the people
d e j a . | should understand their own affairs, and, understanding,
c o m | become inclined to conduct them? ---William Godwin, 1793
More information about the Python-list
mailing list