Re: MRO theory
- From: "Carl Banks" <pavlovevidence@xxxxxxxxx>
- Date: 11 Apr 2007 17:21:28 -0700
On Apr 11, 3:26 pm, "Clarence" <clarence1...@xxxxxxxxx> wrote:
No, there is no circularity. The problem is coming about in the JPype
application. It creates a Python class to proxy any Java class or Java
interface that the program uses (directly or indirectly). As far as
the
Java proxies go, when it creates a class it can have at most one
superclass
that is a proxy of a Java class, and arbitrarily many superclasses
which
are proxies of Java interfaces.
The problem basically comes about because interfaces are not classes,
but a class is being created to stand in for each one.
Yes. In Java, because there's no possibility of conflicting methods,
interfaces can be listed in any order. But when proxying Java classes
with Python, the order of interfaces becomes important.
There is real Java code that is causing a class construction failure
because of an inability to construct a consistent mro. I've tried
several
approaches to make it work, and by accident, sorting the list of
interface
proxy classes, using the default comparison, make it work.
It *might* not be an accident.
Because Java interfaces can be listed in any order, it's quite
possible that some interface hierarchies in Java violate Python's MRO
restrictions right out of the box. I would guess that JPype deals
with this situation by applying a consistent ordering to of bases when
it creates a proxy class. And it just might turn out that "order of
creation" is the sort key. Or something else could be the key
(alphabetical by name?). Regardless, sorted order just *might* be the
proper order to list bases to ensure MRO consistency.
Or I could be way off base.
I'd suggest that this is probably a question better answered on the
JPype mailing list, since they would have answers and not just
speculations.
That made
me
wonder if the theory had something to say. Obviously, if class A is
created
before class B, then B cannot be a base class of A, hence the
chronological
order of class creation _might_ have something to do with creating
acceptable
or unacceptable mro's.
I doubt it "happens" to work that way. If sorting the bases works in
general, it's probably deliberate.
Carl Banks
.
- Follow-Ups:
- Re: MRO theory
- From: Clarence
- Re: MRO theory
- References:
- MRO theory
- From: Clarence
- Re: MRO theory
- From: Steve Holden
- Re: MRO theory
- From: Clarence
- MRO theory
- Prev by Date: Strange Behavior with Old-Style classes and implicit __contains__
- Next by Date: Re: Python Web Servers and Page Retrievers
- Previous by thread: Re: MRO theory
- Next by thread: Re: MRO theory
- Index(es):
Relevant Pages
|