Re: [sage-devel] Proposal: make _cmp_c_impl() override __cmp__()

2015-03-04 Thread Nicolas M. Thiery
On Wed, Mar 04, 2015 at 05:17:02AM -0800, Jean-Pierre Flori wrote:
>The few times I played with comparison functions, I found what we have
>quite confusing, especially the discrpancy between Python and Cython
>classes, so any simplification would be welcomed.
>And if it also eases the transition towards Python 3 that would be
>great.

+1!!!

Thanks for your work in this direction.

I would need to double check each of them, but most likely the custom
cmp methods in the sage.combinat classes should be straightforward and
safe to refactor.

Cheers,
Nicolas
--
Nicolas M. ThiƩry "Isil" 
http://Nicolas.Thiery.name/

-- 
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.


Re: [sage-devel] Proposal: make _cmp_c_impl() override __cmp__()

2015-03-04 Thread Jean-Pierre Flori
The few times I played with comparison functions, I found what we have 
quite confusing, especially the discrpancy between Python and Cython 
classes, so any simplification would be welcomed.

And if it also eases the transition towards Python 3 that would be great.

-- 
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.


Re: [sage-devel] Proposal: make _cmp_c_impl() override __cmp__()

2015-03-04 Thread John Cremona
For the last two in your list it is quite possible that I wrote the
code and did not understand what I was doing at the time, just happy
that what I wrote worked.  (Particularly true of the
WeierstrassIsomorphism code which I wrote in 2007, the very first
Sage/python code I ever did write).  So please do what needs to be
done, and if it still works (and is no slower) I will certailny not
complain!

John

On 4 March 2015 at 10:31, Jeroen Demeyer  wrote:
> 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:
>
>  'sage.combinat.root_system.weyl_group.ClassicalWeylSubgroup_with_category.element_class'>
>  'sage.combinat.root_system.weyl_group.WeylGroup_gens_with_category.element_class'>
>  'sage.combinat.set_partition.SetPartitions_all_with_category.element_class'>
>  'sage.combinat.set_partition.SetPartitions_setn_with_category.element_class'>
>  'sage.combinat.set_partition.SetPartitions_setparts_with_category.element_class'>
>  'sage.combinat.set_partition.SetPartitions_set_with_category.element_class'>
> 
> 
>  'sage.groups.matrix_gps.group_element.FinitelyGeneratedMatrixGroup_gap_with_category.element_class'>
>  'sage.groups.matrix_gps.group_element.LinearMatrixGroup_gap_with_category.element_class'>
>  'sage.groups.matrix_gps.group_element.SymplecticMatrixGroup_gap_with_category.element_class'>
>  'sage.modular.abvar.morphism.EndomorphismSubring_with_category.element_class'>
> 
> 
> 
> 
> 
> 
>  'sage.rings.number_field.morphism.RelativeNumberFieldHomomorphism_from_abs'>
>  'sage.schemes.elliptic_curves.ell_curve_isogeny.EllipticCurveIsogeny'>
>  '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.

-- 
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.