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


Groups > comp.lang.python > #44169

Re: optomizations

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.259
X-Spam-Level **
X-Spam-Evidence '*H*': 0.59; '*S*': 0.10; 'slow.': 0.09; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'skip:l 30': 0.24; 'script': 0.25; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '"",': 0.31; 'regular': 0.32; 'run': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'feedback': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'line,': 0.68; 'smith': 0.68; 'article': 0.77; 'faster.': 0.84; 'stuff:': 0.84; 'subject:skip:o 10': 0.84; 'profile.': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=p/2TofTLPkVhGW2bVg8lRrJVOW9rbeeS7+4lc4SeKuw=; b=l5O3fEgU/m55/Hh24l1vSblG4gSJoQcWocTZCq6Blkbp12h2a9d1pBMsPRapUk2U/T GkVdwRcDHY9PWKMsqshqsNfNCqSOUn28dTrvMP1Kynsc9bTuretFss4lJpMf3XtfpsLA p3RVqgH97yCtYH+kkk2jbOS+3jtJLYoo4ADIfdOdFGuk+Tv1GV5Cq1x8XtMe70R8pK0E Sxz0mlWcWk3Fena9KKmruCbmrMGH21fw8CQTv1PQpQSLYXuqMy4nGuusShUbH7QUksOo LqmdYHI8rKakTVSLavhMS+FKyOnpqBpO6qt2WHX21+xXr3OA0cJow0rAoJqezL4B4tN2 31KQ==
MIME-Version 1.0
X-Received by 10.220.169.132 with SMTP id z4mr6002797vcy.28.1366682615151; Mon, 22 Apr 2013 19:03:35 -0700 (PDT)
In-Reply-To <roy-A32AAF.21531122042013@news.panix.com>
References <mailman.944.1366680414.3114.python-list@python.org> <roy-A32AAF.21531122042013@news.panix.com>
Date Tue, 23 Apr 2013 12:03:35 +1000
Subject Re: optomizations
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-Mailman-Approved-At Tue, 23 Apr 2013 11:03:18 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.966.1366707799.3114.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366707799 news.xs4all.nl 2218 [2001:888:2000:d::a6]:53101
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44169

Show key headers only | View raw


On Tue, Apr 23, 2013 at 11:53 AM, Roy Smith <roy@panix.com> wrote:
> In article <mailman.944.1366680414.3114.python-list@python.org>,
>  Rodrick Brown <rodrick.brown@gmail.com> wrote:
>
>> I would like some feedback on possible solutions to make this script run
>> faster.
>
> If I had to guess, I would think this stuff:
>
>>                     line = line.replace('mediacdn.xxx.com', 'media.xxx.com')
>>                     line = line.replace('staticcdn.xxx.co.uk', '
>> static.xxx.co.uk')
>>                     line = line.replace('cdn.xxx', 'www.xxx')
>>                     line = line.replace('cdn.xxx', 'www.xxx')
>>                     line = line.replace('cdn.xx', 'www.xx')
>>                     siteurl = line.split()[6].split('/')[2]
>>                     line = re.sub(r'\bhttps?://%s\b' % siteurl, "", line, 1)
>
> You make 6 copies of every line.  That's slow.

One of those is a regular expression substitution, which is also
likely to be a hot-spot. But definitely profile.

ChrisA

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


Thread

optomizations Rodrick Brown <rodrick.brown@gmail.com> - 2013-04-22 21:19 -0400
  Re: optomizations Roy Smith <roy@panix.com> - 2013-04-22 21:53 -0400
    Re: optomizations Dan Stromberg <drsalists@gmail.com> - 2013-04-22 20:15 -0700
    Re: optomizations Rodrick Brown <rodrick.brown@gmail.com> - 2013-04-23 00:20 -0400
      Re: optomizations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 04:38 +0000
    Re: optomizations Chris Angelico <rosuav@gmail.com> - 2013-04-23 12:03 +1000
  Re: optomizations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 04:00 +0000
    Re: optomizations Chris Angelico <rosuav@gmail.com> - 2013-04-23 14:08 +1000
    percent faster than format()? (was: Re: optomizations) Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-04-23 09:46 +0200
      Re: percent faster than format()? (was: Re: optomizations) Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-23 10:26 +0200
        Re: percent faster than format()? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-04-23 16:57 +0200
          Re: percent faster than format()? Lele Gaifax <lele@metapensiero.it> - 2013-04-23 17:44 +0200
      Re: percent faster than format()? (was: Re: optomizations) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-23 14:36 +0000
        Re: percent faster than format()? (was: Re: optomizations) Chris Angelico <rosuav@gmail.com> - 2013-04-24 00:52 +1000

csiph-web