This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients josh.r, serhiy.storchaka, vstinner
Date 2016-12-01.12:44:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480596269.28.0.642033841859.issue28839@psf.upfronthosting.co.za>
In-reply-to
Content
> 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%)
History
Date User Action Args
2016-12-01 12:44:29vstinnersetrecipients: + vstinner, serhiy.storchaka, josh.r
2016-12-01 12:44:29vstinnersetmessageid: <1480596269.28.0.642033841859.issue28839@psf.upfronthosting.co.za>
2016-12-01 12:44:29vstinnerlinkissue28839 messages
2016-12-01 12:44:29vstinnercreate