ShopperCove
Menu
All writingBlogTopicsCategoriesAboutRSS
Blog
Categories
Observability & SRE62All categories
Topics
sre111localhost lab102performance70python58javascript47bundle size36benchmarking35node.js35web development21typescript19benchmark16content creation15All topics
About
Loading article…

ShopperCove

Hands-on notes on developer tools, written after the tool has actually been run.

All writingBlogCategoriesTopicsAboutPrivacyRSS

© 2026 ShopperCove

On this page

  1. Example
  2. Use is for None
  3. Pitfall: small ints and strings
  4. Sources
  1. Blog

What Is the Difference Between is and == in Python?

Equality versus identity, and why `is None` is the one place `is` is standard.

Aditya Challa·12 October 2026·1 min read

Summary

Disclosure

This post contains affiliate links. If you buy through them, I may earn a commission at no extra cost to you. I only make firsthand claims about products I have actually used.

On this page
  1. Example
  2. Use is for None
  3. Pitfall: small ints and strings
  4. Sources

In Python, == checks whether two objects have equal values, while is checks whether they are the exact same object in memory. Use == for comparing values and is mainly for singletons such as None.

Example

a = [1, 2]
b = [1, 2]
a == b   # True: same contents
a is b   # False: different objects
c = a
c is a   # True

Use is for None

PEP 8 says comparisons to singletons like None should use is or is not, never the equality operators.

Pitfall: small ints and strings

x is 256 may appear to work because CPython caches some objects, but this is an implementation detail. Python 3.8+ warns with a SyntaxWarning when you use is with a literal.

Related: /blog/how-to-check-if-a-file-exists-in-python

Related: /blog/what-does-if-name-main-do-in-python

Sources

  • 01docs.python.org/3/reference/expressions.html
  • 02peps.python.org/pep-0008/
pythonoperatorsobject identityequality comparisonmemorynonepep 8

Lab evidence

What I found running this

Facts in this draft were checked on 12 Oct 2026 against the primary sources listed in the body (official docs, release schedules or Google/YouTube help pages). No benchmarks or timings were run, so the post makes no performance or measurement claims; dates are quoted as published by the maintainers, and any estimate is labelled as such.

Explore the product

Freelancers and devs who want to turn coding skills into paid site builds

Build ready-made client websites faster

Check out Ready Client Sites

Notes when a lab post goes up

Occasional email for new hands-on reviews. No sequence and no sponsors.

Explore the product

Freelancers and devs who want to turn coding skills into paid site builds

Build ready-made client websites faster

Check out Ready Client Sites

Keep reading

  • What Does yield Do in Python? Generators Explained

    Generators, lazily: what yield actually does to a function.

    Summary12 Oct 20261 min read

  • What Is the Walrus Operator (:=) in Python? Examples

    Assignment expressions, explained with the examples that actually help.

    Summary12 Oct 20261 min read

  • When Does Django 5.2 LTS End? Support Until April 2028

    The official support dates for Django's current long-term support release.

    Summary12 Oct 20261 min read