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 2018-07-10.23:13:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531264419.35.0.56676864532.issue34090@psf.upfronthosting.co.za>
In-reply-to
Content
On the following code, f() uses CALL_FUNCTION_EX bytecode to call g(). The bytecode loads 'kw' variable which is a dictionary. But internally, the dictionary is converted to a temporary tuple, and later a new dictionary is created. Maybe the temporary tuple could be avoided?

def g(*args, **kw):
    ...

def f(*args, **kw):
    g(*args, **kw)

In Python 3.6, before FASTCALL, CALL_FUNCTION_EX calls:

* do_call_core(): kw dict
* PyObject_Call(): kw dict
* function_call(): kw dict -> create a temporary tuple of keys and names: (key[0], value[0], ...)
* _PyEval_EvalCodeWithName(): if CO_VARKEYWORDS, rebuild a new dictionary for keyword arguments (**kw)

In Python master branch (future 3.8) with FASTCALL, CALL_FUNCTION_EX calls:

* do_call_core(): kw dict
* _PyFunction_FastCallDict(): kw dict -> a temporary tuple for keyword names ('kwnames') is created
* _PyEval_EvalCodeWithName(): if CO_VARKEYWORDS, rebuild a new dictionary for keyword arguments (**kw)

To be clear: FASTCALL didn't make this specific function call (Python => Python with **kw) worse nor better.
History
Date User Action Args
2018-07-10 23:13:39vstinnersetrecipients: + vstinner, methane, serhiy.storchaka
2018-07-10 23:13:39vstinnersetmessageid: <1531264419.35.0.56676864532.issue34090@psf.upfronthosting.co.za>
2018-07-10 23:13:39vstinnerlinkissue34090 messages
2018-07-10 23:13:39vstinnercreate