Small data pool ---- caching mechanism (resident mechanism)
==: determining whether the same content on both sides
It is: judgment based on the memory address is determined
Digital data pool small range -5 to 256
Block: a file, a function, a module, each row is a terminal block
Code blocks supported data types: digital: in the same code block. As long as the same content on the same memory address (-6 later not) multiply in the time range of -5 to 256. You can not use floating-point numbers (these are the results of cham) when doing multiplication
String: In the same block of code, as long as the same content on the same memory address. When multiplying the total length can not exceed 20. When Chinese multiplication, special symbols by 1 or 0
Boolean: within the same block. As long as the same content on the same memory value
Small pool data: number: the range of -5 to 256
String: In the same small data pool, as long as the same content on the same memory address. When multiplying the total length can not exceed 20. When Chinese multiplication, special symbols multiplied by zero. Letters, numbers, any length compliance mechanism resides.
A Boolean value: in the same small pool of data, as long as the same content on the same memory address
Small pool validation data must be verified in order from code block. Execution order: first rule execution code block, the data in the small rule execution - (resident Mechanism)
Resident mechanism of action: to save memory space, improve efficiency (reduce the destruction of open space and the space of time)
set
One of the types of data python
Collection ---- set: Keyword
Defined method: s = {1,2,3,4,}
Dictionary is a collection of no value.
Unordered, variable. Set of automatic de-duplication.
By: s = {} # Dictionary
s1 = set ({}) # empty set
s1.add () # add
s1.update () # iterations add
set () # iterations add
Delete: s1.remove (element) # delete
s1.clear () # Empty
s1.pop () # arbitrarily delete
Change: After the first cut plus
Charles: for loop
Other operations:
s2={1,23,9,4,5,7}
s3 = {1,2,3,4,5}
Difference-set - # print (s2-s3)
Intersection & # print (s2 & s3)
And set | #print (s2 | s3)
Anti intersection ^ # print (s2 ^ s3)
Subset, superset (superset)
Freeze collections: not changed. It can be used as a dictionary key.
frozenset({1,23,4,5})
Copy copy depth
Shallow copy
Interview will ask: assignment, a shallow copy and deep copy
After avoided
lst.copy (): shallow copy #lst [:]
The source is shallow copy is to open a frame basis, the common use of the same data. But is not the same framework and shallow copy of the metadata.
Shallow copy source data and comparison, if the source data elements change, the shallow copy the values of which fluctuates. If you add or change elements of the source data, and a shallow copy of the source data element will change or add together. If only a single element is assigned directly, the other party will not change.
Assignment: a plurality of variable to point to the same memory address is assigned.
"=" Is modified, .appedn is added. Variable data types and can be modified to add, modify immutable data type intelligence.
Deep copy
Import module copy import copy #
a=[1,2,3,[4,5],6]
b=copy.deepcopy(a)