RFC: Proposal: Deterministic Object Destruction

Serhiy Storchaka storchaka at gmail.com
Thu Mar 1 02:54:04 EST 2018


01.03.18 04:46, Rick Johnson пише:
> On Wednesday, February 28, 2018 at 5:02:17 PM UTC-6, Chris Angelico wrote:
> 
>> Here's one example: reference cycles. When do they get detected?
>> Taking a really simple situation:
>>
>> class Foo:
>>      def __init__(self):
>>          self.self = self
> 
> *shudders*
> 
> Can you provide a real world example in which you need an
> object which circularly references _itself_? This looks like
> a highly contrived example used to (1) merely win the
> argument, and (2) Bump fib() up one position from it's
> current position as "the worst introductory example of how
> to write a function in the history of programming tutorials"

Every global function (or method of global class) creates a reference cycle.

     def f(): pass

     f.__globals__['f'] is f




More information about the Python-list mailing list