The idea is quite simple: whenever we call compute_fixed_point(T, ...) we should update the definition of T so that any temporary arrays can be optionally supplied by the caller. See the new compute_lt_price function in the LucasTree class of quantecon/models/lucastree.py for an example (there we avoid allocating Tf on each iteration).
Activity
[-]ENH: make calls to `compute_fixed_point` not allocate memory[/-][+]ENH: make calls to `compute_fixed_point` allocate less memory[/+]jstac commentedon Oct 8, 2014
@spencerlyon2 This is done, right? Can we close?
sglyon commentedon Oct 8, 2014
@jstac, I don't think so. This is the line we would need to change. In that line we would want
new_vto be passed directly intoTwhen it is called andTwould update it inplace. Note that this will require a change to theTfunctions also.albop commentedon Oct 9, 2014
What about an 'inplace' option such that
compute_fixed_point(T, v, inplace=True)would assumeTto be a functionT(v0, v1, ...)with the output being stored inv1?The alternative would be to assume a call like
T(v0, out=v1). In that case it is possible to automatically check whether T has an output argument.Both options would preserve backward compatibility.