Back to search

Mutable vs immutable objects

Mutable objects can change in place; immutable objects require a new object for a changed value.

Python Easy Theory

Mutable vs immutable objects

Mutable objects can change in place; immutable objects require a new object for a changed value.

  • List and dict are mutable
  • str and tuple are immutable
  • Matters for side effects and hashing

Mutable vs immutable objects