Resource Of Instance Class

Asked By 10 points N/A Posted on -
qa-featured

How effective are Python resources (python, I think) in allocating a newly created instance of a class? I have a situation where I have to instantiate a node class millions of times to create a tree structure. Each of the node objects must be compact and contain only a few numbers and references to the parent and child nodes.

SHARE
Answered By 0 points N/A #318492

Resource Of Instance Class

qa-featured

In appearance, it’s very simple: methods, class variables and the class docstring are stored in the class (function documents are stored in the function). The instance variables are stored in the instance. The instance also refers to the class so that you can search for the methods. Generally, they are all stored in dictionaries (the __dict__). The short answer is: Python does not store any method in instances, but all instances must have a reference to the class.

Login/Register to Answer

Related Questions