On Sat, Mar 23, 2013 at 2:52 PM, M.-A. Lemburg mal@egenix.com wrote:
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')
According to http://bugs.python.org/issue11454#msg170697, this would be twice as slow.
Best Regards, Ezio Melotti
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