[Tutor] python memory management

Random832 random832 at fastmail.com
Sat Sep 3 05:51:05 EDT 2016


On Fri, Sep 2, 2016, at 23:25, monikajg at netzero.net wrote:
> 
> By:
> "reference cycles: if one object has a reference to another, and 
> that second object also has a reference to the first, that's a cycle."
> 
> Is this what you mean? 
> a = 5
> b = a
> a = b
> 
> I just want to make sure I understand.
> Thank you very much for your explanation. 
> Monika

No, an object that holds reference to other objects is something like a
list, tuple, dict.

e.g. if you had:
a = []
b = [a]
a.append(b)

you've got two lists, and each one has a reference to the other one.
These exist independent of the variables - you could del b and it would
still exist in a[0].


More information about the Tutor mailing list