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


Groups > comp.lang.python > #105191

Re: sobering observation, python vs. perl

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From "Anders J. Munch" <2016@jmunch.dk>
Newsgroups comp.lang.python
Subject Re: sobering observation, python vs. perl
Date Thu, 17 Mar 2016 22:27:19 +0100
Organization .
Lines 38
Message-ID <mailman.308.1458296614.12893.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de QoLyGDmQ3dw6y0PDXYx4lgAmVr6ehPaPOndr0HeXl/xA==
Return-Path <2016@jmunch.dk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'elif': 0.04; 'sys': 0.05; 'line:': 0.07; 'main()': 0.07; 'anders': 0.09; 'python': 0.10; 'def': 0.13; 'subject:python': 0.14; 'assembled': 0.16; 'main():': 0.16; 'pythonic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:2**1': 0.21; 'tables': 0.23; 'import': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; "skip:' 10": 0.28; 'away.': 0.29; 'cat': 0.29; 'perl': 0.29; 'received:dk': 0.29; 'print': 0.30; 'post': 0.31; 'quickly': 0.34; 'file': 0.34; 'but': 0.36; 'too': 0.36; 'instead': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'log': 0.38; 'files': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; "you'll": 0.61; 'real': 0.62; 'charset:windows-1252': 0.62; 'soon': 0.65; 'results': 0.66; 'subject:. ': 0.67; 'amazed': 0.84
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.7.0
X-CMAE-Envelope MS4wfIRJVH0DbBMdVFB/9f1o0TcRRNozfrQlCoGcLpCYFWcKyqObnKAVxYALM6YQ+4YgyDkCfvRQMZsiUTJwKgK7zfASDROo5Jlsjz383Sw2DTo6fJg+ligb PipnrjKBH3P9qs5gX8g1MpOWlvX7IjWFea9DtNcywDz8GsLNV2CI7N9ssMDF0V2SWF2wXBVPINc628JVQgg+npBfABBscIGTHwmB9H5WzEMj2Rs0ZFgfPSnn
X-Mailman-Approved-At Fri, 18 Mar 2016 06:23:32 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105191

Show key headers only | 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