mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#7637: update discussion of minidom.unlink() and garbage collection
This commit is contained in:
parent
343facabf1
commit
f8af7b46fd
1 changed files with 6 additions and 16 deletions
|
@ -85,22 +85,12 @@ document: the one that holds all others. Here is an example program::
|
||||||
dom3 = parseString("<myxml>Some data</myxml>")
|
dom3 = parseString("<myxml>Some data</myxml>")
|
||||||
assert dom3.documentElement.tagName == "myxml"
|
assert dom3.documentElement.tagName == "myxml"
|
||||||
|
|
||||||
When you are finished with a DOM, you should clean it up. This is necessary
|
When you are finished with a DOM tree, you may optionally call the
|
||||||
because some versions of Python do not support garbage collection of objects
|
:meth:`unlink` method to encourage early cleanup of the now-unneeded
|
||||||
that refer to each other in a cycle. Until this restriction is removed from all
|
objects. :meth:`unlink` is a :mod:`xml.dom.minidom`\ -specific
|
||||||
versions of Python, it is safest to write your code as if cycles would not be
|
extension to the DOM API that renders the node and its descendants are
|
||||||
cleaned up.
|
essentially useless. Otherwise, Python's garbage collector will
|
||||||
|
eventually take care of the objects in the tree.
|
||||||
The way to clean up a DOM is to call its :meth:`unlink` method::
|
|
||||||
|
|
||||||
dom1.unlink()
|
|
||||||
dom2.unlink()
|
|
||||||
dom3.unlink()
|
|
||||||
|
|
||||||
:meth:`unlink` is a :mod:`xml.dom.minidom`\ -specific extension to the DOM API.
|
|
||||||
After calling :meth:`unlink` on a node, the node and its descendants are
|
|
||||||
essentially useless.
|
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue