summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-01-14 12:06:45 (GMT)
committerGitHub <noreply@github.com>2020-01-14 12:06:45 (GMT)
commita2ec3f07f7f028ff6229d6be2a7cfbda1f4efaeb (patch)
tree2ca30015db1da7016d3f0eff8e253dcfc298452a /Doc/library
parent1d1b97ae643dd8b22d87785ed7bd2599c6c8dc8d (diff)
downloadcpython-a2ec3f07f7f028ff6229d6be2a7cfbda1f4efaeb.zip
cpython-a2ec3f07f7f028ff6229d6be2a7cfbda1f4efaeb.tar.gz
cpython-a2ec3f07f7f028ff6229d6be2a7cfbda1f4efaeb.tar.bz2
bpo-39322: Add gc.is_finalized to check if an object has been finalised by the gc (GH-17989)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/gc.rst21
1 files changed, 21 insertions, 0 deletions
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
index 13eda91..0c33c86 100644
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -177,6 +177,27 @@ The :mod:`gc` module provides the following functions:
.. versionadded:: 3.1
+.. function:: is_finalized(obj)
+
+ Returns ``True`` if the given object has been finalized by the
+ garbage collector, ``False`` otherwise. ::
+
+ >>> x = None
+ >>> class Lazarus:
+ ... def __del__(self):
+ ... global x
+ ... x = self
+ ...
+ >>> lazarus = Lazarus()
+ >>> gc.is_finalized(lazarus)
+ False
+ >>> del lazarus
+ >>> gc.is_finalized(x)
+ True
+
+ .. versionadded:: 3.9
+
+
.. function:: freeze()
Freeze all the objects tracked by gc - move them to a permanent generation