STINNER Victor <victor.stin...@gmail.com> added the comment: Serhiy: "Victor, how large is performance regression of your patch?"
I tested bm_regex_compile.py of the Python performance benchmark suite: https://pyperformance.readthedocs.io/benchmarks.html#regex-compile My patch has no impact on *uncached* re.compile() performances according to this benchmark. haypo@selma$ ./python -m perf compare_to ref.json patch.json Benchmark hidden because not significant (1): regex_compile haypo@selma$ ./python -m perf compare_to ref.json patch.json -v Mean +- std dev: [ref] 386 ms +- 6 ms -> [patch] 387 ms +- 6 ms: 1.00x slower (+0%) Not significant! -- On a microbenchmark on the *cache* itself, the difference is visible: 1018 ./python -m perf timeit -s 'import re; re_compile=re.compile' 're_compile("a", flags=2)' --duplicate=1024 -o ref.json --inherit=PYTHONPATH -v 1019 git co re_compile_flags_type 1020 make 1021 ./python -m perf timeit -s 'import re; re_compile=re.compile' 're_compile("a", flags=2)' --duplicate=1024 -o patch.json --inherit=PYTHONPATH -v 1022 ./python -m perf compare_to ref.json patch.json 1023 git diff master.. haypo@selma$ ./python -m perf compare_to ref.json patch.json Mean +- std dev: [ref] 364 ns +- 6 ns -> [patch] 459 ns +- 10 ns: 1.26x slower (+26%) If you replace type(flags) with flags.__class__, the change has no impact on performances :-) But obj.__class__ can be different than type(obj). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31671> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com