[issue45953] Statically allocate interpreter states as much as possible.

Julien Palard report at bugs.python.org
Tue Mar 29 03:04:09 EDT 2022


Julien Palard <julien+python at palard.fr> added the comment:

> Since you seem to be challenging the value of 999999999, my question to you is, why do you care what the refcount of 1 is?

Yesterday I was teaching Python, and we were speaking of integer immutability, names being "labels to objects" and so on, and I was showing the memory layout of all of this by hand on a whiteboard while "prooving" my drawings using an interpreter.

While doing so came a question like "So, many modules can use the object int(1)?" So I answered yes, told that I expected many reuse of 1, and went importing sys.getrefcount to show them.

And boom, it printed 1000000209 so I bugged for a few seconds, the value was obviously not the real refcount, and was also obviously bumped by a constant like 100000000, so I went inspecting why and found this commit.

I have nothing against keeping 999999999, but in the other hand it could surprise other people, maybe we should at least document it near sys.getrefcount.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45953>
_______________________________________


More information about the Python-bugs-list mailing list