[issue31671] IntFlag makes re.compile slower
STINNER Victor
report at bugs.python.org
Tue Oct 3 09:51:37 EDT 2017
STINNER Victor <victor.stinner at 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 at selma$ ./python -m perf compare_to ref.json patch.json
Benchmark hidden because not significant (1): regex_compile
haypo at 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 at 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 <report at bugs.python.org>
<https://bugs.python.org/issue31671>
_______________________________________
More information about the Python-bugs-list
mailing list