Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.071 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'cache': 0.05; '*is*': 0.09; 'dwarfed': 0.16; 'subject:search': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'feb': 0.19; 'fraction': 0.22; 'header:In-Reply- To:1': 0.25; 'compiled': 0.27; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.27; 'subject:/': 0.28; "we're": 0.30; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'needed': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'execute': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'apply': 0.39; 'think': 0.40; 'times': 0.63; 'here': 0.65; '2013': 0.84; 'subject:via': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=jbh+7gEdrOoEvoqoUAB7x2zD9Juk6TxBwigbus86aVA=; b=SvmqvMBavX4AZ2vGEf8WNi6T2p7JFa0iWKFE8ocx85TK9NvX/6DOQb4KEnmo9Apz50 UEJgiUUDBmniUYwEWoWApgrqdN/HdDDbO+WiAmuZLI4i6hayvl8yklZB9awaU+48Sd1Z mVJszhJYcH4uJiNyGd+0m0jQBSKad71MPzD1cJ6AhRp1+knY7VBv8w/Q0EILhJYRYrzM 3oeV5hEEilWjiISmnns9vhKfHztw6Gr/7wz1ztq5m+06hcRYqlzSvXrduy9rUqLkVLtR Ajyb7OzF1K4AVKwnxH+6tJCqq2HEJgdvMY7kwc/iF3KK+RCZTiT1vAd4irKrtq0mGswD hKMQ== X-Received: by 10.66.74.234 with SMTP id x10mr15052637pav.10.1360311740065; Fri, 08 Feb 2013 00:22:20 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20130207215755.3c4a5c464357313496320cc3@lavabit.com> References: <511319c7$0$21812$c3e8da3$76491128@news.astraweb.com> <51142e96$0$6512$c3e8da3$5496439d@news.astraweb.com> <51143feb$0$29974$c3e8da3$5496439d@news.astraweb.com> <20130207215755.3c4a5c464357313496320cc3@lavabit.com> From: Ian Kelly Date: Fri, 8 Feb 2013 01:21:39 -0700 Subject: Re: Curious to see alternate approach on a search/replace via regex To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360311744 news.xs4all.nl 6850 [2001:888:2000:d::a6]:54867 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38430 On Thu, Feb 7, 2013 at 10:57 PM, rh wrote: > On Thu, 7 Feb 2013 18:08:00 -0700 > Ian Kelly wrote: > >> Which is approximately 30 times slower, so clearly the regular >> expression *is* being cached. I think what we're seeing here is that >> the time needed to look up the compiled regular expression in the >> cache is a significant fraction of the time needed to actually execute >> it. > > By "actually execute" you mean to apply the compiled expression > to the search or sub? Or do you mean the time needed to compile > the pattern into a regex obj? The former. Both are dwarfed by the time needed to compile the pattern.