[BangPypers] How to handle files efficiently in python

Senthil Kumaran orsenthil at gmail.com
Thu Mar 24 07:37:17 CET 2011


On Thu, Mar 24, 2011 at 11:06:14AM +0530, Vishal wrote:
> setting l[0] to None, un-references the earlier string data associated with
> that name, which is then (force) collected by the collect() call.

Can you please elaborate this further? I don't see such behavior in
this snippet.

>>> l
[10, 20, 30]
>>> sys.getsizeof(l)
104
>>> l[0] = None
>>> import gc
>>> gc.collect()
0
>>> sys.getsizeof(l)
104
>>> l[0] = range(1000)
>>> sys.getsizeof(l)
104
>>> l[0] = None
>>> gc.collect()
0
>>> sys.getsizeof(l)
104

-- 
Senthil


More information about the BangPypers mailing list