3 ms·
iirc re caches regexps. so unless you're using many (more than the cache size [edit: 100]), i wouldn't worry (well, and also measuring before optimising...)
by andrewcooke 14y ago
iirc re caches regexps. so unless you're using many (more than the cache size [edit: 100]), i wouldn't worry (well, and also measuring before optimising...)
- aidos 14y agoI did wonder if that was the case but I couldn't find anything about it. Just discovered re._MAXCACHE which implies it does cache. Tested and in my case the performance is the same. Thanks for the tip (I was posting half hoping someone would have a better solution). That's another 3 lines of code removed :)