Hi Simon,

When I read your post I had a hard time believing that your simple example 
actually caused trouble with inheritance. After playing around with it, it 
became clear this is a cython issue:

This works:

sage: cython("cdef class FastHash(object):\n    xyz_blaha=1")
sage: class Foo(FastHash,ZZ.__class__):
    pass
....: 

The following is the minimal example wich breakes:

sage: cython("cdef class FastHash2(object):\n    cdef object xyz_blaha2")
sage: cython("cdef class FastHash(object):\n    cdef object xyz_blaha")
sage: class Foo(FastHash,FastHash2):
    pass
....: 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/maarten/Downloads/sage-4.7.2.alpha2/devel/sage-main/<ipython console> 
in <module>()

TypeError: Error when calling the metaclass bases
    multiple bases have instance lay-out conflict


I guess the problem is that when FastHash is compiled, then the C lay-out of 
all the instance attributes is determined at compile time, and being 
efficient and all it just picks the first available slot. When later 
inheriting from both FastHash2 and FastHash the same memory slot has been 
assigned for xyz_blaha and xyz_blaha2. This of course leeds to errors. I 
have no idea how to solve this since I know to little of cython.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to