Could anyone help me to understand why does a class consists of (4 + 1) references before even creating an object for it in Python?
from sys import getrefcount
from gc import get_referrers
class A:
… passget_referrers(A)
[<attribute ‘dict’ of ‘A’ objects>, <attribute ‘weakref’ of ‘A’ objects>, (<class ‘main.A’>, <class ‘object’>), {‘name’: ‘main’, ‘doc’: None, ‘package’: None, ‘loader’: <class ‘_frozen_importlib.BuiltinImporter’>, ‘spec’: None, ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘getrefcount’: , ‘get_referrers’: , ‘A’: <class ‘main.A’>}]getrefcount(A)
5
I am only aware that one reference is passed when I am calling get_referrers/getrefcount method.
Please bridge the gap.
Could anyone help me to understand why does a class consists of (4 + 1) references before even creating an object for it in Python?
Type your question above this line.
Course: https://www.educative.io/collection/10370001/6201068373409792
Lesson: https://www.educative.io/collection/page/10370001/6201068373409792/5682521335398400