On 2017-03-30 19:04, INADA Naoki wrote:
Maybe, this commit make this regression.
https://github.com/python/cpython/commit/4897300276d870f99459c82b937f0ac22450f0b6
Old:
minused = (so->used + other->used)*2 (L619)
New:
minused = so->used + other->used (L620)
minused = (minused > 50000) ? minused * 2 : minused * 4; (L293)
So size of small set is doubled.
$ /usr/bin/python3
Python 3.5.2+ (default, Sep 22 2016, 12:18:14)
[GCC 6.2.0 20160927] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
s = set(range(10))
sys.getsizeof(frozenset(s))
736
$ python3
Python 3.6.0 (default, Dec 30 2016, 20:49:54)
[GCC 6.2.0 20161005] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
s = set(range(10))
sys.getsizeof(frozenset(s))
1248
Copying a small set _might_ double its memory usage.
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> s = set(range(10))
>>> sys.getsizeof(s)
736
>>> sys.getsizeof(set(s))
736
>>>
>>> sys.getsizeof(set(set(s)))
736
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> s = set(range(10))
>>> sys.getsizeof(s)
736
>>> sys.getsizeof(set(s))
1248
>>>
>>> sys.getsizeof(set(set(s)))
1248
>>>
--
https://mail.python.org/mailman/listinfo/python-list