[issue30040] new empty dict can be more small
INADA Naoki
report at bugs.python.org
Tue Apr 11 05:39:20 EDT 2017
New submission from INADA Naoki:
dict.clear() make the dict to empty key-sharing dict to reduce it's size.
New dict can use same technique.
$ ./python.default
Python 3.7.0a0 (heads/master:6dfcc81, Apr 10 2017, 19:55:52)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> d = {}
>>> sys.getsizeof(d)
240
>>> d.clear()
>>> sys.getsizeof(d)
72
$ ./python.patched
Python 3.7.0a0 (heads/master-dirty:6dfcc81, Apr 11 2017, 18:11:02)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getsizeof({})
72
----------
messages: 291470
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: new empty dict can be more small
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30040>
_______________________________________
More information about the Python-bugs-list
mailing list