This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年08月26日 02:42 by andersk, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue12844_arbitrary_arguments.diff | Trundle, 2011年09月02日 22:00 | review | ||
| no-args-limit.patch | serhiy.storchaka, 2016年11月25日 09:27 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017年03月31日 16:36 | |
| Messages (11) | |||
|---|---|---|---|
| msg142995 - (view) | Author: Anders Kaseorg (andersk) * | Date: 2011年08月26日 02:42 | |
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: https://docs.djangoproject.com/en/1.3/topics/http/urls/#module-django.conf.urls.defaults 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 f(arg0, ..., arg999, k0=v0, ..., k999=v999) into f(*(arg0, ..., arg999), **{'k0': 'v0', ..., 'k999': 'v999'}) |
|||
| msg142996 - (view) | Author: Anders Kaseorg (andersk) * | Date: 2011年08月26日 02:56 | |
I guess the desugaring is slightly more complicated in the case where the original function call already used *args or **kwargs:
f(arg0, ..., arg999, *args, k0=v0, ..., k999=v999, **kwargs)
becomes something like
f(*((arg0, ..., arg999) + args),
**dict({'k0': 'v0', ..., 'k999': 'v999'}, **kwargs))
|
|||
| msg142998 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2011年08月26日 03:28 | |
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. |
|||
| msg143002 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2011年08月26日 07:42 | |
The approach looks fine to me. Would you like to work on a patch? |
|||
| msg143440 - (view) | Author: Andreas Stührk (Trundle) * | Date: 2011年09月02日 22:00 | |
Attached is a patch that removes the limit and that allows passing an arbitrary number of positional and keyword arguments. Lacks tests for now. |
|||
| msg143451 - (view) | Author: David Benjamin (davidben) | Date: 2011年09月03日 03:32 | |
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. |
|||
| msg281655 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年11月24日 21:33 | |
Since issue27213 the bytecode no longer have a limitation for numbers of positional or keyword arguments. |
|||
| msg281688 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年11月25日 09:27 | |
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. |
|||
| msg281836 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2016年11月27日 21:32 | |
Patch LGTM. |
|||
| msg281848 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年11月28日 08:52 | |
New changeset 5c1bb72c0f5d by Serhiy Storchaka in branch 'default': Issue #12844: More than 255 arguments can now be passed to a function. https://hg.python.org/cpython/rev/5c1bb72c0f5d |
|||
| msg281855 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年11月28日 10:25 | |
Thanks Brett. See issue18896 for supporting functions with more than 255 parameters. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:21 | admin | set | github: 57053 |
| 2017年03月31日 16:36:20 | dstufft | set | pull_requests: + pull_request943 |
| 2016年11月28日 10:25:17 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg281855 stage: commit review -> resolved |
| 2016年11月28日 08:52:21 | python-dev | set | nosy:
+ python-dev messages: + msg281848 |
| 2016年11月27日 21:32:20 | brett.cannon | set | assignee: serhiy.storchaka messages: + msg281836 stage: patch review -> commit review |
| 2016年11月25日 09:27:13 | serhiy.storchaka | set | files:
+ no-args-limit.patch stage: patch review messages: + msg281688 versions: + Python 3.7 |
| 2016年11月24日 21:33:19 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg281655 |
| 2011年09月08日 17:06:25 | sebastinas | set | nosy:
+ sebastinas |
| 2011年09月03日 03:32:07 | davidben | set | nosy:
+ davidben messages: + msg143451 |
| 2011年09月02日 22:00:37 | Trundle | set | files:
+ issue12844_arbitrary_arguments.diff nosy: + Trundle messages: + msg143440 keywords: + patch |
| 2011年08月30日 17:34:32 | brett.cannon | set | nosy:
+ brett.cannon |
| 2011年08月26日 07:42:24 | loewis | set | nosy:
+ loewis messages: + msg143002 |
| 2011年08月26日 03:28:33 | rhettinger | set | priority: normal -> low nosy: + rhettinger messages: + msg142998 |
| 2011年08月26日 02:56:52 | andersk | set | messages: + msg142996 |
| 2011年08月26日 02:42:57 | andersk | create | |