Jonas H. <jo...@lophus.org> added the comment:

I agree with your statement in principle. Here are numbers for the slowdown 
that's introduced:

Without the change:
  ./python.exe -m timeit -s 'import re'\n'[re.compile(f"fill_cache{i}") for i 
in range(512)]'\n'pat = re.compile(".")' 're.match(pat, "asdf")'
  500000 loops, best of 5: 462 nsec per loop
  ./python.exe -m timeit -s 'import re'\n'[re.compile(f"fill_cache{i}") for i 
in range(512)]'\n'pat = re.compile(".")' 're.match(".", "asdf")'
  1000000 loops, best of 5: 316 nsec per loop

With the change:
  ./python.exe -m timeit -s 'import re'\n'[re.compile(f"fill_cache{i}") for i 
in range(512)]'\n'pat = re.compile(".")' 're.match(pat, "asdf")'
1000000 loops, best of 5: 207 nsec per loop
  ./python.exe -m timeit -s 'import re'\n'[re.compile(f"fill_cache{i}") for i 
in range(512)]'\n'pat = re.compile(".")' 're.match(".", "asdf")'
1000000 loops, best of 5: 351 nsec per loop

So we have a 2x speedup in the uncommon case and a 10% slowdown in the common 
case.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45462>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to