Hi,

In working on the Python 3 port of Sage I ran into a problem with
constants defined in sage.symbolic.constants (there are only a few).

On Python 2 this works:

sage: bool(pi <= pi)
True

This works fine because the Constant class implements __eq__, and so
if asking if pi <= pi that's good enough for it.

However, on Python 3 <= will explicitly call __le__ if it's defined
and raise a TypeError otherwise.  Or at the very least __lt__ must be
implemented, and with __eq__ and __lt__ defined it's possible to
derive the other comparison operators.

So on Python 3 we get:

sage: bool(pi <= pi)
TypeError                                 Traceback (most recent call last)
...
TypeError: '<=' not supported between instances of 'Pi' and 'Pi'

So I could define __lt__ between Constants and fix this.  The question
is how it should be defined.  That is, to what level of precision?
For the constants we have defined, taking their float values should be
good enough for comparison between constants.  But I'm not sure if
that's good enough in general...?

Thanks,
E

-- 
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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to