A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/034639.html below:

Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures)

Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures) Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures)Guido van Rossum guido@python.org
Tue, 15 Apr 2003 15:06:15 -0400
> > > If the object having a finalizer doesn't support references to
> > > arbitrary other objects, then the application cannot make this
> > > object be part of a cycle.

> Greg Ewing <greg@cosc.canterbury.ac.nz> writes:
> 
> > It could make a subclass, though...

> From: martin@v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=)
> 
> If the type is carefully designed, it can't...

I suppose you have something in mind like this (which is the only way
I can come up with to implement something like a 'final' class in pure
Python):

  >>> class C(object): 
  ...   def __new__(cls):
  ...     if cls is not C: raise TypeError, "haha"
  ...     return object.__new__(cls)
  ...
  >>> class D(C): pass
  ...    
  >>> a = D()
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "<stdin>", line 3, in __new__
  TypeError: haha
  >>>

But how would you prevent this?

  >>> a = C()
  >>> a.__class__ = D
  >>>

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4