wasm-demo/demo/ermis-f/python_m/cur/1992

40 lines
1.5 KiB
Plaintext

From: rael at see.sig (William S. Lear)
Date: 10 May 1999 12:06:36 -0500
Subject: An efficient split function
References: <wy3e15x8sa.fsf@wiggum.dejanews.com> <14134.64897.771093.125780@amarok.cnri.reston.va.us>
Message-ID: <wyaevcq2g3.fsf@wiggum.dejanews.com>
Content-Length: 1218
X-UID: 1992
"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