#11576: make it possible to generate sequences of variables easily
-------------------------------+--------------------------------------------
Reporter: kcrisman | Owner: burcin
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.6
Component: symbolics | Resolution:
Keywords: Cernay2012 | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
-------------------------------+--------------------------------------------
Comment (by burcin):
Replying to [comment:4 nbruin]:
> Perhaps another motivation for using GiNaC functionality for this is
that the alternative approach leaks. Watch the memory usage of
> {{{
> sage: for i in range(10^8):
> ....: l=1+SR.symbol("a%s"%str(i))
> }}}
> Perhaps GiNaCs indexed variables are less prone to leaking?
I'm not sure if anything is _leaking_ here. Pynac stores a symbol lookup
table, in order to give you the same variable if you ask for
SR.symbol('x') twice. As you pass new strings to this function, the lookup
table grows. Note that if you repeat the same loop, memory usage does not
grow.
I agree that this is a good argument for using indexed variables from
Pynac/GiNaC instead of trying to invent our own. Here are some numbers:
{{{
sage: get_memory_usage()
866.94921875
sage: x.ind[5]
x.5
sage: for i in range(10000):
....: t = x.ind[i]
....:
sage: get_memory_usage()
867.2265625
sage: for i in range(10000):
....: t = SR.symbol('a_'+str(i))
....:
sage: get_memory_usage()
870.4140625
}}}
This is with [attachment:trac_11576-indexed_expression.20130107.patch]. I
just rebased the patch I was working on at the Sage days in Cernay.
Apart from lack of documentation and tests, this patch provides the
functionality discussed in this ticket. The main problem holding it up was
the fact that it allows you to use arbitrary Python objects as indices,
and these are not handled properly when the expression is being converted
to Maxima.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11576#comment:22>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.