When I run this code
def outer():
xs = {1,2,3,4,5,6,7,8,9,10,11}
print(xs)
print(id(xs))
xid = id(xs)
def inner():
xs = {1,2,3,4}
print(xs)
print(id(xs))
yid = id(xs)
print(xid == yid)
return inner
fn = outer()
fn()
xid and yid value is the same in intellij,
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
140317084319328
{1, 2, 3, 4}
140317084319328
True
but when i run in a terminal
>>> fn = outer()
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
140343083023728
>>> fn()
{1, 2, 3, 4}
140343082597504
they are different. I am expecting that yid should be different because there is no interning happening for a list. Can anyone explain this behaviour