This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients methane, serhiy.storchaka, vstinner
Date 2017-10-03.13:51:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507038697.63.0.213398074469.issue31671@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2017-10-03 13:51:37vstinnersetrecipients: + vstinner, methane, serhiy.storchaka
2017-10-03 13:51:37vstinnersetmessageid: <1507038697.63.0.213398074469.issue31671@psf.upfronthosting.co.za>
2017-10-03 13:51:37vstinnerlinkissue31671 messages
2017-10-03 13:51:37vstinnercreate