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