Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'example:': 0.03; 'languages,': 0.04; 'c++,': 0.07; 'correct.': 0.07; 'expressions': 0.07; 'javascript,': 0.07; 'perl,': 0.07; 'php,': 0.09; 'skip:/ 10': 0.09; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'notation': 0.16; 'world!': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'wed,': 0.18; "python's": 0.19; 'things.': 0.19; 'example': 0.22; 'parse': 0.24; 'skip:% 10': 0.24; 'tells': 0.24; "haven't": 0.24; "i've": 0.25; 'this:': 0.26; 'least': 0.26; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; "doesn't": 0.30; 'compared': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'are.': 0.31; 'lot.': 0.31; 'peterson': 0.31; 'post.': 0.31; 'stuff': 0.32; 'regular': 0.32; 'text': 0.33; 'noticed': 0.34; "can't": 0.35; 'problem.': 0.35; 'something': 0.35; 'etc': 0.35; 'received:google.com': 0.35; 'largely': 0.36; 'much.': 0.36; 'doing': 0.36; 'so,': 0.37; 'performance': 0.37; '(3)': 0.38; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'no.': 0.61; 'simply': 0.61; 'information': 0.63; 'more': 0.64; '(5)': 0.74; 'jul': 0.74; '.....': 0.78; 'partial': 0.84; 'significance': 0.84; 'numerous': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=u64gb7hPe0xDuD++Sf20x8z10MvVC/DO2er7eqyLBe4=; b=tpjRI1ztzxHFsGScr1w03sWOUSsRPkqcICAQQZQ9z4M6AEo5PmO8hpOTevp0srn6d5 gz+5Ya+UEHq3xQoGoyl7Yb7o2tgYLST1XRx7IFx9buEaHphJVBtGOleOfZHM0Mm9FdHP xd8LEPkYaFpjpcxOe9zloZCL4Xj6VsCDm0++/B9uR76xDlfeZl8B7NtBU7M9gsMqqMOk lXp2avvnWNasAUBy/8u+Paag+mezzR4V8f6tzwQwMZOyt2RZusMquwF/0j+7hiZmCG3U 6/cAbf7oyc5/i9Sn8CM75l4Q+69xYJvN6Y5P781zAHUv5kBsiL07J8nEQ7weqFPPYEWj ha+g== MIME-Version: 1.0 X-Received: by 10.220.182.193 with SMTP id cd1mr18695409vcb.32.1373449145255; Wed, 10 Jul 2013 02:39:05 -0700 (PDT) In-Reply-To: References: Date: Wed, 10 Jul 2013 19:39:05 +1000 Subject: =?windows-1252?Q?Re=3A_Stack_Overflow_moderator_=93animuson=94?= From: Chris Angelico To: python-list@python.org 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373449148 news.xs4all.nl 15881 [2001:888:2000:d::a6]:47252 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50330 On Wed, Jul 10, 2013 at 7:01 PM, Mats Peterson wrote: > Chris Angelico wrote: >> I know what regular expressions are. I've used them in Perl, PHP, >> JavaScript, Python, C++, Pike, and numerous text editors (which may >> have been backed by one of the above languages, or may have been >> something else). Doesn't change the fact that I have no idea what the >> significance is of your post. >> >> ChrisA > > You do? And you haven't noticed the inferior performance of regular > expressions in Python compared to Perl? Then you obviously haven't > used them a lot. That would be correct. Why have I not used them all that much? Because Python has way better ways of doing many things. Regexps are notoriously hard to debug, largely because a nonmatching regex can't give much information about _where_ it failed to match, and when I parse strings, it's more often with (s)scanf notation instead - stuff like this (Pike example as Python doesn't, afaik, have scanf support): > data="Hello, world! I am number 42."; > sscanf(data,"Hello, %s! I am number %d.",foo,x); (3) Result: 2 > foo; (4) Result: "world" > x; (5) Result: 42 Or a more complicated example: sscanf(Stdio.File("/proc/meminfo")->read(),"%{%s: %d%*s\n%}",array data); mapping meminfo=(mapping)data; That builds up a mapping (Pike terminology for what Python calls a dict) with the important information out of /proc/meminfo, something like this: ([ "MemTotal": 2026144, "MemFree": 627652, "Buffers": 183572, "Cached": 380724, ..... etc etc ]) So, no. I haven't figured out that Perl's regular expressions outperform Python's or Pike's or SciTE's, because I simply don't need them all that much. With sscanf, I can at least get a partial match, which tells me where to look for the problem. ChrisA