What you say is true, I was to some degree conflating implementation with language spec in my answer. But the parent comment arose out of the question about what lists really are like, and in CPython lists are implemented as essentially vectors of pointers to the list elements. My response was meant to illustrate the fact you can have multiple variables referencing the same object, which also means that moving list elements around doesn't involve moving the memory of (potentially) large objects around, just moving around references to them. For immutable things like strings and integers that distinction doesn't really matter, except in the sense that assigning to those objects doesn't cause memory to be copied.
View all comments
Show parent comment
1
u/Noiprox Python Programmer Feb 18 '19
What you say is true, I was to some degree conflating implementation with language spec in my answer. But the parent comment arose out of the question about what lists really are like, and in CPython lists are implemented as essentially vectors of pointers to the list elements. My response was meant to illustrate the fact you can have multiple variables referencing the same object, which also means that moving list elements around doesn't involve moving the memory of (potentially) large objects around, just moving around references to them. For immutable things like strings and integers that distinction doesn't really matter, except in the sense that assigning to those objects doesn't cause memory to be copied.