James Y Knight <[email protected]> added the comment:
Show your speed test? Looks 2.5x faster to me. But I'm running this on python
2.6, so I guess it's possible that the re module's speed was decimated in Py3k.
python -m timeit -s "$(printf "import re\ndef escape(s):\n return
re.sub('([][.^$*+?{}\\|()])', '\\\1', s)")"
'escape("!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()")'
100000 loops, best of 3: 18.4 usec per loop
python -m timeit -s "import re"
're.escape("!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()!@#$%^&*()")'
10000 loops, best of 3: 45.7 usec per loop
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue2650>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com