Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '2.7': 0.04; 'python': 0.08; 'correct.': 0.09; 'expressions.': 0.09; 'from:addr:python': 0.09; 'str': 0.09; '>>>': 0.12; 'wrote:': 0.14; '2.7:': 0.16; 'experiment.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'methods,': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'roy': 0.16; '(perhaps': 0.19; 'solution.': 0.19; 'header :In-Reply-To:1': 0.21; 'seems': 0.21; 'say,': 0.22; 'received:84': 0.25; 'problem': 0.28; 'subject:how': 0.29; 'odd': 0.29; "python's": 0.29; 'least': 0.30; 'module': 0.30; 'usually': 0.32; 'to:addr:python-list': 0.33; 'too': 0.33; "i've": 0.33; 'regular': 0.34; 'header:User-Agent:1': 0.35; 'reply-to:addr:python.org': 0.35; 'typical': 0.35; 'subject:: ': 0.38; 'some': 0.38; 'case,': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'best': 0.60; 'email addr:yahoo.com': 0.63; 'skip:1 10': 0.63; 'header:Reply- To:1': 0.72; 'reply-to:no real name:2**0': 0.72; '(unicode)': 0.84; 'article,': 0.84; 'surprise,': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak8LAB5J6E3Unw4S/2dsb2JhbABTl2gyjiB3yX6GIQSVMYQvhj8 Date: Fri, 03 Jun 2011 03:41:47 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: how to avoid leading white spaces References: <9e861b0e-e768-401b-b5ca-190f20830a08@s9g2000yqm.googlegroups.com> <94ph22FrhvU5@mid.individual.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307068911 news.xs4all.nl 49184 [::ffff:82.94.164.166]:43334 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6905 On 03/06/2011 02:57, Roy Smith wrote: > In article<94ph22FrhvU5@mid.individual.net>, > Neil Cerutti wrote: > >> On 2011-06-01, rurpy@yahoo.com wrote: >>> For some odd reason (perhaps because they are used a lot in >>> Perl), this groups seems to have a great aversion to regular >>> expressions. Too bad because this is a typical problem where >>> their use is the best solution. >> >> Python's str methods, when they're sufficent, are usually more >> efficient. > > I was all set to say, "prove it!" when I decided to try an experiment. > Much to my surprise, for at least one common case, this is indeed > correct. > [snip] I've tested it on my PC for Python 2.7 (bytestring) and Python 3.1 (Unicode) and included the "regex" module on PyPI: Python 2.7: 0.949936333562 4.31320052965 1.14035334748 Python 3.1: 1.27268308633 4.2509511537 1.16866839819