[issue34100] Same constants in tuples are not merged while compile()

INADA Naoki report at bugs.python.org
Fri Jul 20 04:34:13 EDT 2018


INADA Naoki <songofacandy at gmail.com> added the comment:

This is another memory overhead comparison.
It seems merging constants reduces 2~3% memory usage.

import sys, django, flask
sys._debugmallocstats()

### master branch

class   size   num pools   blocks in use  avail blocks
-----   ----   ---------   -------------  ------------
    0      8           1             312           194
    1     16           1             135           118
    2     24           2             198           138
    3     32          22            2690            82
    4     40          62            6214            48
    5     48         149           12465            51
    6     56         254           18260            28
    7     64         354           22300             2
    8     72         208           11589            59
    9     80         124            6173            27
   10     88          59            2708             6
...
# bytes in allocated blocks        =            9,261,952


### merge-const branch

class   size   num pools   blocks in use  avail blocks
-----   ----   ---------   -------------  ------------
    0      8           1             312           194
    1     16           1             135           118
    2     24           1             161             7
    3     32          22            2657           115
    4     40          62            6202            60
    5     48         102            8501            67
    6     56         235           16879            41
    7     64         346           21751            47
    8     72         204           11387            37
    9     80         122            6083            17
   10     88          58            2656            12
...
# bytes in allocated blocks        =            8,919,824

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34100>
_______________________________________


More information about the Python-bugs-list mailing list