Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.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.052 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'string': 0.09; 'builtin': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rebuild': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'not,': 0.20; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'faster,': 0.31; 'i.e.': 0.36; 'should': 0.36; 'too': 0.37; '8bit%:86': 0.38; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'analyze': 0.60; 'most': 0.60; 'real': 0.63; 'such': 0.63; 'received:46': 0.66; 'overall': 0.69; 'theoretical': 0.74; '.replace': 0.84; 'subject:skip:S 10': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: Find and Replace Simplification Date: Sun, 21 Jul 2013 10:44:19 +0300 References: <51e967bb$0$29971$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 46.211.124.101 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 In-Reply-To: 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374392677 news.xs4all.nl 16000 [2001:888:2000:d::a6]:54284 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50999 20.07.13 20:03, Joshua Landau написав(ла): > 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 it possible), i.e. '&' should be replaced before '<' in html.escape. This extra work is too large for most real input.