New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove namedtuple 255 arguments restriction #63096
Comments
Named tuples offer a useful mix of features from both dict and tuple data structures. However, unlike dictionaries and tuples, Named tuples are only allowed to hold up to 255 items. This behavior seems inconsistent and un-Pythonic. http://stackoverflow.com/questions/18550270/any-way-to-bypass-namedtuple-255-arguments-limitation |
I'll let Raymond give his answer here, but namedtuples are meant as lightweight structures or records (if you know C, think "struct"), not arbitrary containers. |
@pitrou: Recently, I've seen a lot of solutions that emulate the namedtuple functionality with some classes in order to workaround this issue, but they all feel "forced" and require some unsavory hacks. I think namedtuple is one the most useful structures in the language, and like tuples and dicts, shouldn't be limited by design. |
I would like to see the limitation removed. IIRC, Guido has said the same. That said, the limitation isn't due to anything in the namedtuple code. Instead, it is due to a CPython bytecode implementation detail that limits all function/method definitions to no more than 255 arguments. |
Currently it is not possible to declare a Python function with more than 255 parameters. There were two historical causes of this:
The first limitation is disappeared in 3.6 after changing the format of MAKE_FUNCTION (bpo-27095). Proposed patch gets rid of the second cause by changing the type of co_cell2arg and removes explicit check in the compiler. |
Thanks. The patch looks good. |
New changeset 7454ca88aacb by Serhiy Storchaka in branch 'default': |
Thank you Raymond for your review. |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: