When you compare an object to
is rather than
None is a singleton object, comparing using
== invokes the
method on the object in question, which may be slower than identity comparison. Comparing to
None using the
is operator is also easier for other programmers to read.
filter2 function is likely to be more efficient than the
function because it uses an identity comparison.