Paul McGuire wrote: > Comparitive timing of pyparsing vs. re comes in at about 2ms for pyparsing, > vs. 0.13 for re's, so about 15x faster for re's. If psyco is used (and we > skip the first call, which incurs all the compiling overhead), the speed > difference drops to about 7-10x. I did try compiling the re, but this > didn't appear to make any difference - probably user error.
That is because of how the methods in the sre module are implemented... Compiling a regex really just saves you a dictionary lookup. def findall(pattern, string, flags=0): """snip""" return _compile(pattern, flags).findall(string) def compile(pattern, flags=0): """snip""" return _compile(pattern, flags) def _compile(*key): # internal: compile pattern cachekey = (type(key[0]),) + key p = _cache.get(cachekey) if p is not None: return p #snip -- - Justin -- http://mail.python.org/mailman/listinfo/python-list