[Python-ideas] New 3.x restriction on number of keyword arguments

Nick Coghlan ncoghlan at gmail.com
Sat Sep 18 09:28:42 CEST 2010

On Sat, Sep 18, 2010 at 7:11 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Fri, 17 Sep 2010 13:00:08 -0700
> Raymond Hettinger
> <raymond.hettinger at gmail.com> wrote:
>> One of the use cases for named tuples is to have them be automatically created from a SQL
>> query or CSV header.  Sometimes (but not often), those can have a huge number of columns.  In
>> Python 2.x, it worked just fine -- we had a test for a named tuple with 5000 fields.  In
>> Python 3.x, there is a SyntaxError when there are more than 255 fields.
> I don't understand your explanation. You can't pass a namedtuple using
> the **kw convention:

But you do need to *initialise* the named tuple after you create it.
If it's a big tuple, then all of those field values need to be passed
in either as positional arguments or as keyword arguments. A
restriction to 255 parameters means that named tuples with more than
255 fields become a lot less useful.

Merging the parameter count into the opcode as an optimisation when
the number of parameters is < 256 is fine. *Disallowing* parameter
counts >= 255 is not.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list