QuantEcon.py icon indicating copy to clipboard operation
QuantEcon.py copied to clipboard

ENH: make calls to `compute_fixed_point` allocate less memory

Open sglyon opened this issue 9 years ago • 3 comments

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).

sglyon avatar Aug 04 '14 21:08 sglyon

@spencerlyon2 This is done, right? Can we close?

jstac avatar Oct 08 '14 08:10 jstac

@jstac, I don't think so. This is the line we would need to change. In that line we would want new_v to be passed directly into T when it is called and T would update it inplace. Note that this will require a change to the T functions also.

sglyon avatar Oct 08 '14 12:10 sglyon

What about an 'inplace' option such that compute_fixed_point(T, v, inplace=True) would assume T to be a function T(v0, v1, ...) with the output being stored in v1 ? 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.

albop avatar Oct 09 '14 03:10 albop