.readline() -SOLVED: PYTHON FASTER THAN PERL !
h_schneider at marketmix.com
Tue Nov 21 11:45:00 CET 2000
1.52 sec. with your code (PERL was: 3.705)
You gave me the reason to dig more into Python :) Thanks a lot!
All the best,
"Alex Martelli" <aleaxit at yahoo.com> schrieb im Newsbeitrag
news:8vdc7301ts8 at news2.newsguy.com...
> "Harald Schneider" <h_schneider at marketmix.com> wrote in message
> news:8vd94d$mjo$06$1 at news.t-online.com...
> > #!/usr/bin/perl
> > Result of upper Script: 3.705 sec
> > while 1:
> > lines = db.readlines(250000)
> > if not lines:
> > break
> > for dbline in lines:
> > rs = string.split(dbline, ';')
> > if rs == 'TEST':
> > print dbline + "\n"
> > break
> > Result of upper Script: 5.629 sec.
> I wonder if a tad extra performance might not be obtained
> in the Python version by a slightly more Pythonic idiom in
> the inner loop, e.g. (in Python 2.0):
> proceed = 1
> while proceed:
> lines = db.readlines(250000)
> if not lines: break
> for dbline in lines:
> if dbline.startswith('TEST'):
> print dbline,'\n'
> proceed = 0
> (this also has the same semantics as the Perl script,
> which, it seems to me, your original Python version does
> not, since the 'break' only breaks from one level of
> loop; I inserted the 'proceed' switch as one way to
> ensure termination of the outer-loop as well).
More information about the Python-list