Any symbolic ring in Sage has a dictionary called "symbols". (I'll refer 
specifically to "SR" for the following.) "SR.symbols" contains all the 
previously defined variables through "SR.var()" and/or "SR.symbol()". 
However, this generates a problem: Many symbols remain stored there even 
when they have been overwritten for other purposes. For example, when one 
starts a new Sage session, Sage executes the line

    from sage.calculus.predefined import x

This is done in order to have "x" as a default predefined symbolic 
variable. However, the whole file "sage/calculus/predefined.py" is executed 
which calls "SR.var()" on every single letter of the alphabet (lowercase 
and uppercase). So, when one has a freshly started Sage session (without 
any additional execution), "SR.symbols" already has length 48:

    SR.symbols = {'a':a, ...'z':z, 'A':A, ...,'Z':Z}

Since "x" is the only predefined variable, this should be simply 
"SR.symbols={'x':x}".

An even bigger problem is seen with the following code:

    SR.var('foo')
    # Do something meaningful with "foo" until you don't need it anymore
    foo = 2
   # Do something meaningful with the new meaning of "foo"

This keeps "foo" listed as a symbolic variable in "SR.symbols" even though 
it is now an Integer. In time, "SR.symbols" gets cluttered with 
non-existing symbolic variables.

Do we really need this behavior? Is it "SR.symbols" necessary at all? Could 
we remove it?

*Note: *The motivation for this proposal comes from this Ask SageMath 
question 
<http://ask.sagemath.org/question/56041/differences-between-srvar-and-srsymbol/>,
 
where @tmonteil proposed a command "SR.symbols()" for defining symbolic 
variables. The current "SR.symbols" could be renamed to "SR._symbols_" 
(this complies with Python's conventions on private variables), but perhaps 
it is unnecessary to have "SR._symbols_" at all.

(Sorry for the long post.)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/6adf8329-2967-4d0e-baa9-f78db2c18b55n%40googlegroups.com.

Reply via email to