homepage

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.

classification
Title: Modify PyObject_CallFunction() to use fast call internally
Type: performance Stage:
Components: Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, vstinner
Priority: normal Keywords:

Created on 2016年12月09日 01:07 by vstinner, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bench_slots.py vstinner, 2016年12月09日 01:15
Messages (8)
msg282748 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016年12月09日 01:07
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%)
msg282749 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016年12月09日 01:15
bench_slots.py: microbenchmark on __int__ and __getitem__ slots.
msg282751 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年12月09日 01:17
New changeset b771cf37714b by Victor Stinner in branch 'default':
Add _PyObject_FastCallVa() helper
https://hg.python.org/cpython/rev/b771cf37714b
New changeset 455169e87bb3 by Victor Stinner in branch 'default':
Add _PyObject_CallFunctionVa() helper
https://hg.python.org/cpython/rev/455169e87bb3
New changeset dd0d162593c5 by Victor Stinner in branch 'default':
modsupport: replace int with Py_ssize_t
https://hg.python.org/cpython/rev/dd0d162593c5
New changeset 69d5dcf31f4a by Victor Stinner in branch 'default':
modsupport: replace int with Py_ssize_t
https://hg.python.org/cpython/rev/69d5dcf31f4a
New changeset c1414b182232 by Victor Stinner in branch 'default':
Add _Py_VaBuildStack() function
https://hg.python.org/cpython/rev/c1414b182232
New changeset 69948a157507 by Victor Stinner in branch 'default':
_PyObject_CallFunctionVa() uses fast call
https://hg.python.org/cpython/rev/69948a157507
New changeset b9eb35435178 by Victor Stinner in branch 'default':
Don't parenthesis in _PyObject_CallMethodId() format
https://hg.python.org/cpython/rev/b9eb35435178
New changeset 67302e6caa29 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs()
https://hg.python.org/cpython/rev/67302e6caa29
New changeset 032cbdb596fe by Victor Stinner in branch 'default':
build_struct_time() uses Py_BuildValue()
https://hg.python.org/cpython/rev/032cbdb596fe
New changeset 49a7fdc0d40a by Victor Stinner in branch 'default':
time_strptime() uses PyObject_Call()
https://hg.python.org/cpython/rev/49a7fdc0d40a
New changeset 6e748eb79038 by Victor Stinner in branch 'default':
Add _PyObject_VaCallFunctionObjArgs() private function
https://hg.python.org/cpython/rev/6e748eb79038
New changeset adcd9131b7c6 by Victor Stinner in branch 'default':
Use _PyObject_FastCallVa() in type slots
https://hg.python.org/cpython/rev/adcd9131b7c6 
msg282780 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年12月09日 13:43
New changeset 39bed12135c1 by Victor Stinner in branch 'default':
Issue #28915: Use _PyObject_CallNoArg()
https://hg.python.org/cpython/rev/39bed12135c1
New changeset b29c719d5992 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs() in _asyncio
https://hg.python.org/cpython/rev/b29c719d5992 
msg282786 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年12月09日 15:31
New changeset 807688539b56 by Victor Stinner in branch 'default':
Fix refleak introduced in change 032cbdb596fe
https://hg.python.org/cpython/rev/807688539b56
New changeset ceb22b8f6d32 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs() in _ctypes
https://hg.python.org/cpython/rev/ceb22b8f6d32
New changeset ef05cc5cc651 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs() in _elementtree
https://hg.python.org/cpython/rev/ef05cc5cc651
New changeset 5b41b92a7ccf by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs() in _datetime
https://hg.python.org/cpython/rev/5b41b92a7ccf
New changeset 434e76e0ee17 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs() in _io
https://hg.python.org/cpython/rev/434e76e0ee17
New changeset 4545a2293e01 by Victor Stinner in branch 'default':
Use _PyObject_CallMethodIdObjArgs()
https://hg.python.org/cpython/rev/4545a2293e01
New changeset 4321f833a4e0 by Victor Stinner in branch 'default':
Use PyObject_CallFunctionObjArgs()
https://hg.python.org/cpython/rev/4321f833a4e0 
msg282789 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016年12月09日 16:28
The main feature was implemented, so I close the issue.
Enjoy faster slots! (Many other less important functions are also faster.)
msg283286 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年12月15日 11:55
New changeset bec846dd92e8 by Victor Stinner in branch 'default':
Fix _PyObject_CallFunctionVa(), use the small stack
https://hg.python.org/cpython/rev/bec846dd92e8 
msg284109 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年12月27日 15:59
New changeset fa9933bf4ea0 by Serhiy Storchaka in branch 'default':
Issue #28915: Exclude _Py_VaBuildStack from the limited API.
https://hg.python.org/cpython/rev/fa9933bf4ea0 
History
Date User Action Args
2022年04月11日 14:58:40adminsetgithub: 73101
2016年12月27日 15:59:28python-devsetmessages: + msg284109
2016年12月15日 11:55:10python-devsetmessages: + msg283286
2016年12月09日 16:28:57vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg282789
2016年12月09日 15:31:43python-devsetmessages: + msg282786
2016年12月09日 13:43:19python-devsetmessages: + msg282780
2016年12月09日 01:17:09python-devsetnosy: + python-dev
messages: + msg282751
2016年12月09日 01:15:03vstinnersetfiles: + bench_slots.py

messages: + msg282749
2016年12月09日 01:07:34vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /