Issue 34090: Python function call optimization: avoid temporary tuple to pass **kwargs (original) (raw)

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:

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

To be clear: FASTCALL didn't make this specific function call (Python => Python with **kw) worse nor better.