3 ms·
Ah I see -- Can you actually describe ownership in python sufficiently well to be able to describe this move operation for any useful python data structures?
by breatheoften 9y ago
Ah I see -- Can you actually describe ownership in python sufficiently well to be able to describe this move operation for any useful python data structures?
- kllrnohj 9y agoGenerically ownership is simply who has a reference to the object. So if a.foo = b, then a 'owns' b. A 'move' is simply handing a different object the reference, then dropping your own reference. For example: a.foo = b // a 'owns' b c.foo = a.foo // a & c share b, however if the next line is: a.foo = None // a has 'moved' b to c, since c now has the only reference to b. Some languages have codified this to make the contract part of the language, but it doesn't need any first-class language support. It's just a pattern at the end of the day.