~/talk

Faster, Faster! Improving regex performance with atomic grouping, possessive quantifiers and more!

Talkat PyCon AU 2023 · 2023-08-18..08-22· [python]
links:none on file
slides:none on file

Benchmarks run on Python 3.11 (CPython 3.11.4) on Windows 10 and timed with an IPython timer show concrete fixes: compile patterns (module cache actually defaults to 512 patterns), avoid dot and nested unbounded quantifiers, use negated classes, atomic grouping and possessive quantifiers to eliminate catastrophic backtracking. Reported wins include ~500% for startswith vs regex, 280% from clamping quantifiers, 78% by removing overlapping classes, 26% for atomic groups and even a cited 2 million percent case when possessive quantifiers remove exponential work.

AI-written summary · about

  1. 0:00Regex performance intro
  2. 2:08Rule one: avoid regex
  3. 3:10Avoid regex for simple matches
  4. 4:37Pre-compile regex patterns
  5. 5:41Replace flags with classes
  6. 6:29Quantifiers and failed cases
  7. 7:31Avoid plus and star quantifiers
  8. 8:15Greedy vs lazy quantifiers
  9. 9:21Negated classes vs dot
  10. 10:49Non-capturing groups
  11. 11:31Regex backtracking
  12. 13:21Catastrophic backtracking
  13. 15:30Solutions to backtracking
  14. 16:34Mutually exclusive classes
  15. 16:56Atomic grouping and possessive quantifiers
  16. 18:43When possessive quantifiers work
  17. 19:49Possessive in quoted strings
  18. 20:12Speed boost with possessive
  19. 21:57Key regex tips
  20. 22:40Avoid nested unbounded quantifiers
  21. 23:22Python 3.11 regex updates
  22. 24:47Regex engine differences
  23. 26:16Q&A on possessive quantifiers
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.