[Wonderful Python 3] Python Object Parsing

Source: Internet
Author: User

Wonderful Python objects
In short: Python is a language that can surprise you infinitely and is quite different.
Understanding Python object concepts is a prerequisite for understanding Python data storage. Python uses objects to store data and constructs values of any type to be objects.
1. Python object:
Python objects have three attributes:Id: each object has a unique id. You can view the id of an object through id.Type: the type of the object. It indicates the data type that the object can store and can be viewed through type.Value: the value of OSS data.For example:Python internal implementation mechanism: a = 1. Python first creates an integer object, sets the value of this integer object to 1, and finally assigns this object to variable. A = 2. Create a new integer object in Python, set the object value to 2, and assign the object to variable.Python memory management: each object has a reference counter. when an object is assigned a variable name, the reference timer + 1 is used. When a reference is destroyed, the reference counter-1 is used. When the reference counter is 0, that is, if all references do not exist, the system will destroy this object.
2. Variable names and objects:
Python stores data based on objects. The relationship between variable names and objects is different from that between C/C ++ variable names and memory addresses. In Python, the variable name cannot change the object value. Instead, the variable name points to the new object. In C/C ++, if the variable name is assigned a value again, the corresponding memory address is changed..In Python, a variable name can point to any type of object, and a variable name can be changed to point to a new data object of different types. In C/C ++, a variable name has its specific data type.
3. Python standard type:
The Python language provides standard data types, and data storage is based onObject Mechanism, The above object introduction can deepen our team's understanding of Python data.

  • Number
  • String
  • List
  • Tuples
  • Dictionary
These Python standard types will be introduced in the subsequent sections. Python's Object Storage Data mechanism: in essence, Python encapsulates the memory address. The advantage of this encapsulation is that Python can implement automatic memory management and other functions to reduce the burden on developers, the cost is that Python requires more space and performance consumption than C/C ++.


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.