New submission from STINNER Victor:

Attached patch is a minor optimization for _PyFunction_FastCallDict(): avoid 
the creation of a tuple to pass keyword arguments, use a simple C array 
allocated by PyMem_Malloc().

It also uses a small stack of 80 bytes (2*5*sizeof(PyObject*)) allocated on the 
C stack to pass up to 5 keyword arguments (5 key+value pairs): it avoids 
completely the allocation on the heap memory 

I wrote _PyFunction_FastCallDict() (issue #27809): the code was based on 
function_call() which also uses PyTuple_New(). When I wrote the function, I 
didn't notice that PyEval_EvalCodeEx() doesn't expect a Python tuple object, 
but a C array.

The patch also modifies function_call() to call _PyFunction_FastCallDict(), so 
it gets _PyFunction_FastCallDict() optimizations.

----------
files: fastcalldict.patch
keywords: patch
messages: 282079
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: _PyFunction_FastCallDict(): replace PyTuple_New() with PyMem_Malloc()
type: performance
versions: Python 3.7
Added file: http://bugs.python.org/file45703/fastcalldict.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28839>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to