In Python everything is an object, each object has three attributes, (ID) identity, which is the address in memory, type, is int, character, dictionary (DIC), list, etc., value,
For example, a = 12 is an integer with 12, the value is 12, a space is created in the memory space (the space is represented by an address, that is, the ID), when the object is created, if the object's
The value can be changed, then called a mutable object (mutable), and if the value cannot be changed, it is called an immutable object (inmutable), and if an object contains references to other objects, it is called
As a container or a collection. For example, I created a dictionary type object and was b reference B = list () I created a dictionary type object and was c = c = dic () at this point B applies the dictionary type
Object b[' a '] = C then b at this point is a collection.
#is用来比较两个对象的id是不是相同的, test your identity.
Ifis B: return and
#比较值
If a = = B:
Return a==
B
#比较类型
If Type (a) = = Type (b):
return type is the same
reference counting and garbage collection, all objects have reference counts. A= 22#creates an object with a value of 22 and is referenced by aB=a#the reference count for object 22 increasesc =[]c.append (b)#increased reference count for object 22actions to reduce reference countsdelA#Reduce reference countB = 56#Reduce reference countC[0] =33#Reduce reference countGet reference count>>>a = 22>>>ImportSYS>>>Sys.getrefcount (a)7In most cases, the reference count will be much more than we thought because the immutable objects (short strings and small values) are cached, and Pyth will share objects in different parts of the program to conserve memory
Not finished!
Objects in Python