I'm afraid the issue is more complicated. On Friday, February 16, 2018 at 5:04:30 PM UTC+1, Erik Bray wrote: > > 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.
Actually Constants.__eq__ is never called here. Pi is an expression not a constant. With expression relations ultimately Expression.__nonzero__ does all the work. It calls OP(pi.pyobject(), pi.pyobject()) with OP = operator.le. This calls Expression._richcmp_(pi, pi, Py_LT) (why?) which consults Pynac. Pynac checks if LHS-RHS is trivially zero which it is and returns True. No floating point involved, just symbolics. > 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' > This baffles me and I would like to know why the computation differs from the above. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
