如题, python 内部对不可变类型不可变的原理?? 大佬们, 求指教
s1 = str.__new__(str, 's1')
s2 = str.__new__(str, 's1')
print(s1 is s2)
just return cached reference in new method, for other methods, return new object
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答987 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
不可变类型(immutable):
改变了变量的值 == 新建了一个对象,而对于相同的值的对象,在内存中则只有一个对象(一个地址), python的id() 方法让你明白