[Python-ideas] New 3.x restriction on number of keyword arguments
Cesare Di Mauro
cesare.di.mauro at gmail.com
Tue Oct 26 13:10:56 CEST 2010
2010/10/26 M.-A. Lemburg <mal at egenix.com>
> Cesare Di Mauro wrote:
> > I can provide another patch that will not use EXTENDED_ARG (no VM
> changes),
> > and uses *args and/or **kwargs function calls when there are more than
> 255
> > arguments or keyword arguments.
> >
> > But I need some days.
> >
> > If needed, I'll post it at most on this week-end.
>
> You mean a version that pushes the *args tuple and **kws dict
> on the stack and then uses those for calling the function/method ?
>
> I think that would be a lot more efficient than pushing/popping
> hundreds of parameters on/off the stack.
>
> --
> Marc-Andre Lemburg
>
I was referring to the solution (which I prefer) that I proposed answering
to Greg, two days ago.
Unfortunately, the stack must be used whatever the solution we will use.
Pushing the "final" tuple and/or dictionary is a possible optimization, but
we can use it only when we have a tuple or dict of constants; otherwise we
need to use the stack.
Good case: f(1, 2, 3, a = 1, b = 2)
We can push (1, 2, 3) tuple and {'a' : 1, 'b' : 2}, then calling f with
CALL_FUNCTION_VAR_KW opcode passing narg = nkarg = 0.
Worst case: f(1, x, 3, a = x, b = 2)
We can't push the tuple and dict as a whole, because they need first to be
built using the stack.
The good case is possible, and I have already done some work in wpython
collecting constants on parameters push (even partial constant sequences),
but some additional work must be done recognizing costants-only tuple /
dict.
However, the worst case rest unresolved.
Cesare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101026/449f82e0/attachment.html>
More information about the Python-ideas
mailing list