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
Support more than 255 arguments #57053
Comments
This feels like an arbitrary restriction (obvious sequences have been replaced with ‘…’ to save space in this report): >>> zip([0], [1], [2], …, [1999])
File "<stdin>", line 1
SyntaxError: more than 255 arguments especially when this works: >>> zip(*[[0], [1], [2], …, [1999]])
[(0, 1, 2, …, 1999)] Apparently that limit bites some people: The bytecode format doesn’t support directly calling a function with more than 255 arguments. But, it should still be pretty easy to compile such function calls by desugaring |
I guess the desugaring is slightly more complicated in the case where the original function call already used *args or **kwargs: |
On python-dev a few month ago, Guido agreed with you that this is an arbitrary limitation that should be removed at some point. In particular, he worried that programmatically generated code would tend to run into this limitation. |
The approach looks fine to me. Would you like to work on a patch? |
Attached is a patch that removes the limit and that allows passing an arbitrary number of positional and keyword arguments. Lacks tests for now. |
I don't think that patch works. Consider a dict subclass which has overridden update. Or perhaps a list subclass which has overridden addition. It would be quite poor if Python's behavior here w.r.t. which overrides are followed switched as you added more arguments. |
Since bpo-27213 the bytecode no longer have a limitation for numbers of positional or keyword arguments. |
No longer changes to Python/compile.c are needed. Here is a patch against 3.7 that just removes the limit of the number of passed arguments in Python/ast.c and adds tests. But still there is a limitation on the number of function parameters. It is caused by using a bytes objects as co_cell2arg. |
Patch LGTM. |
New changeset 5c1bb72c0f5d by Serhiy Storchaka in branch 'default': |
Thanks Brett. See bpo-18896 for supporting functions with more than 255 parameters. |
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: