Message321400
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. |
|
Date |
User |
Action |
Args |
2018-07-10 23:13:39 | vstinner | set | recipients:
+ vstinner, methane, serhiy.storchaka |
2018-07-10 23:13:39 | vstinner | set | messageid: <1531264419.35.0.56676864532.issue34090@psf.upfronthosting.co.za> |
2018-07-10 23:13:39 | vstinner | link | issue34090 messages |
2018-07-10 23:13:39 | vstinner | create | |
|