As commented by @thefourtheye:
When you assign None
and no other references exist, the objects will be automatically marked for GC. You don't have to explicitly trigger that.
You are reducing the reference count of the actual object by assigning None
to the list index. When you say a[i] = None
you decrease the reference count of the object at a[i]
by 1
. If it had reference count 1
, then it makes it to 0
, and since nothing no longer references that object, it will be ready for GC.