Ville Vainio <[EMAIL PROTECTED]> writes: >>>>>> "Ilpo" == Ilpo Nyyssönen <iny> writes: > > 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.
If you would have read what I waid, you would have noticed this: ,---- | I would like to have a way to write a regexp as a constant and then | python should compile that regexp to the byte-code file. `---- and this: ,---- | This is not a problem in a program that continues to run long times, | but I want short lived programs like command line apps. `---- Of course it caches those when running. The point is that it needs to recompile every time you have restarted the program. With short lived command line programs this really can be a problem. And yes, I have read the source of sre.py and I have made an ugly module that digs the compiled data and pickles it to a file and then in next startup it reads that file and puts the stuff back to the cache. -- Ilpo Nyyssönen # biny # /* :-) */ -- http://mail.python.org/mailman/listinfo/python-list