4 ms·
Python Support for Regular Expressions
- MichaelMoser123 5y agoIf you are doing something heavy on regular expression, then you are much better off with re2 from google. https://pypi.org/project/re2/ https://pypi.org/project/re2/ https://swtch.com/~rsc/regexp/regexp1.html https://swtch.com/~rsc/regexp/regexp1.html Also re is running in python, whereas re2 is written in C (with python language bindings) I wonder, why python didn't ditch the built-in re package in favor of re2... That might be due to some compatibility issues, but i don't know anything specific.
- deleted 5y ago[deleted]
- metadat 5y agoAre you able to qualify: Better off in what way? The built-in re package has always been sufficient for me and I dream in regex.
- Loranubi 5y agore2 is using state machines to evaluate everything in linear time. Backtracking re implementations have some very slow edge cases.
- Loranubi 5y agoBecause re2 doesn't support everything POSIX regex support.
- jwilk 5y agoWhy does it matter? Python's re doesn't support all POSIX ERE constructs either.
- Dunedan 5y agoThe features of the regex module mentioned in the article sound great. I wonder why the Python core developers are so hesitant to add new functionality to the standard library. There are exceptions, like the new zoneinfo module, which is great, but overall I'd like to see more of that. Here is a list of features I regularly wish would be part of the standard library: - more compression algorithms (e.g. brotli, zstandard) - more hashing algorithms (e.g. argon2, bcrypt) - support for parsing ISO 8601 date times with "Z" as timezone designator - a TTL-cache implementation (like cachetools offers) - support for reading/writing YAML