Small data pool
What is a small data pool?
- Python is a small data pool to increase the efficiency of one embodiment, a fixed data type using the same memory address
- Support: str, int, bool
Small data pool is doing?
- id () View the memory address space of open space acquisition An address
- Digital support small data pool range: -5 to 256
- is: determining whether the same memory address two
- ==: both sides of the equal sign is determined whether the value of the wanted copper
String
- Characters multiply when the total length can not exceed 20, to camp
- Own definition string length is not limited, but must be an integral alphanumeric string underlined to camp
- Special characters (except Chinese) defined a time, to camp
- * 1 string, in fact assigned
Block
- A file, a module, a function, a class, each row is a terminal block, in the manner Python to store dictionaries
- Digital, all reside
- String
- Multiplying the total length of not more than 20
- Custom reside
- Multiplier of 1 is assigned time
- Python3.7 multiplication when the total length of not more than 4096
Forced resident
from sys import intern
a = intern(@@@@*20)
b = intern(@@@@*20)
print (a is b) # themselves residing
set
What is a collection?
Dictionary is a collection of no value, follow: unique, unordered, the elements required can hash (immutable)
Collection are variable and disorderly
The main role is to re
increase
- s.update ( "3456") # iterations add
- s.add()
delete
- s.pop (): random delete # observed that, according to its own law a little, but not say
- s.remove (): Delete by elements
- s.clear (): Empty
- del s: delete the entire collection
modify
- Deleted plus is not changed
Other operations
# print(s1 - s2) #差集 # print(s1 | s2) #并集 (合集) # print(s1 & s2) #交集 # print(s1 ^ s2) #对称差集 -- 反交集 # print(s1 > s2) # 超集 -- 父集 # print(s1 < s2) # 子集 # 冻结集合(可变 转换成 不可变) -- 更不常用 # f_s = frozenset({1,2,3,4,5}) # # dic = {f_s:"1"} # # print(dic)
Copy depth
Copies of the depth of the law:
Assignment: two variables in the same space is
shallow copy: Review immutable data types, does not change, modify the variable data type, change
deep copy: not modified variations