Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102329 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2016-01-31 03:43 +0000 |
| Last post | 2016-01-31 03:43 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Re: psss...I want to move from Perl to Python MRAB <python@mrabarnett.plus.com> - 2016-01-31 03:43 +0000
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2016-01-31 03:43 +0000 |
| Subject | Re: psss...I want to move from Perl to Python |
| Message-ID | <mailman.149.1454211840.2338.python-list@python.org> |
On 2016-01-31 01:56:51, "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> wrote: >On Sunday 31 January 2016 09:18, Gregory Ewing wrote: > >> Rustom Mody wrote: >>> 1. One can use string-re's instead of compiled re's >> >> And I gather that string REs are compiled on first use and >> cached, so you don't lose much by using them most of the >> time. > >Correct. The re module keeps a cache of the last N regexes used, for >some >value of N (possibly 10?) so for casual use there's no real point to >pre- >compiling other than fussiness. > In Python 3.5, it's 512. > >But if you have an application that makes heavy-duty use of regexes, >e.g. >some sort of parser with dozens of distinct regexes, you might not want >to >rely on the cache. > It's slightly faster to use a pre-compiled regex because it won't have to look it up in the cache, although most of the time it probably won't matter.
Back to top | Article view | comp.lang.python
csiph-web