[New-bugs-announce] [issue26314] interned strings are stored in a dict, a set would use less memory

Gregory P. Smith report at bugs.python.org
Mon Feb 8 15:42:46 EST 2016


New submission from Gregory P. Smith:

The implementation of string interning uses a dict [1].  It would consume less memory and be a bit simpler if it used a set.

Identifier strings in a program are interned.  If you have a large program with a lot of code, this makes for a large dictionary.

Experimenting with changing this to use a set on 2.7 found ~22k savings on an interactive interpreter startup.  Measuring it on a huge application showed a few hundred k saved.

[1]: https://hg.python.org/cpython/file/3.5/Objects/unicodeobject.c#l1579

----------
messages: 259885
nosy: gregory.p.smith, nnorwitz
priority: low
severity: normal
stage: needs patch
status: open
title: interned strings are stored in a dict, a set would use less memory
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26314>
_______________________________________


More information about the New-bugs-announce mailing list