@@ -1483,55 +1483,56 @@ cdef class ExpressionChoice(Expression):
14831483 repr (self ._iffalse))
14841484
14851485cpdef _expression_binop_helper(s, o, op):
1486- r """
1487- Make an Expression for ( s op o) . Either s or o ( or both) must already
1488- be an expression.
1489-
1490- EXAMPLES::
1491-
1492- sage: from sage. ext. fast_callable import _expression_binop_helper, ExpressionTreeBuilder
1493- sage: var( 'x,y')
1494- ( x, y)
1495- sage: etb = ExpressionTreeBuilder( vars=( x,y))
1496- sage: x = etb( x)
1497-
1498- Now x is an Expression, but y is not. Still, all the following
1499- cases work::
1500-
1501- sage: _expression_binop_helper( x, x, operator. add)
1502- add( v_0, v_0)
1503- sage: _expression_binop_helper( x, y, operator. add)
1504- add( v_0, v_1)
1505- sage: _expression_binop_helper( y, x, operator. add)
1506- add( v_1, v_0)
1507-
1508- """
1509- # The Cython way of handling operator overloading on cdef classes
1510- # (which is inherited from Python) is quite annoying. Inside the
1511- # code for a binary operator, you know that either the first or
1512- # second argument (or both) is a member of your class, but you
1513- # don't know which.
1514-
1515- # If there is an arithmetic operator between an Expression and
1516- # a non-Expression, I want to convert the non-Expression into
1517- # an Expression. But to do that, I need the ExpressionTreeBuilder
1518- # from the Expression.
1519-
1520- cdef Expression self
1521- cdef Expression other
1522-
1523- if not isinstance (o, Expression):
1524- self = s
1525- other = self ._etb(o)
1526- elif not isinstance (s, Expression):
1527- other = o
1528- self = other._etb(s)
1529- else :
1530- self = s
1531- other = o
1532- assert self ._etb is other._etb
1533-
1534- return ExpressionCall(self ._etb, op, [self , other])
1486+ r """
1487+ Make an Expression for ( s op o) . Either s or o ( or both) must already
1488+ be an expression.
1489+
1490+ EXAMPLES::
1491+
1492+ sage: from sage. ext. fast_callable import _expression_binop_helper, ExpressionTreeBuilder
1493+ sage: var( 'x,y')
1494+ ( x, y)
1495+ sage: etb = ExpressionTreeBuilder( vars=( x,y))
1496+ sage: x = etb( x)
1497+
1498+ Now x is an Expression, but y is not. Still, all the following
1499+ cases work::
1500+
1501+ sage: _expression_binop_helper( x, x, operator. add)
1502+ add( v_0, v_0)
1503+ sage: _expression_binop_helper( x, y, operator. add)
1504+ add( v_0, v_1)
1505+ sage: _expression_binop_helper( y, x, operator. add)
1506+ add( v_1, v_0)
1507+
1508+ """
1509+ # The Cython way of handling operator overloading on cdef classes
1510+ # (which is inherited from Python) is quite annoying. Inside the
1511+ # code for a binary operator, you know that either the first or
1512+ # second argument (or both) is a member of your class, but you
1513+ # don't know which.
1514+
1515+ # If there is an arithmetic operator between an Expression and
1516+ # a non-Expression, I want to convert the non-Expression into
1517+ # an Expression. But to do that, I need the ExpressionTreeBuilder
1518+ # from the Expression.
1519+
1520+ cdef Expression self
1521+ cdef Expression other
1522+
1523+ if not isinstance (o, Expression):
1524+ self = s
1525+ other = self ._etb(o)
1526+ elif not isinstance (s, Expression):
1527+ other = o
1528+ self = other._etb(s)
1529+ else :
1530+ self = s
1531+ other = o
1532+ assert self ._etb is other._etb
1533+
1534+ return ExpressionCall(self ._etb, op, [self , other])
1535+
15351536
15361537class IntegerPowerFunction (object ):
15371538 r """
0 commit comments