* Variable without prior declaration
* variable does not need to specify type
* Programmer does not have a relationship with memory management
* Variable name will be recycled
* Del can release resources directly
1.python uses a reference call instead of a value call, and the recycling algorithm he uses is a reference counting algorithm, and I'll give you two examples below
x = 4y = 4aList = [1, 2, 3]blist = [1, 2, 3]print (x = y) print (x = = y) print (alist is blist) print (alist = = blist) A = 3.2B = 3.2print (A is B) print (A = = b)
Output Result:
True
True
False
True
True
True
From the output analysis we come to the following conclusion,
1) If they are purely shaped, floating-point, String type These, the return is the same result, because they are the same value, and the reference address is the same
2) If it is a list, a tuple, a dictionary, and so on, because two objects store different addresses, even if the values are the same, but if you compare the reference address, return false
2. Through del, you can delete objects
Then the above code:
x = 4y = 4print (x is y) print (x = = y) alist = [1, 2, 3]blist = [1, 2, 3]print (Alist is blist) print (alist = blist) A = 3.2b = 3.2print (A is B) print (A = = b) del aa
Output Result:
True
True
False
True
True
True
Traceback (most recent):
File "D:\myWorkSpace\CRUDFile\com\ray\test\CRUDFile.py", line +, in <module>
A
Nameerror:name ' A ' is not defined
An error message appears, and a variable is not defined because we are releasing a by Del
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 Basic python-3.5 Memory management