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/034644.html below:

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

Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures)Martin v. Löwis martin@v.loewis.de
15 Apr 2003 21:50:11 +0200
Guido van Rossum <guido@python.org> writes:

> > > It could make a subclass, though...
> 
> > 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):

I was actually thinking about impure Python, i.e. by means of omitting
Py_TPFLAGS_BASETYPE.

> But how would you prevent this?
> 
>   >>> a = C()
>   >>> a.__class__ = D
>   >>>

For the issue at hand: Assigning __class__ won't change the object
layout, so if the object didn't have an __dict__ before, it won't have
an __dict__ afterwards. Of course, if there are writable slots,
the application could corrupt the underlying resource reference,
making __del__ meaningless, anyway. Here I need to bring up
Python's "we are all consenting adults" attitude...

Regards,
Martin




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