U
Uri Guttman
JB> And yet there are plenty of papers written on automatic memoization,
JB> which would be a pleonasm if it was that simple.
JB> This technique is called “memoization.†The manual version of the
JB> technique generally involves building lookup tables and is a standard
JB> technique in dynamic programming. This process, however, is often
JB> tedious and time-consuming, and it requires significant mod-
JB> ification and debugging of existing code. An “automatic†memoization
JB> facility is one in which existing functions can be programmatically
JB> changed to cache previously seen results in a table,
JB> http://techdigest.jhuapl.edu/td/td1802/hall.pdf p254-255.
JB> (unless I misunderstand automatic memoization)
do you know there is a memoize module on cpan? it does that very same
thing. it is actually fairly simple code. it creates a new sub that uses
a private hash to store previously calculated values. the index is the
fixed set of args into the function. it replaces the regular sub in the
symbol table with the new sub. the new sub keeps the code ref to the
original and calls it when the hash lookup fails. then it stores the new
result in the hash. not complex at all IMO. and it doesn't require any
debugging of existing code - it is a drop in speedup for the right type
of call - trading ram for speed.
uri
JB> which would be a pleonasm if it was that simple.
JB> This technique is called “memoization.†The manual version of the
JB> technique generally involves building lookup tables and is a standard
JB> technique in dynamic programming. This process, however, is often
JB> tedious and time-consuming, and it requires significant mod-
JB> ification and debugging of existing code. An “automatic†memoization
JB> facility is one in which existing functions can be programmatically
JB> changed to cache previously seen results in a table,
JB> http://techdigest.jhuapl.edu/td/td1802/hall.pdf p254-255.
JB> (unless I misunderstand automatic memoization)
do you know there is a memoize module on cpan? it does that very same
thing. it is actually fairly simple code. it creates a new sub that uses
a private hash to store previously calculated values. the index is the
fixed set of args into the function. it replaces the regular sub in the
symbol table with the new sub. the new sub keeps the code ref to the
original and calls it when the hash lookup fails. then it stores the new
result in the hash. not complex at all IMO. and it doesn't require any
debugging of existing code - it is a drop in speedup for the right type
of call - trading ram for speed.
uri