
On Thu, Oct 21, 2010 at 11:41 AM, M.-A. Lemburg <mal@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, CALL_FUNCTION(argc) 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. http://docs.python.org/dev/py3k/library/dis.html?highlight=opcode#opcode-CAL...