[Python-ideas] Ordering keyword dicts

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Jun 10 07:46:51 CEST 2013


On Mon, Jun 10, 2013 at 1:14 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> The various "CALL_FUNCTION*" opcodes in CPython almost always end up
> passing through a snippet like the following in ceval.c [1,2] (there
> are a couple of exceptions related to optimisation of calls that only
> involve positional arguments and parameters):
>
>     if (PyCFunction_Check(func)) {
>         PyThreadState *tstate = PyThreadState_GET();
>         C_TRACE(result, PyCFunction_Call(func, callargs, kwdict));
>     }
>     else
>         result = PyObject_Call(func, callargs, kwdict);

This is correct for calling functions implemented in C, but python function
calls go through a special treatment:

        if (PyFunction_Check(func))
            x = fast_function(func, pp_stack, n, na, nk);

Eventually, this gets to PyEval_EvalCodeEx, where keyword arguments are
still ordered.  I believe this would be the place where a new co_* flag can
be checked and order preserved.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130610/8d179259/attachment.html>


More information about the Python-ideas mailing list