[Python-Dev] PEP 252, PEP 253 and jython issues
Samuele Pedroni <firstname.lastname@example.org>
Thu, 23 Aug 2001 23:56:42 +0200 (MET DST)
OK, here is my major concern
Given the following three types subclassed in Pyhon:
class A(CSpecialList): ...
class B(list): ...
class C(A,B): ...
where CSpecialList is a subtype of list written in C.
Now the old mro would be:
C A CSpecialList list object B list object
that translate to the new mro
C A CSpecialList B list object
The question is it possible for CSpecialList for the code that define
for example sq_ass_slice to use sq_slice code in a safe manner?
(AFAIK listobject does something similar)
And how can safely CSpecialList invoke a "super" behaviour, it is safe
for it to refer to the behaviour offered by list. In principle
given the mro e.g. a __getslice__ redefined in B should shadow
such a behaviour?
A natural way to design PEP252, and PEP253 for Jython would
be start to start from the equation:
object = org.python.core.PyObject
then it is necessary to build a class that truly correspond to the type
metatype, actually jython fakes using the metatype used for Java Classes for
It would make sense to use Java subclassing to implement
type subclassing, at least at layout level this does not clash with
the multiple inheritance rule in best_base.
And actually is also how Jython now works: for example
PyList extends PySequence that extends PyObject.
But than there is the issue of method resolution order: from the viewpoint
of Python code we can implement anything, not that easy ...
But the at the Java level, where we construct types, the codebase uses the
normal single inheritance of java and the codebase is full of super.foo
invocations and of methods that cross-call each other (potentially overriden)
versions, and this happen also for behaviour that correspond to the slots/
__foo__ special methods of CPython.
That's why the two questions are important?