Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48663
| Date | 2013-06-18 20:49 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Why is regex so slow? |
| References | <kpq2r9$gg6$1@panix2.panix.com> <CANc-5UyouN5EQw_GDecaAR+inyAB26g=e2pZ=zBuspXdmxJh+Q@mail.gmail.com> <B2AEBA54-6098-47D6-B7E0-77F0B7D8D722@panix.com> <mailman.3549.1371576854.3114.python-list@python.org> <kpqc0a$8am$1@panix2.panix.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3556.1371584976.3114.python-list@python.org> (permalink) |
On 18/06/2013 20:21, Roy Smith wrote: > In article <mailman.3549.1371576854.3114.python-list@python.org>, > Mark Lawrence <breamoreboy@yahoo.co.uk> wrote: > >> Out of curiousity have the tried the new regex module from pypi rather >> than the stdlib version? A heck of a lot of work has gone into it see >> http://bugs.python.org/issue2636 > > I just installed that and gave it a shot. It's *slower* (and, much > higher variation from run to run). I'm too exhausted fighting with > OpenOffice to get this into some sane spreadsheet format, so here's > the raw timings: > > Built-in re module: > 0:01.32 > 0:01.33 > 0:01.32 > 0:01.33 > 0:01.35 > 0:01.32 > 0:01.35 > 0:01.36 > 0:01.33 > 0:01.32 > > regex with flags=V0: > 0:01.66 > 0:01.53 > 0:01.51 > 0:01.47 > 0:01.81 > 0:01.58 > 0:01.78 > 0:01.57 > 0:01.64 > 0:01.60 > > regex with flags=V1: > 0:01.53 > 0:01.57 > 0:01.65 > 0:01.61 > 0:01.83 > 0:01.82 > 0:01.59 > 0:01.60 > 0:01.55 > 0:01.82 > I reckon that about 1/3 of that time is spent in PyArg_ParseTupleAndKeywords, just getting the arguments! There's a higher initial overhead in using regex than string methods, so working just a line at time will take longer.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why is regex so slow? roy@panix.com (Roy Smith) - 2013-06-18 12:45 -0400
Re: Why is regex so slow? Skip Montanaro <skip@pobox.com> - 2013-06-18 12:01 -0500
Re: Why is regex so slow? Roy Smith <roy@panix.com> - 2013-06-18 13:08 -0400
Re: Why is regex so slow? Chris Angelico <rosuav@gmail.com> - 2013-06-19 03:20 +1000
Re: Why is regex so slow? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-18 20:10 +0200
Re: Why is regex so slow? Roy Smith <roy@panix.com> - 2013-06-18 12:40 -0700
Re: Why is regex so slow? André Malo <ndparker@gmail.com> - 2013-06-18 21:59 +0200
Re: Why is regex so slow? André Malo <ndparker@gmail.com> - 2013-06-18 22:13 +0200
Re: Why is regex so slow? MRAB <python@mrabarnett.plus.com> - 2013-06-18 18:31 +0100
Re: Why is regex so slow? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-18 18:34 +0100
Re: Why is regex so slow? roy@panix.com (Roy Smith) - 2013-06-18 15:21 -0400
Re: Why is regex so slow? MRAB <python@mrabarnett.plus.com> - 2013-06-18 20:49 +0100
Re: Why is regex so slow? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-18 12:21 -0700
Re: Why is regex so slow? Antoine Pitrou <solipsis@pitrou.net> - 2013-06-18 20:05 +0000
Re: Why is regex so slow? Roy Smith <roy@panix.com> - 2013-06-18 13:23 -0700
Re: Why is regex so slow? Duncan Booth <duncan.booth@invalid.invalid> - 2013-06-19 13:21 +0000
Re: Why is regex so slow? Roy Smith <roy@panix.com> - 2013-06-19 12:55 -0700
Re: Why is regex so slow? Grant Edwards <invalid@invalid.invalid> - 2013-06-18 20:30 +0000
Re: Why is regex so slow? Terry Reedy <tjreedy@udel.edu> - 2013-06-18 17:29 -0400
Re: Why is regex so slow? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2013-06-19 10:29 +0200
Re: Why is regex so slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-19 01:51 +0000
Re: Why is regex so slow? Dave Angel <davea@davea.name> - 2013-06-18 22:11 -0400
Re: Why is regex so slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-19 03:16 +0000
csiph-web