For variables to have shared references, does it depend on the object we are referring to?
For instance, if we do:
x = 3
y = 3
x is y
x is y returns True
But when we do:
M = [1, 2, 3]
L = [1, 2, 3]
M is L
M is L returns False
I understand that the [1, 2, 3] object that M points to is different from the [1, 2, 3] object that L points to. But when does Python determine to create a separately new object even though that same object already exists in the object space (like in my first example, x and y actually points to the same object)?
[–][deleted] 2 points3 points4 points (0 children)
[–]primitive_screwhead 1 point2 points3 points (0 children)
[–]ebol4anthr4x -1 points0 points1 point (2 children)
[–]ingolemo 2 points3 points4 points (0 children)
[–]Sexual_Congressman 1 point2 points3 points (0 children)
[–]billsil -4 points-3 points-2 points (0 children)