On Sat, Sep 18, 2010 at 7:11 AM, Antoine Pitrou firstname.lastname@example.org wrote:
On Fri, 17 Sep 2010 13:00:08 -0700 Raymond Hettinger email@example.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.