[issue28509] dict.update allocates too much

INADA Naoki report at bugs.python.org
Tue Oct 25 15:05:25 EDT 2016


INADA Naoki added the comment:

script:
import sys

for i in range(25):
    a = {}
    b = {j: j for j in range(i)}
    a.update(b)
    print(i, sys.getsizeof(a))

before:
0 256
1 256
2 256
3 256
4 256
5 256
6 384
7 384
8 664
9 664
10 664
11 664
12 664
13 664
14 664
15 664
16 1200
17 1200
18 1200
19 1200
20 1200
21 1200
22 1200
23 1200
24 1200

patched:
0 256
1 256
2 256
3 256
4 256
5 256
6 384
7 384
8 384
9 384
10 384
11 664
12 664
13 664
14 664
15 664
16 664
17 664
18 664
19 664
20 664
21 664
22 1200
23 1200
24 1200

----------
keywords: +patch
Added file: http://bugs.python.org/file45223/28509-smaller-update.patch

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


More information about the Python-bugs-list mailing list