[Python-ideas] re.compile_lazy - on first use compiled regexes
M.-A. Lemburg
mal at egenix.com
Sat Mar 23 13:52:41 CET 2013
On 23.03.2013 13:43, Ronny Pfannschmidt wrote:
>
>> Wouldn't it make sense to add a way to pickle or marshal compiled REs ?
>>
>> The precompiled REs could then be loaded directly from the
>> pickle, avoiding the compiling overhead on startup.
>>
>
> as far as i can tell that would need regex as part of the syntax to make sense fort use in modules
> i dont think such a change would be accepted and i dont even what to deal with the potential
> bikeshedding for such an integration
I wasn't thinking of making it part of the Python byte-code.
It would suffice to add pickle/marshal support for the
compiled RE code. This could then be loaded from a string
embedded in the module code on startup.
E.g.
# rx = re.compile('.*')
rx = pickle.loads('asdfsadfasdf')
It would also be possible to seed the re module cache with
such pickle.loads, perhaps compiled at Python build time.
This would avoid having to change code in the stdlib to
load pickles.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Mar 23 2013)
>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2013-03-13: Released eGenix pyOpenSSL 0.13 ... http://egenix.com/go39
::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-ideas
mailing list