-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
-
目标链接:https://docs.python.org/3/reference/datamodel.html#object.del。
-
目标位置:Documentation -> The Python Language Reference -> 3.3.1. Basic customization,位于该节中介绍 object.__del__(self) 的小节。
-
原始英文:
(第1段开头)Called when the instance is about to be destroyed. This is also called a finalizer or (improperly) a destructor.
(CPython实现细节那段)CPython implementation detail: It is possible for a reference cycle to prevent the reference count of an object from going to zero. In this case, the cycle will be later detected and deleted by the cyclic garbage collector. A common cause of reference cycles is when an exception has been caught in a local variable. The frame’s locals then reference the exception, which references its own traceback, which references the locals of all frames caught in the traceback.
- 原始译文:
(第1段开头)在实例将被销毁时调用。这还会调用终结器或析构器 (不适当)。
(CPython实现细节那段)【本段未被翻译】
- 改进提议:
(第1段开头)在实例将被销毁时调用。这还被称为终结器或析构器 (不适当)。
(CPython实现细节那段)CPython implementation detail: 引用循环可能妨碍一个对象的引用计数归零。这种引用循环稍后会被循环垃圾回收器所检测并删除。引用循环常发生在一个异常被某一局部变量捕获时。然后,执行帧的局部变量引用了该异常,该异常引用了其自身的回溯对象,后者再引用了它捕获的所有执行帧的局部变量。
- 提议原因:
(第1段开头)第2句中的”call“为被动语态,非”调用“之意,否则会是“This also calls…”。
(CPython实现细节那段)贡献一版译文。