#8555: Unexpected behaviour of symbolic zero.
-------------------------------------+-------------------------------------
       Reporter:  lfousse            |        Owner:  burcin
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:
      Component:  symbolics          |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  André Apitzsch     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/aapitzsch/ticket/8555            |  c79c0fb678fb6e7f27a966ce7fbadfae258aa3c0
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Perhaps it's better to be a bit more selective than just avoiding the zero
 shortcut completely. It's only `SR(0)` that has this funny behaviour. All
 other zeros should be fine. So the test should probably be something like
 {{{
     if not isinstance(right, sage.symbolic.expression.Expression) and
 right == 0:
         return bool(self._MPolynomial_element__element)
 }}}
 Note the chance to the if body.
 This return value evaluates slightly faster when `self` is in fact 0 and a
 lot faster if `self` is nonzero (I suspect it kicks down to checking if
 `self._MPolynomial_element__element.__len__()` is 0, but does so on
 CPython slot level, so saves quite a bit of lookup).

 It's of course nice to try and make symbolic entities work consistently
 with MPolynomial, but interacting with SR is not the main purpose of
 MPolynomial, so you should make sure that measures undertaken for it do
 not affect other use cases.

 I don't have an immediate answer on what the best way is to make available
 the symbol `sage.symbolic.expression.Expression` (or what the best test is
 determine reliably and cheaply whether `right` is an element of SR). One
 way is of course to just `import sage.symbolic.expression`, but it's a
 little unfortunate to create an apparent dependence (even if that's a
 circular import, it should be fine, though). Doing the import in the
 method is not an option.

--
Ticket URL: <http://trac.sagemath.org/ticket/8555#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to