Skip to content

Instantly share code, notes, and snippets.

@pmbrull
Created April 10, 2022 17:12
Show Gist options
  • Save pmbrull/542bf7a4a64217c79b2dde12a3800d70 to your computer and use it in GitHub Desktop.
Save pmbrull/542bf7a4a64217c79b2dde12a3800d70 to your computer and use it in GitHub Desktop.
What the hash 2
my_list = [1, 2, 3]
hex(id(my_list)) # 0x104d7a580
my_list.append(4) # mutate the list
hex(id(my_list)) # 0x104d7a580 -> still the same object.
my_string = "Levy"
hex(id(my_string)) # 0x104dec760
my_string += " the cat"
hex(id(my_string)) # 0x104e01530 -> new object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment