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 vstinner
Date 2016-12-09.01:07:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481245654.11.0.143889949597.issue28915@psf.upfronthosting.co.za>
In-reply-to
Content
This issue tracks changes to support the "fast call" calling convention in functions:

* PyObject_CallFunctionObjArgs()
* PyObject_CallMethodObjArgs()
* _PyObject_CallMethodIdObjArgs()

A "stack" of Python objects is created to pass arguments to _PyObject_FastCall(). The goal is to avoid the creation of a temporary tuple to call functions.

The patch serie changes slots (typeobject.c), so calling Python slots from Python should avoid completely the creation of temporary tuples to pass parameters.


Microbenchmark on a simple class with an __int__() method, call int(o):

int(o): Median +- std dev: [ref] 239 ns +- 13 ns -> [patch] 219 ns +- 14 ns: 1.10x faster (-9%)


Microbenchmark on a simple class with an __getitem__() method, call o[100]:

o[100]: Median +- std dev: [ref] 211 ns +- 11 ns -> [patch] 172 ns +- 11 ns: 1.23x faster (-19%)


Comparison between Python 2.7, 3.5, 3.7 and 3.7+patch, 3.5 is used as the reference:

int(o)
======

Median +- std dev: [3.5] 271 ns +- 15 ns -> [3.7] 239 ns +- 13 ns: 1.13x faster (-12%)
Median +- std dev: [3.5] 271 ns +- 15 ns -> [patch] 219 ns +- 14 ns: 1.24x faster (-19%)
Median +- std dev: [3.5] 271 ns +- 15 ns -> [2.7] 401 ns +- 21 ns: 1.48x slower (+48%)

o[100]
======

Median +- std dev: [3.5] 206 ns +- 5 ns -> [3.7] 211 ns +- 11 ns: 1.02x slower (+2%)
Not significant!
Median +- std dev: [3.5] 206 ns +- 5 ns -> [patch] 172 ns +- 11 ns: 1.20x faster (-17%)
Median +- std dev: [3.5] 206 ns +- 5 ns -> [2.7] 254 ns +- 15 ns: 1.23x slower (+23%)
History
Date User Action Args
2016-12-09 01:07:34vstinnersetrecipients: + vstinner
2016-12-09 01:07:34vstinnersetmessageid: <1481245654.11.0.143889949597.issue28915@psf.upfronthosting.co.za>
2016-12-09 01:07:34vstinnerlinkissue28915 messages
2016-12-09 01:07:33vstinnercreate