Skip to content

Instantly share code, notes, and snippets.

@rongpenl
Created May 22, 2023 17:36
Show Gist options
  • Save rongpenl/03b8d654dad1a1e9bbfb64124a322fb9 to your computer and use it in GitHub Desktop.
Save rongpenl/03b8d654dad1a1e9bbfb64124a322fb9 to your computer and use it in GitHub Desktop.
Python integers are immutable.
"""
hollyandprosper.com
YouTube Channel: https://www.youtube.com/@hollyandprosper
Link to the original YouTube Short: https://youtu.be/Oo2g93efAeQ
"""
alpha = 'alpha'
# alpha[0] = 'A'
answer = 42
print(id(answer))
answer += 1
print(id(answer))
# Advantages of immutability
# potentially faster
# can be hashed
# safer for multithreading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment