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 <rep...@bugs.python.org> <http://bugs.python.org/issue30040> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com