On Fri, Oct 18, 2013 at 1:56 PM, Simon King <simon.k...@uni-jena.de> wrote:
> Howdy!
>
> On 2013-10-18, Robert Bradshaw <rober...@math.washington.edu> wrote:
>> It's a little more subtle than that. The underlying restriction is
>> that one can't have multiple inheritance of classes whose C members
>> (including cdef methods) are incompatible.
>
> A little remainder: There are cases of classes whose C members are
> considered to be *compatible* (e.g., sage.categories.maps.Map and
> sage.structure.element.ModuleElement or RingElement, I don't recall
> which), but when one creates a python class inheriting from both
> extension classes, then in fact the C members of the two bases may get
> confused.

Python's "are these two classes compatible" isn't very sophisticated.
(It might actually do no more than check the struct sizes.) I'm not
sure where we can put our hooks in to do better.

>> On that note, I have been looking at exposing C function pointers at
>> runtime, which would avoid the Python calling overhead and allow
>> passing of primitive types without the need for compile-time
>> declarations or fixed layouts.
>
> I don't know the internals of GAP very well. But someone has told me
> that GAP chooses functions according to what it has discovered about a
> specific object (hence, it can change over time), and it does so with C
> speed. Is GAP's method similar to what you suggest here?

I have no idea how GAP works, but from what you're describing it
sounds like there's a known, fixed set of methods that it can store in
a vtab which can get updated at runtime.

I'm thinking along the lines of when you do f(x) from Cython, it will
check to see if f was defined in Cython, and if it is and exposes a C
function pointer with compatible signature (depending on the type of
x) it could simply call that. If f is a method that would still
involve looking up f on the object using dicts, the mro, etc. but that
could (possibly) be made more efficient with implicit interfaces.

- Robert

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to