5 ms·
> because regexpes are heavily optimized C code AFAIK, the python re module does not have a C language component. It is a pure python regular expression imple
by knome 15y ago
> because regexpes are heavily optimized C code
AFAIK, the python re module does not have a C language component. It is a pure python regular expression implementation.
- kkowalczyk 15y agoThat's not true: http://hg.python.org/cpython/file/d1d5a7392e39/Modules/_sre.c http://hg.python.org/cpython/file/d1d5a7392e39/Modules/_sre....
- deleted 15y ago[deleted]
- enneff 15y agoMost dynamic languages use a C Regular Expression library. That's why they can do so well on Regular Expression benchmarks. V8 is a notable exception. They use their code generation pipeline to JIT compile regexps to machine code, making it the fastest regexp engine around bar none (I think).
- azakai 15y agoAFAIK all modern JS engines JIT regexps: V8, SpiderMonkey and Nitro.
- silentbicycle 15y agoWhat about LPEG? It has a superset of the functionality of most regexp engines, yet is able to handle many things linearly that they would handle in quadratic time.
- pavpanchekha 15y agoI'd like to put in a word for CL-PPCRE, the Common Lisp regex library. It does the same except using the CL optimizing compiler, so also achieves amazing speed. Libraries don't appear in the Comp.Lang.Benchmark Shootout, so CL doesn't do so well.
- silentbicycle 15y agoPerformance-wise, any regex-based implementation may spend a lot of time backtracking and re-parsing data that a DFA hand-coded parser would handle in linear time.