[issue39109] [C-API] PyUnicode_FromString
STINNER Victor
report at bugs.python.org
Fri Dec 20 08:07:41 EST 2019
STINNER Victor <vstinner at python.org> added the comment:
> I think the ob_refcnt Field should be 1 in both cases. Or why is the refcnt here so high?
Python has singletons for short strings: empty string and 1-character latin1 characters (unicode range [U+0000; U+00FF]).
Examples:
>>> sys.getrefcount("")
103
>>> sys.getrefcount("a")
11
It's not a bug, but an optimization to reduce the memory footprint ;-)
----------
nosy: +vstinner
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39109>
_______________________________________
More information about the Python-bugs-list
mailing list