Reference Counting and Garbage Collection
Reference counts are increased by...
- Variable assignment
- Inclusion of an object in a container (list, tuple, dictionary, etc...).
Reference counts are decreased when...
- Local reference goes out of scope (variable name is destroyed).
- Variable name is bound to another object.
- Object is removed from a container.
- The variable name is explicitly destroyed using 'del' statement
del a
Objects destroyed when reference count reaches zero
- Well, unless there are circular references.
|