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 methane, rhettinger, serhiy.storchaka, vstinner, yselivanov
Date 2017-01-24.09:24:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Serhiy Storchaka: "Calling _PyStack_AsDict() with non-string or non-unique keywords means that the var-keyword argument was first unpacked to arrays of keyword names and values and then converted back to a dict. Seems something is done non-efficiently." (msg286159 of the issue #29360)

Python code from test_dict:



    LOAD_GLOBAL              1 (dict)
    BUILD_TUPLE              0
    LOAD_FAST                1 (invalid)
    CALL_FUNCTION_EX         1

Call stack:

* _PyEval_EvalFrameDefault()
* do_call_core()
* PyObject_Call()
* _Py_RawFastCallDict() -- conversion from dict to stack+kwnames
* type_call()
* call_init()
* _PyStack_AsDict() -- convertsion from stack+kwnames to dict

Oh right, there are two conversions using a temporary FASTCALL format for (keyword) arguments.

This code was not upstream yet, it comes from the pull request of this issue.

Maybe we need two flavors of type_call(): type_call(args: tuple, kwargs: tuple) if tp_fastinit isn't set, type_fastcall(stack, nargs, kwnames) (FASTCALL) if tp_fastinit is set.

But it seems that the logic should be implemented in PyObject_Call() and _PyObject_FastCallDict(), it cannot be implemented in type_call(), it's too late.

For best performances (avoid any kind of conversion and avoid any temporary object), we should implement something like that.
Date User Action Args
2017-01-24 09:24:35vstinnersetrecipients: + vstinner, rhettinger, methane, serhiy.storchaka, yselivanov
2017-01-24 09:24:35vstinnersetmessageid: <>
2017-01-24 09:24:34vstinnerlinkissue29358 messages
2017-01-24 09:24:34vstinnercreate