In what structure is a Python object stored in memory?

前端 未结 2 836
悲&欢浪女
悲&欢浪女 2020-12-31 13:55

Say I have a class A:

class A(object):
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return self.x

And I us

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 14:35

    in the case of a new class instance getsizeof() return the size of a reference to PyObject which is returned by the C function PyInstance_New()

    if you want a list of all the object size check this.

提交回复
热议问题