Regular Expressions - Python vs Perl
Ville Vainio
ville at spammers.com
Fri Apr 22 05:06:47 EDT 2005
>>>>> "Ilpo" == Ilpo Nyyssönen <iny> writes:
Ilpo> James Stroud <jstroud at mbi.ucla.edu> writes:
>> Is it relevant that Python can produce compiled expressions? I
>> don't think that there is such a thing with Perl.
Ilpo> The problem in python here is that it needs to always
Ilpo> recompile the regexp. I would like to have a way to write a
Ilpo> regexp as a constant and then python should compile that
Ilpo> regexp to the byte-code file.
Ilpo> This is a problem when one has a big amount of regexps. One
Ilpo> example is the xmlproc parser in PyXML,
Read the source for sre.py, esp. _compile. The compiled regexps are
cached, so when you invoke e.g. re.match(), it doesn't recompile the
regexp.
So this point is moot, and perl's approach is excessive special
casing.
--
Ville Vainio http://tinyurl.com/2prnb
More information about the Python-list
mailing list