Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures) (original) (raw)
Martin v. L�wis martin@v.loewis.de
15 Apr 2003 21:50:11 +0200
- Previous message: Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures)
- Next message: [Python-Dev] Garbage collecting closures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Algorithm for finalizing cycles (Re: [Python-Dev] Garbage collecting closures)
- Next message: [Python-Dev] Garbage collecting closures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]