Python: Mutable vs Immutable

Mutable objects

  • list
  • set
  • dict
  • byte array

Immutable Objects

  • int
  • float
  • str
  • tuple
  • etc
a & b have the same id
The state diagram of references of a & b
check whether two names have the same value
check whether two names refer to the same object

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sergii Garkusha

Sergii Garkusha

142 Followers

Hacker. 500 Startups Alumni. Envato Elite. School of AI Dean. Runner. Ukrainian. I write about software, AI & life. SF 🌁 https://cu7io.us