[Doc-SIG] Does the "is" operator only matter for mutable object?

Fred Drake fdrake at acm.org
Mon Mar 7 05:12:38 CET 2011


On Sun, Mar 6, 2011 at 8:29 PM, Laura Creighton <lac at openend.se> wrote:
> I figure that the fact that None is a singleton is not actually relevant
> to this.

It's important because Python promises that None is a singleton at the
language level, rather than the implementation level.  That's
different than using cached values of small integers, since that's a
runtime efficiency issue (and therefore implementation specific).

That's essential to the recommended practice of testing for None using
"is" rather than "=="; it's irrelevant to the general description of
"is".


  -Fred

--
Fred L. Drake, Jr.    <fdrake at acm.org>
"A storm broke loose in my mind."  --Albert Einstein


More information about the Doc-SIG mailing list