[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: matrix operations and temporary objects?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 4 Aug 2009 07:45:04 -0300
> Is it possible to do something in Lua and somehow control use of
> temporary objects when dealing with typical +-*/ math operations in Lua??
It is not possible to know directly when Lua is creating a temporary object,
though you could do something along the lines of the "Using fallbacks" section
in the SPE paper: http://www.lua.org/spe.html (I have the equivalent code for
Lua 5.1 somewhere).
Another alternative is to provide "begin_computation" and "end_computation"
functions that will store all objects created between these calls in an
internal C stack that can be freed or recycled in one go.
for n=1,1000 do
begin_computation()
m= m*m1 + m2
end_computation() -- must not free m, ie, the last object created
end