diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-23 18:52:06 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-03-23 18:52:06 (GMT) |
commit | 3a652b1d0af20c7d2a9fc9251f71b2a34c49b302 (patch) | |
tree | 9972834d33037bf0daa361b04ed3eb3c9b20f75a /Doc/library | |
parent | 17e4fddb57049ed3a29cb667b630698973d946b8 (diff) | |
download | cpython-3a652b1d0af20c7d2a9fc9251f71b2a34c49b302.zip cpython-3a652b1d0af20c7d2a9fc9251f71b2a34c49b302.tar.gz cpython-3a652b1d0af20c7d2a9fc9251f71b2a34c49b302.tar.bz2 |
Merged revisions 70546 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70546 | antoine.pitrou | 2009-03-23 19:41:45 +0100 (lun., 23 mars 2009) | 9 lines
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/library')
-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 7c425e3..6929a3d 100644 --- a/Doc/library/gc.rst +++ b/Doc/library/gc.rst @@ -129,6 +129,31 @@ The :mod:`gc` module provides the following functions: from an argument, that integer object may or may not appear in the result list. +.. 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): |