== so sánh giá trị (gọi __eq__). is so sánh identity — hai biến có trỏ đến cùng object trong memory không.
- Lưu ý: CPython cache integers nhỏ (-5 đến 256) và string interning —
x = 256; y = 256; x is ycó thể làTruenhưngx = 257; y = 257; x is ycó thể làFalse. - Chỉ dùng
isđể so sánh vớiNone,True,False.
== compares value (calls __eq__). is compares identity — whether both variables point to the same object in memory.
Pitfall: CPython caches small integers (-5 to 256) and interns strings — this makes is behave unexpectedly.