Python_ class-to-instance attribute relationships

Source: Internet
Author: User
Knowledge of the object we know that the instance has only data properties in memory, which is exactly the data in the Init constructor, and does not include other data attributes in the class. The classes have both data properties in the Init constructor and data that are not in the Init constructor, as well as the function properties in the class.
Why design it like this? Because we can instantiate a different object through the class, if all the properties of the class are stored in the memory of the instance at this time, then all the function properties of the class will be stored in memory repeatedly, which will greatly waste the memory of the computer. All when the individual instances need to go to the class to take the corresponding function properties, so that the need to meet the function, but also save the memory space.
So, we can be sure that, with an instance, we can access all the properties in the class, but the class has different access to the instance's properties. A class has both a data property and a function property, whereas an instance has only data properties.

Python_ class-to-instance attribute relationships

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.