Flattening lists

Stephen Hansen apt.shansen at gmail.com
Thu Feb 5 17:41:36 CET 2009


> Either list creation is somewhat
> costly, or "if var is None" is really cheap.

"if x is y" is extremely cheap, I believe. Unlike most comparisons
which are (relatively) expensive, that one is just comparing simple
object address. You can't override "is" so there's a whole series of
checks that don't have to get done. You don't have to go through the
richcompare machinery, check if there's a __ne__, etc, etc.

--S



More information about the Python-list mailing list