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."