psss...I want to move from Perl to Python
Rustom Mody
rustompmody at gmail.com
Sat Jan 30 22:22:08 EST 2016
On Sunday, January 31, 2016 at 7:27:06 AM UTC+5:30, Steven D'Aprano 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.
>
> 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.
>
>
>
> --
> Steve
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>>
>>> import re
>>> re._MAXCACHE
512
>>>
Have you ever seen a program that uses 512 re's?
I havent :-)
More information about the Python-list
mailing list