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 josh.r, serhiy.storchaka, vstinner
Date 2016-12-01.12:07:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480594052.03.0.202766779194.issue28839@psf.upfronthosting.co.za>
In-reply-to
Content
bench_fastcalldict.py: hardcore microbenchmark on _PyFunction_FastCallDict(). Pass keyword arguments to the tp_init slot of a Python constructor. Result for 1, 5 and 10 keyword arguments:

kw1: Median +- std dev: [ref] 329 ns +- 21 ns -> [patch] 306 ns +- 17 ns: 1.07x faster (-7%)
kw5: Median +- std dev: [ref] 508 ns +- 22 ns -> [patch] 481 ns +- 25 ns: 1.05x faster (-5%)
kw10: Median +- std dev: [ref] 829 ns +- 45 ns -> [patch] 805 ns +- 39 ns: 1.03x faster (-3%)

As expected, the difference is small, but it's faster :-) Indirect benefit is that the garbage collector should be less stressed :-) (tuples are tracked by the GC.)

Note: Using a simple printf() in the C code, I noticed that it is not uncommon that _PyFunction_FastCallDict() is called with an empty dictionary for keyword arguments. Without the patch, an empty tuple was created. With my patch, "unpack" the empty dictionary costs nothing.
History
Date User Action Args
2016-12-01 12:07:32vstinnersetrecipients: + vstinner, serhiy.storchaka, josh.r
2016-12-01 12:07:32vstinnersetmessageid: <1480594052.03.0.202766779194.issue28839@psf.upfronthosting.co.za>
2016-12-01 12:07:32vstinnerlinkissue28839 messages
2016-12-01 12:07:31vstinnercreate