diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-23 18:41:45 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-23 18:41:45 (GMT) |
commit | f8387af2620b2e02ceac856e08786429a913adb5 (patch) | |
tree | 28d9ca7a2f538e80fc9d6b00a22cea40b9941a33 /Doc | |
parent | e5b78563b6f394e69d87ee68cc82c173c95dfa0b (diff) | |
download | cpython-f8387af2620b2e02ceac856e08786429a913adb5.zip cpython-f8387af2620b2e02ceac856e08786429a913adb5.tar.gz cpython-f8387af2620b2e02ceac856e08786429a913adb5.tar.bz2 |
Issue #4688: Add a heuristic so that tuples and dicts containing only
untrackable objects are not tracked by the garbage collector. This can
reduce the size of collections and therefore the garbage collection overhead
on long-running programs, depending on their particular use of datatypes.
(trivia: this makes the "binary_trees" benchmark from the Computer Language
Shootout 40% faster)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/gc.rst | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst index 9ebbf06..65f0f39 100644 --- a/Doc/library/gc.rst +++ b/Doc/library/gc.rst @@ -140,6 +140,31 @@ The :mod:`gc` module provides the following functions: .. versionadded:: 2.3 +.. function:: is_tracked(obj) + + Returns True if the object is currently tracked by the garbage collector, + False otherwise. As a general rule, instances of atomic types aren't + tracked and instances of non-atomic types (containers, user-defined + objects...) are. However, some type-specific optimizations can be present + in order to suppress the garbage collector footprint of simple instances + (e.g. dicts containing only atomic keys and values):: + + >>> gc.is_tracked(0) + False + >>> gc.is_tracked("a") + False + >>> gc.is_tracked([]) + True + >>> gc.is_tracked({}) + False + >>> gc.is_tracked({"a": 1}) + False + >>> gc.is_tracked({"a": []}) + True + + .. versionadded:: 2.7 + + The following variable is provided for read-only access (you can mutate its value but should not rebind it): |