Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105191

Re: sobering observation, python vs. perl

From "Anders J. Munch" <2016@jmunch.dk>
Newsgroups comp.lang.python
Subject Re: sobering observation, python vs. perl
Date 2016-03-17 22:27 +0100
Organization .
Message-ID <mailman.308.1458296614.12893.python-list@python.org> (permalink)

Show all headers | View raw


Charles T. Smith:
> I've really learned to love working with python, but it's too soon
> to pack perl away.  I was amazed at how long a simple file search took
> so I ran some statistics:

Write Python in pythonic style instead of translated-from-Perl style, and the 
tables are turned:

$ cat find-rel.py
| import sys
| def main():
|     for fn in sys.argv[1:]:
|         tn = None
|         with open(fn, 'rt') as fd:
|             for line in fd:
|                 if ' is ready' in line:
|                     tn = line.split(' is ready', 1)[0]
|                 elif 'release_req' in line:
|                     print tn
| main()


$ time python find-rel.py *.out
real    0m0.647s
user    0m0.616s
sys    0m0.029s

$ time perl find-rel.pl *.out
real    0m0.935s
user    0m0.910s
sys    0m0.023s

I don't have your log files and my quickly assembled test file doesn't actually 
contain the phrase 'release_req', so my results may be misleading. Perhaps 
you'll try it and post your results?

regards, Anders

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: sobering observation, python vs. perl "Anders J. Munch" <2016@jmunch.dk> - 2016-03-17 22:27 +0100

csiph-web