# Ptyhon 中使用 is None 而不是 ==None 问题

is比较在两个对象是否相同时使用（即通过比较在内存中的标识符（id(obj)）），而==通过调用__eq__()方法比较两个的值是否相等。

is is generally preferred when comparing arbitrary objects to singletons like None because it is faster and more predictable. is always compares by object identity, whereas what == will do depends on the exact type of the operands and even on their ordering.

This recommendation is supported by PEP 8, which explicitly states that “comparisons to singletons like None should always be done with is or is not, never the equality operators.”

PEP 8 支持此建议，该声明明确指出“与单例的比较（如None，应该始终使用isnot进行比较，永远不要使用相等运算符进行比较）”。