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年05月23日 14:24 by peter.fankhaenel, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17934 | merged | Zac Hatfield-Dodds, 2020年01月10日 12:13 | |
| Messages (4) | |||
|---|---|---|---|
| msg136644 - (view) | Author: Peter Fankhaenel (peter.fankhaenel) | Date: 2011年05月23日 14:24 | |
An OverflowError is emitted in case the return value of __len__ exceeds 2**31-1. The following code: class C (object): def __len__ (self): return self.l c = C() c.l = 2**31 len (c) # leads to an OverflowError in the last line. It works flawless for c.__len__ () |
|||
| msg136645 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2011年05月23日 14:27 | |
Yep, len() has to return something less than sys.maxsize. |
|||
| msg136646 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年05月23日 14:30 | |
len(obj) is implemented using PyObject_Size() which is stores the result into a Py_ssize_t, and so is limited to sys.maxsize (2**31-1 or 2**63-1). This implementation detail should be documented. |
|||
| msg359837 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2020年01月12日 09:04 | |
New changeset d7c7adde003ddca5cbe4fc47cf09464ab95a066e by Victor Stinner (Zac Hatfield-Dodds) in branch 'master': bpo-12159: Document sys.maxsize limit in len() function reference (GH-17934) https://github.com/python/cpython/commit/d7c7adde003ddca5cbe4fc47cf09464ab95a066e |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:17 | admin | set | github: 56368 |
| 2020年01月12日 09:04:36 | vstinner | set | messages: + msg359837 |
| 2020年01月10日 12:13:54 | Zac Hatfield-Dodds | set | pull_requests: + pull_request17339 |
| 2011年05月23日 14:30:42 | vstinner | set | nosy:
+ vstinner messages: + msg136646 |
| 2011年05月23日 14:27:30 | benjamin.peterson | set | status: open -> closed nosy: + benjamin.peterson messages: + msg136645 resolution: works for me |
| 2011年05月23日 14:24:02 | peter.fankhaenel | create | |