coroutine as objects, then the finally clause can be considered a finalizer of the object, and thus can be executed when the instance is garbage collected. In Python terminology, the definition of a coroutine is a generator function, while an instance of it is a generator iterator, and thus a finally clause in a generator function becomes a finalizer in generator iterators instantiated from this function. History The notion of finalization as a separate step in object destruction dates to , by analogy with the earlier distinction of initialization in object construction in . Literature prior to this point used "destruction" for this process, not distinguishing finalization and deallocation, and programming languages dating to this period, like C++ and Perl, use the term "destruction". The terms "finalize" and "finalization" are also used in the influential book Design Patterns (1994). The introduction of Java in 1995 contained finalize methods, which popularized the term and associated it with garbage collection, and languages from this point generally make this distinction and use the term "finalization", particularly in the context of garbage collection. See also Garbage collection, specifically the section on Determinism Object lifetime Initialization Process & related Initializer Pattern Notes References Further reading External links "Finalize Instead Of Proper Destructor", WikiWikiWeb – comparison of Java finalizers with C++ destructors Paul Krill, "Oracle recommends axing Java object finalizer", JavaWorld Mar 29, 2017. Memory management Method (computer programming) Object-oriented programming de:Garbage Collection#Finalisierung