New submission from STINNER Victor:

Example:
---
def func(x, y):
    print(x, y)

def proxy2(func, **kw):
    func(**kw)

def proxy1(func, **kw):
    proxy2(func, **kw)
---

The "proxy2(func, **kw)" call in proxy1() is currently inefficient: 
_PyFunction_FastCallDict() converts the dictionary into a C array [key1, 
value1, key2, value2, ...] and then _PyEval_EvalCodeWithName() rebuilds the 
dictionary from the C array.

Since "func(*args, **kw)" proxies are common in Python, especially to call the 
parent constructor when overriding __init__, I think that it would be 
interesting to optimize this code path.

I first expected that it was a regression of FASTCALL, but Python < 3.6 doesn't 
optimize this code neither.

----------
components: Interpreter Core
messages: 285773
nosy: haypo, inada.naoki
priority: normal
severity: normal
status: open
title: Optimize _PyFunction_FastCallDict() for **kwargs
type: performance
versions: Python 3.7

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

Reply via email to