Skip to content

Instantly share code, notes, and snippets.

@GRAYgoose124
Created January 26, 2017 03:53
Show Gist options
  • Select an option

  • Save GRAYgoose124/baba6e559fceb6f2ae7f50c228c0e8dc to your computer and use it in GitHub Desktop.

Select an option

Save GRAYgoose124/baba6e559fceb6f2ae7f50c228c0e8dc to your computer and use it in GitHub Desktop.
>>> a = "my string"
>>> b = "my string"
>>> id(a)
7570480
>>> id(b)
7574128
>>> id("my string")
7574192
>>> id("my string")
7574192
>>> del(a)
>>> del(b)
>>> id("my string")
7574320
>>> a = "my string"; b = "my string"
>>> id(a)
11175280
>>> id(b)
11175280
>>> id("mystring")
18121776
>>> id("fucking")
18113456
>>> id("mystring")
18121776
>>> id("fucking")
18113456
>>> a = "my string"
>>> b = "my string"
>>> a is b
False
>>> def f():
... a = "my string"
... b = "my string"
... return a is b
...
>>> f()
True
Counterpoint:
>>> a = "mystring"
>>> b = "mystring"
>>> a is b
True
>>> id(a), id(b)
(4486743552, 4486743552)
>>> c = "my string"
>>> d = "my string"
>>> c is d
False
>>> id(c), id(d)
(4486743600, 4486743024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment