Issue 4800: little inaccuracy in Py_ssize_t explanation (original) (raw)

Issue4800

Created on 2009-01-01 10:32 by exe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg78695 - (view) Author: Kandalintsev Alexandre (exe) Date: 2009-01-01 10:32
Documentation says that ======== There’s no chance that the reference count can overflow; at least as many bits are used to hold the reference count as there are distinct memory locations in virtual memory (assuming sizeof(Py_ssize_t) >= sizeof(void*)). Thus, the reference count increment is a simple operation. ======== But Py_ssize_t is a signed type so in case of sizeof(Py_ssize_t) == sizeof (void*)) it can only reference a half of memmory :). But because any python object consumes much more than 2bytes this is not a problem.
msg78835 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-02 16:34
I think the documentation is correct as it stands; the question is what a "distinct memory location" is. Wrt. reference count, this surely refers to pointers; each pointer is at least 4 bytes, and pointers are four-aligned. So for N bits address space, there can be at most 2**(N-2) pointers.
History
Date User Action Args
2022-04-11 14:56:43 admin set github: 49050
2009-01-02 16:34:08 loewis set status: open -> closednosy: + loewisresolution: wont fixmessages: +
2009-01-01 10:32:31 exe create