[Python-Dev] Meta-reflections

Samuele Pedroni pedroni@inf.ethz.ch
Tue, 19 Feb 2002 19:25:26 +0100


From: Kevin Jacobs <jacobs@penguin.theopalgroup.com>
> On Tue, 19 Feb 2002, Samuele Pedroni wrote:
> > Slots are already not flat.
> > They have basically a similar behavior to fields
> > in JVM object model (and I presume in .NET).
> 
> I agree, but do we want slots to be non-flat?  It goes very much against the
> traditional Python idiom.  In my opinion, I believe that slots should have
> exactly the same semantics as normal instance attributes, except for
> how/where they are allocated.

Personally I don't expect slots to behave like attributes. I mean,
the different naming is a hint.

> > Given that implementing slots with fields is one of the possibility for
> > Jython
> 
> This is possible for flat slot namespaces too; just remap new slots to
> existing ones when they overlap, instead of allocating a new one.

Yes, but from the POV of fields this is less natural.
There's a trade-off issue here.

> > Consider also:
> >
> > >>> class Goo(object):
> > ...  __slots__ = ('a',)
> > ...
> > >>> class Bar(Goo,Foo): pass
> > ...
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > TypeError: multiple bases have instance lay-out conflict
> >
> > that helps and reinforces that model.
> 
> I'll contend that the current implementation is flawed for this and several
> other reasons I've stated in my previous e-mails.  Of course, we're waiting
> to hear back from Guido when he returns, since his opinion is infinitely
> more important than mine in this matter.
> 

It is not flawed, it is just single-inheritance-of-struct-like-layout-based.
I'm fine with that.

To be honest I would find very annoying that what we are about
to implement in Jython 2.2 should be somehow radically changed for Jython 2.3.
We have not the necessary amount of human resources 
to happily play that kind of game.

I hope and presume that Guido did know what he was designing,
and I had that impression too.
OTOH I agree that pickle should work for new-style classes too.

regards, Samuele Pedroni.