STINNER Victor added the comment:
> Note: Using a simple printf() in the C code, I noticed that it is not
> uncommon that _PyFunction_FastCallDict() is called with an empty dictionary
> for keyword arguments.
Simplified Python example where _PyFunction_FastCallDict() is called with an
empty dictionary:
---
def f2():
pass
def wrapper(func, *args, **kw):
# CALL_FUNCTION_EX: func(**{}) calls PyObject_Call() with kwargs={} which
# calls _PyFunction_FastCallDict()
func(*args, **kw)
def f():
# CALL_FUNCTION: calling wrapper calls fast_function() which calls
# _PyEval_EvalCodeWithName() which creates an empty dictionary for kw
wrapper(f2)
f()
---
But on this specific case, the speedup is *very* small: 3 nanoseconds :-)
./python -m perf timeit -s 'kw={}' -s 'def func(): pass' --duplicate=1000
'func(**kw)'
(...)
Median +- std dev: [ref] 108 ns +- 4 ns -> [patch] 105 ns +- 5 ns: 1.02x faster
(-2%)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28839>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com