= true is true and reference the same object same values same objects the first technique herethe =operatortests whether the two referenced objects have the same valuesthis is the method almost always used for equality checks in python the second methodthe is operatorinstead tests for object identity--it returns true only if both names point to the exact same objectso it is much stronger form of equality testing and is rarely applied in most programs reallyis simply compares the pointers that implement referencesand it serves as way to detect shared references in your code if needed it returns false if the names point to equivalent but different objectsas is the case when we run two different literal expressionsl [ [ = true is false and reference different objects same values different objects nowwatch what happens when we perform the same operations on small numbersx = true is true should be two different objects same object anyhowcaching at workin this interactionx and should be =(same value)but not is (same objectbecause we ran two different literal expressions ( because small integers and strings are cached and reusedthoughis tells us they reference the same single object in factif you really want to look under the hoodyou can always ask python how many references there are to an objectthe getrefcount function in the standard sys module returns the object' reference count when ask about the integer object in the idle guifor instanceit reports reuses of this same object (most of which are in idle' system codenot minethough this returns outside idle so python must be hoarding as well)import sys sys getrefcount( pointers to this shared piece of memory this object caching and reuse is irrelevant to your code (unless you run the is check!because you cannot change immutable numbers or strings in placeit doesn' matter how many references there are to the same object--every reference will always see the the dynamic typing interlude