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 2013年08月31日 18:05 by valorien, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| no-params-limit.patch | serhiy.storchaka, 2016年11月28日 10:22 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017年03月31日 16:36 | |
| Messages (8) | |||
|---|---|---|---|
| msg196660 - (view) | Author: Alori (valorien) | Date: 2013年08月31日 18:05 | |
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. Is there a way to remove this restriction? Why not set a much higher limit? Also see: http://grokbase.com/t/python/python-ideas/109hbv63sv/new-3-x-restriction-on-number-of-keyword-arguments#responses_tab_top http://stackoverflow.com/questions/18550270/any-way-to-bypass-namedtuple-255-arguments-limitation |
|||
| msg196664 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2013年08月31日 18:49 | |
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. |
|||
| msg196667 - (view) | Author: Alori (valorien) | Date: 2013年08月31日 19:33 | |
@pitrou: Thank you for your answer. I agree they should not replace databases or files, but I think 255 is just way too lightweight. It feels unnatural to have this limitation for no specific reason. 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. |
|||
| msg196704 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2013年09月01日 05:02 | |
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. |
|||
| msg281854 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年11月28日 10:22 | |
Currently it is not possible to declare a Python function with more than 255 parameters. There were two historical causes of this: 1. Opcodes MAKE_FUNCTION and MAKE_CLOSURE packed the number of default values for positional and keyword parameters in the opcode argument as 8-bit numbers. 2. co_cell2arg was of type "unsigned char *". It's mapped a cell index to an argument index and didn't support arguments with index > 254. The first limitation is disappeared in 3.6 after changing the format of MAKE_FUNCTION (issue27095). Proposed patch gets rid of the second cause by changing the type of co_cell2arg and removes explicit check in the compiler. |
|||
| msg283242 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2016年12月15日 05:19 | |
Thanks. The patch looks good. |
|||
| msg283419 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年12月16日 17:19 | |
New changeset 7454ca88aacb by Serhiy Storchaka in branch 'default': Issue #18896: Python function can now have more than 255 parameters. https://hg.python.org/cpython/rev/7454ca88aacb |
|||
| msg283420 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年12月16日 17:22 | |
Thank you Raymond for your review. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:50 | admin | set | github: 63096 |
| 2017年03月31日 16:36:34 | dstufft | set | pull_requests: + pull_request1075 |
| 2016年12月16日 17:22:24 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg283420 stage: patch review -> resolved |
| 2016年12月16日 17:19:22 | python-dev | set | nosy:
+ python-dev messages: + msg283419 |
| 2016年12月15日 05:19:41 | rhettinger | set | messages: + msg283242 |
| 2016年12月14日 20:30:50 | serhiy.storchaka | set | assignee: serhiy.storchaka |
| 2016年11月28日 10:22:52 | serhiy.storchaka | set | files:
+ no-params-limit.patch components: + Interpreter Core versions: + Python 3.7, - Python 3.4 keywords: + patch nosy: + serhiy.storchaka messages: + msg281854 stage: patch review |
| 2013年09月07日 05:58:52 | terry.reedy | set | versions: + Python 3.4, - Python 3.3 |
| 2013年09月01日 05:02:31 | rhettinger | set | messages: + msg196704 |
| 2013年09月01日 04:07:14 | r.david.murray | set | nosy:
+ r.david.murray |
| 2013年08月31日 19:33:38 | valorien | set | messages: + msg196667 |
| 2013年08月31日 18:49:56 | pitrou | set | nosy:
+ rhettinger, pitrou messages: + msg196664 |
| 2013年08月31日 18:47:20 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2013年08月31日 18:05:10 | valorien | create | |