Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.194 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.66; '*S*': 0.04; 'string': 0.09; 'builtin': 0.09; 'cc:addr:python-list': 0.11; 'rebuild': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'not,': 0.20; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'faster,': 0.31; 'received:google.com': 0.35; 'i.e.': 0.36; 'should': 0.36; 'too': 0.37; '8bit%:86': 0.38; 'mapping': 0.38; 'does': 0.39; 'analyze': 0.60; 'most': 0.60; 'real': 0.63; 'such': 0.63; 'july': 0.63; 'to:addr:gmail.com': 0.65; 'overall': 0.69; 'theoretical': 0.74; '.replace': 0.84; 'subject:skip:S 10': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=DA4y0EVwdP00vXTtsNM6eQTOO1lDCEIw5uJ7Harr0Fw=; b=XfasqeIfyHEozJ6MxTW9/fYtKaiMHvUY6IEb/DD2ib2rJtErKHcByi3lEUEZ2PWb76 FeKO5NEk2QCsyt+lzJRvuMUqUz5aJVZbCvuVsPpdBW+E0YMPdWP0ODqhbNG98l8u0nIy HZqr/Q/6VHlEnlcucFQ9+T8wN0AaIqBC1ze6PYEt0dYibT/VBQBZiNOB0pUuOicW0WM+ MNUMfEJ1AbljezPHSvAxokchOOn3d3+rsx04cAVFT0h4Zzvk8nKplgqpe3aSg9ppiw2e /ReU79bJRu5W4lfuPQ2e3R4lrMlQYj7raEurG6GXrGfz+40N7e0seKu1EJEKFoDXiUoV eeCg== X-Received: by 10.152.88.78 with SMTP id be14mr10675923lab.19.1374406206825; Sun, 21 Jul 2013 04:30:06 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: <51e967bb$0$29971$c3e8da3$5496439d@news.astraweb.com> From: Joshua Landau Date: Sun, 21 Jul 2013 12:29:26 +0100 X-Google-Sender-Auth: LwdoTBvsnU9TBOTRAJ3dTszs-K8 Subject: Re: Find and Replace Simplification To: Serhiy Storchaka Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374406214 news.xs4all.nl 15985 [2001:888:2000:d::a6]:58508 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51007 On 21 July 2013 08:44, Serhiy Storchaka wrote: > 20.07.13 20:03, Joshua Landau =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=B2(= =D0=BB=D0=B0): > >> Still, it seems to me that it should be optimizable for sensible >> builtin types such that .translate is significantly faster, as there's >> no theoretical extra work that .translate *has* to do that .replace >> does not, and .replace also has to rebuild the string a lot of times. > > You should analyze overall mapping and reorder items in right order (if i= t > possible), i.e. '&' should be replaced before '<' in html.escape. This ex= tra > work is too large for most real input. I don't understand. What items are you reordering?