1 | initial version |

From `$SAGE_ROOT/local/sage-exp/src/sage/misc/functional.py`

:

```
def symbolic_sum(expression, *args, **kwds):
"...."
if hasattr(expression, 'sum'): ## This catches possible specialized methods of some objects
return expression.sum(*args, **kwds)
elif len(args) <= 1: ## If 0 or 1 argument, call Python's sum
return sum(expression, *args)
else:
from sage.symbolic.ring import SR
return SR(expression).sum(*args, **kwds) ## Use SR.sum by default
```

*Then*, from `$SAGE_ROOT/local/sage-exp/src/sage/misc/all.py`

:

```
from .functional import (additive_order,
#...
symbolic_sum as sum,
# ...
)
```

At compilation time, when `symbolic_sum`

is defined, Python's `sum`

is accessible as `sum`

, and used when no or a single argument is passed to `symbolic sum`

.

At run time, the global identifier `sum`

points to Sage's `symbolic_sum`

; however, thanks to Python's *lexical scoping*, this function still calls Python's `sum`

if necessary : the definitions in use are those present when `symbolic_sum`

was defined.

HTH,

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.