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


Groups > comp.lang.python > #44133

Re: optomizations

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: optomizations
Date 2013-04-22 21:53 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-A32AAF.21531122042013@news.panix.com> (permalink)
References <mailman.944.1366680414.3114.python-list@python.org>

Show all headers | View raw


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.  But I'm also going to 
quote something I wrote here a couple of months back:

> I've been doing some log analysis.  It's been taking a grovelingly long 
> time, so I decided to fire up the profiler and see what's taking so 
> long.  I had a pretty good idea of where the ONLY TWO POSSIBLE hotspots 
> might be (looking up IP addresses in the geolocation database, or 
> producing some pretty pictures using matplotlib).  It was just a matter 
> of figuring out which it was. 
> 
> As with most attempts to out-guess the profiler, I was totally, 
> absolutely, and embarrassingly wrong. 

So, my real advice to you is to fire up the profiler and see what it 
says.

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