[Python-ideas] New 3.x restriction on number of keyword arguments (original) (raw)
M.-A. Lemburg mal at egenix.com
Thu Oct 21 17:41:12 CEST 2010
- Previous message: [Python-ideas] New 3.x restriction on number of keyword arguments
- Next message: [Python-ideas] New 3.x restriction on number of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Georg Brandl wrote:
Am 21.10.2010 16:06, schrieb Benjamin Peterson:
Raymond Hettinger <raymond.hettinger at ...> writes:
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'm not sure why you think this is new. It's been true from at least 2.5 as far as I can see. You must be talking of a different restriction. This snippet works fine in 2.7, but raises a SyntaxError in 3.1: exec("def f(" + ", ".join("a%d" % i for i in range(1000)) + "): pass")
The AST code in 2.7 raises this error for function/method calls only. In 3.2, it also raises the error for function/method definitions.
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 ?
Note that it's not uncommon to have more than 255 possible function/method arguments in generated code, e.g. in database abstraction layers.
Thanks,
Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Oct 21 2010)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/
- Previous message: [Python-ideas] New 3.x restriction on number of keyword arguments
- Next message: [Python-ideas] New 3.x restriction on number of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]