Lec15-Mutability
Contents
Mutability
date
Obj in Python
String
|
|
ASCII
和表格对应
0x41 –> row 4, col 1 😮
|
|
Mutation operations
Mutable objects
- List
- Dictionary
- Set?
|
|
赋值的时候,如果是可变对象,则会影响到原对象,如果是不可变对象,则会创建新的对象。 😮
Immutable objects
- Tuple
- String
- Number
Immutable objects are hashable, which means that they can be used as keys in dictionaries and as elements in sets.
An immutable object can be changed if it contains a mutable object.
|
|
Mutation
same or change?
-
Identity:
a is b
is
in Python -
Equality:
a == b
==
in Python
|
|
frame里面引用传递更加常见 🤔