[issue12414] getsizeof() on code objects is wrong

Raymond Hettinger report at bugs.python.org
Sun Mar 26 12:02:43 EDT 2017


Raymond Hettinger added the comment:

Not including the Python accessible referred-to objects is consistent with how sys.getsizeof() works elsewhere (i.e. for object instances, the size of __dict__ is not included).

    >>> import sys
    >>> class A:
            pass

    >>> a = A()
    >>> sys.getsizeof(a)
    56
    >>> sys.getsizeof(a.__dict__)
    112

The result is easily misleading but this seems to have been an early design decision about the semanatics __sizeof__.

----------
nosy: +pitrou

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


More information about the Python-bugs-list mailing list