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


Groups > comp.lang.python > #105102

Re: sobering observation, python vs. perl

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From srinivas devaki <mr.eightnoteight@gmail.com>
Newsgroups comp.lang.python
Subject Re: sobering observation, python vs. perl
Date Thu, 17 Mar 2016 21:18:43 +0530
Lines 98
Message-ID <mailman.273.1458229771.12893.python-list@python.org> (permalink)
References <nceihb$vpg$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de grLfFcUb3e+Ammen6gxZrA33mtGGH10ymM7aa0AAjhVg==
Return-Path <mr.eightnoteight@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'modified': 0.05; 'sys': 0.05; 'cc:addr:python-list': 0.09; '#print': 0.09; 'res': 0.09; 'python': 0.10; 'subject:python': 0.14; '+91': 0.15; 'file,': 0.15; 'thu,': 0.15; 'variables': 0.15; '2016': 0.16; 'doin': 0.16; 'line)': 0.16; 'line),': 0.16; 'match:': 0.16; 'perl.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'res:': 0.16; 'slow,': 0.16; 'wrote:': 0.16; 'student': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '%s"': 0.22; 'junior': 0.22; 'import': 0.24; 'header:In- Reply-To:1': 0.24; 'sort': 0.25; "i've": 0.25; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'away.': 0.29; 'perl': 0.29; 'print': 0.30; 'that.': 0.30; 'url:mailman': 0.30; 'seconds': 0.31; 'generally': 0.32; 'skip:. 10': 0.32; 'url:python': 0.33; 'open': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'too': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'indian': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'log': 0.38; 'url:mail': 0.40; 'some': 0.40; 'school': 0.62; 'real': 0.62; 'mar': 0.65; 'soon': 0.65; 'subject:. ': 0.67; 'smith': 0.76; '(3rd': 0.84; 'amazed': 0.84; 'ph:': 0.84; 'precompiled': 0.84; 'programs:': 0.84; 'numbers:': 0.91; 'improvement': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KvtUWgloKjTewfdRFX3p6yJQgYoOC6/CGhK0PG9BLC8=; b=xOVyHIhTIvDn3AXMTtgAeZ1n89kWQbiMufp5KleBooCnmRUeGjpB1vZoUVl69rHcs0 wkS9BQ5V57K67kX/8e6Vgxl2CzpRvjyrFpheWpNTOxuNbvmUFoR4kV7/R8IaXVjkImlX L6szCTnfUgmtARpORGR4WhuJX8RGEkdfr17u9mOEwo/C5YfhwRaJBNkp2S49umS6tbuA C2zH8LXa0e/96HTtAM4ccKBNlH+kNjtqJJJOCoBhcC87awnwsxJ7Eu+d14h1gzLEusfc bqB61C2TKUPA2qBJ9XFRzm37RkNQVfbYpZo5I0P30QecesOq9vEqK74fMTdsdlATSov4 mSmQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KvtUWgloKjTewfdRFX3p6yJQgYoOC6/CGhK0PG9BLC8=; b=L8pkN6PEVK5Z1PdaWzPRLf+52js2Vf6i7GWnXeMVXU0QslzmLOT0rI8r9l36pmPLY1 en/pLSusPPgGnq9E/8732VIz0t81e0g+Bo2vy+6dqJZ8O6WKmmpW/fNiUJaS2lmK0USd PZVdTF52zlGnlx0pFG3fHsKabGDJza/nqgoroBgvPmAeDVwH7+GBvdm+Ly70y0yx8NlH SUuL9x/XYPU6XWkRouLtVCfy8WLzMbrNOSuElji6QqP5vNGVQ74sVvVz8WpQ4dhKX9fY Z11tPBZkXeeMDBnCUW6tzYgUUaAxJ3BETjDyVwBW+aoKaQHP6muUxgK2PmBGEjRSia4P mqwA==
X-Gm-Message-State AD7BkJIFx4JWAoVM/S2nKJ//vzednBHsrfIu2EJfY5unFiCitn4GHG6P6iKGs5R5fDs8OjwxO025XUE4qYzZNA==
X-Received by 10.50.160.9 with SMTP id xg9mr34921392igb.41.1458229762459; Thu, 17 Mar 2016 08:49:22 -0700 (PDT)
In-Reply-To <nceihb$vpg$1@dont-email.me>
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:105102

Show key headers only | View raw


please upload the log file,

and global variables in python are slow, so just keep all that in a
function and try again. generally i get 20-30% time improvement by
doin that.


On Thu, Mar 17, 2016 at 8:59 PM, Charles T. Smith
<cts.private.yahoo@gmail.com> wrote:
> 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:
>
>     $ time python find-rel.py
>     ./find-relreq *.out | sort -u
>     TestCase_F_00_P
>     TestCase_F_00_S
>     TestCase_F_01_S
>     TestCase_F_02_M
>
>     real    1m4.581s
>     user    1m4.412s
>     sys     0m0.140s
>
>
>     $ time python find-rel.py
>     # modified to use precompiled REs:
>     TestCase_F_00_P
>     TestCase_F_00_S
>     TestCase_F_01_S
>     TestCase_F_02_M
>
>     real    0m29.337s
>     user    0m29.174s
>     sys     0m0.100s
>
>
>     $ time perl find-rel.pl
>     find-relreq.pl *.out | sort -u
>     TestCase_F_00_P
>     TestCase_F_00_S
>     TestCase_F_01_S
>     TestCase_F_02_M
>
>     real    0m5.009s
>     user    0m4.932s
>     sys     0m0.072s
>
> Here's the programs:
>
> #!/usr/bin/env python
> # vim: tw=0
> import sys
> import re
>
> isready = re.compile ("(.*) is ready")
> relreq = re.compile (".*release_req")
> for fn in sys.argv[1:]:                                 # logfile name
>     tn = None
>     with open (fn) as fd:
>         for line in fd:
>             #match = re.match ("(.*) is ready", line)
>             match = isready.match (line)
>             if match:
>                 tn = match.group(1)
>             #match = re.match (".*release_req", line)
>             match = relreq.match (line)
>             if match:
>                 #print "%s: %s" % (tn, line),
>                 print tn
>
> vs.
>
> while (<>) {
>     if (/(.*) is ready/) {
>         $tn = $1;
>     }
>     elsif (/release_req/) {
>         print "$tn\n";
>     }
> }
>
> Look at those numbers:
> 1 minute for python without precompiled REs
> 1/2 minute with precompiled REs
> 5 seconds with perl.
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight

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


Thread

sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 15:29 +0000
  Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 15:40 +0000
    Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 17:48 +0200
      Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 15:59 +0000
        Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 18:07 +0200
          Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:15 +0000
  Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 17:47 +0200
    Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:06 +0000
      Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 18:30 +0200
        Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:32 +0000
  Re: sobering observation, python vs. perl srinivas devaki <mr.eightnoteight@gmail.com> - 2016-03-17 21:18 +0530
    Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:15 +0000
  Re: sobering observation, python vs. perl Tim Chase <python.list@tim.thechases.com> - 2016-03-17 10:52 -0500
    Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:08 +0000
      Re: sobering observation, python vs. perl Ethan Furman <ethan@stoneleaf.us> - 2016-03-17 09:21 -0700
        Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:36 +0000
          Re: sobering observation, python vs. perl Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-17 17:09 +0000
          Re: sobering observation, python vs. perl Ethan Furman <ethan@stoneleaf.us> - 2016-03-17 10:26 -0700
            Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 17:35 +0000
              Re: sobering observation, python vs. perl Ethan Furman <ethan@stoneleaf.us> - 2016-03-17 11:21 -0700
          DSLs in perl and python (Was sobering observation) Rustom Mody <rustompmody@gmail.com> - 2016-03-17 10:47 -0700
            Re: DSLs in perl and python (Was sobering observation) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-17 22:22 +0000
            Re: DSLs in perl and python (Was sobering observation) MRAB <python@mrabarnett.plus.com> - 2016-03-17 22:43 +0000
              Re: DSLs in perl and python (Was sobering observation) Rustom Mody <rustompmody@gmail.com> - 2016-03-18 05:57 -0700
                Re: DSLs in perl and python (Was sobering observation) Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-18 15:18 +0200
                Re: DSLs in perl and python (Was sobering observation) Peter Otten <__peter__@web.de> - 2016-03-18 14:22 +0100
                Re: DSLs in perl and python (Was sobering observation) Rustom Mody <rustompmody@gmail.com> - 2016-03-18 19:07 -0700
                DSL design (was DSLs in perl and python) Rustom Mody <rustompmody@gmail.com> - 2016-03-29 06:28 -0700
                Re: DSL design (was DSLs in perl and python) Chris Angelico <rosuav@gmail.com> - 2016-03-30 00:41 +1100
                Re: DSL design (was DSLs in perl and python) Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-29 16:45 +0300
                Finding methods, was Re: DSL design (was DSLs in perl and python) Peter Otten <__peter__@web.de> - 2016-03-29 15:51 +0200
      Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 18:34 +0200
        Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 16:42 +0000
          Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 19:08 +0200
            Re: sobering observation, python vs. perl "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-03-17 17:25 +0000
              Re: sobering observation, python vs. perl BartC <bc@freeuk.com> - 2016-03-17 17:53 +0000
                Re: sobering observation, python vs. perl Rustom Mody <rustompmody@gmail.com> - 2016-03-17 10:59 -0700
                Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 20:53 +0200
                Re: sobering observation, python vs. perl BartC <bc@freeuk.com> - 2016-03-17 19:06 +0000
                Re: sobering observation, python vs. perl Marko Rauhamaa <marko@pacujo.net> - 2016-03-17 21:11 +0200
            Re: sobering observation, python vs. perl Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-17 20:47 +0000
      Re: sobering observation, python vs. perl Peter Otten <__peter__@web.de> - 2016-03-18 10:26 +0100
      Re: sobering observation, python vs. perl Steven D'Aprano <steve@pearwood.info> - 2016-03-18 22:47 +1100

csiph-web