Hello,

I am trying to simplify and optimize the "comparison" part of the coercion framework at #17890.

There is one convention we currently have in Sage which is posing an obstacle: if a Python class (not a Cython cdef class) inheriting from Element defines both _cmp_c_impl and __cmp__, then __cmp__ should be called. This is particularly annoying because testing for __cmp__ takes a lot more time than testing for _cmp_c_impl.

In #17890, I want to rename _cmp_c_impl to _cmp_ and make it cpdef (like the other arithmetic functions such as _add_). Then I also would like to reverse the convention and make _cmp_ take priority over __cmp__. Of course, for cmp() to work, both __cmp__ and _cmp_ will need to be defined (but this is already true for cdef classes). Any comments or objections?


Note: below is the list of affected classes, where currently both _cmp_c_impl and __cmp__ are defined:

<class 'sage.combinat.root_system.weyl_group.ClassicalWeylSubgroup_with_category.element_class'> <class 'sage.combinat.root_system.weyl_group.WeylGroup_gens_with_category.element_class'> <class 'sage.combinat.set_partition.SetPartitions_all_with_category.element_class'> <class 'sage.combinat.set_partition.SetPartitions_setn_with_category.element_class'> <class 'sage.combinat.set_partition.SetPartitions_setparts_with_category.element_class'> <class 'sage.combinat.set_partition.SetPartitions_set_with_category.element_class'>
<class 'sage.geometry.fan_morphism.FanMorphism'>
<class 'sage.groups.braid.BraidGroup_class_with_category.element_class'>
<class 'sage.groups.matrix_gps.group_element.FinitelyGeneratedMatrixGroup_gap_with_category.element_class'> <class 'sage.groups.matrix_gps.group_element.LinearMatrixGroup_gap_with_category.element_class'> <class 'sage.groups.matrix_gps.group_element.SymplecticMatrixGroup_gap_with_category.element_class'> <class 'sage.modular.abvar.morphism.EndomorphismSubring_with_category.element_class'>
<class 'sage.modular.hecke.degenmap.DegeneracyMap'>
<class 'sage.modular.hecke.morphism.HeckeModuleMorphism_matrix'>
<class 'sage.modules.fg_pid.fgp_morphism.FGP_Morphism'>
<class 'sage.modules.free_module_morphism.FreeModuleMorphism'>
<class 'sage.modules.matrix_morphism.MatrixMorphism'>
<class 'sage.modules.vector_space_morphism.VectorSpaceMorphism'>
<class 'sage.rings.number_field.morphism.RelativeNumberFieldHomomorphism_from_abs'> <class 'sage.schemes.elliptic_curves.ell_curve_isogeny.EllipticCurveIsogeny'> <class 'sage.schemes.elliptic_curves.weierstrass_morphism.WeierstrassIsomorphism'>

--
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/d/optout.

Reply via email to