Tim Peters <t...@python.org> added the comment:
"The 'aux' object" is simply the integer 1. The dict is irrelevant to the outcome, except that the dict owns one reference to 1. Do sys.getrefcount(1) all by itself and you'll see much the same. This isn't a bug, but neither is it a feature: it's undocumented, implementation-defined behavior. It so happens that CPython treats a number of small integers as singletons, creating only one object for each, shared by all contexts that use the integer. Here's from a fresh Python interactive session: >>> from sys import getrefcount as r >>> r(1) 94 >>> r(2) 76 >>> r(3) 27 >>> r(4) 49 >>> r(5) 23 >>> r(6) 11 >>> r(7) 13 >>> r(8) 35 >>> r(9) 13 Nothing about that is a bug, nor is anything about that defined behavior. It just reflects how many times these small integers happen to be referenced by all the under-the-covers stuff that happened to get imported by the time the interactive prompt was displayed. ---------- nosy: +tim.peters _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40451> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com