0

Given this example:

>>> x = [1, 2, 3]
>>> x = [1, 2]

Does the previous object that x is pointing to, the array of 1, 2, and 3, get destroyed by the garbage collector of Python? Or does it float around with nothing pointing at it?

Lawrence Vo
  • 177
  • 2
  • 11
  • 3
    I believe it's garbage collected – LMc Nov 11 '16 at 15:37
  • Yes, it is garbage collected. However, exactly when the GC is triggered is unknown – inspectorG4dget Nov 11 '16 at 15:39
  • As far as I understand [this](http://stackoverflow.com/a/9449506/6614295), this is actually implementation dependent and not guaranteed to be collected at all. It will probably be gc'ed, though. – jotasi Nov 11 '16 at 15:39

0 Answers0