Message282168
> 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%) |
|
Date |
User |
Action |
Args |
2016-12-01 12:44:29 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka, josh.r |
2016-12-01 12:44:29 | vstinner | set | messageid: <1480596269.28.0.642033841859.issue28839@psf.upfronthosting.co.za> |
2016-12-01 12:44:29 | vstinner | link | issue28839 messages |
2016-12-01 12:44:29 | vstinner | create | |
|