[Python-ideas] New 3.x restriction on number of keyword arguments
alexander.belopolsky at gmail.com
Thu Oct 21 18:13:49 CEST 2010
On Thu, Oct 21, 2010 at 11:41 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> Looking at the AST code, the limitation appears somewhat arbitrary.
> There's no comment in the code suggesting a reason for the limit and
> it's still possible to pass in more arguments via *args and **kws -
> but without the built-in argument checking.
> Could someone provide some insight ?
My understanding is that the limitation comes from bytecode generation
phase, not AST.
See also Guido's http://bugs.python.org/issue1636#msg58760.
According to Python manual section for opcodes,
Calls a function. The low byte of argc indicates the number of
positional parameters, the high byte the number of keyword parameters.
On the stack, the opcode finds the keyword parameters first. For each
keyword argument, the value is on top of the key. Below the keyword
parameters, the positional parameters are on the stack, with the
right-most parameter on top. Below the parameters, the function object
to call is on the stack. Pops all function arguments, and the function
itself off the stack, and pushes the return value.
More information about the Python-ideas