Hi everyone,
   On https://github.com/sagemath/sage/pull/37128, we find it useful to 
swap the order of the base classes for UniqueRepresentation. Thus, it 
becomes

class UniqueRepresentation(WithEqualityById, CachedRepresentation):

I believe this is very reasonable since we want to have objects' (typically 
parents, but not limited to them) comparison and hashing be first in the 
MRO. In particular, this is important if we have the following setup:

class Foo(CachedRepresentation):
    pass

class Bar(UniqueRepresentation, Foo):
    pass

That way Bar gets the main benefits of being a UR (fast equality and 
hashing). With the current way, there is no way (that I know) to simply 
have the corresponding methods at the Cython level (at best, there is a 
Python redirect that has to be manually implemented) since WithEqualityById 
is a Cython cdef class.

However, we then have a problem with unpickling, but I suspect it is a 
bigger issue. From combinat/root_system/cartan_type.py, the last line fails 
with an incompatible class order:

            sage: pg_CartanType_simple_finite = 
unpickle_global('sage.combinat.root_system.cartan_type', 
'CartanType_simple_finite')
            sage: si1 = unpickle_newobj(pg_CartanType_simple_finite, ())
            sage: from sage.misc.fpickle import unpickleModule
            sage: pg_make_integer = unpickle_global('sage.rings.integer', 
'make_integer')
            sage: si2 = pg_make_integer('4')
            sage: unpickle_build(si1, 
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', 
si2], 'letter':'A', 'n':si2})

Mainly, the last line does a self.__class__ = UR.__class__, where UR is an 
instance of a UniqueRepresentation. Granted, this is a very old pickle, but 
I am worried it isn't a problem with this specific pickle.

This is beyond my knowledge of Cython. Any thoughts or advice about this 
issue would be appreciated.

Thank you,
Travis

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/5d3b6cdd-5253-405c-ae34-094870e15430n%40googlegroups.com.

Reply via email to