On Apr 5, 2013 8:24 PM, "Uri Guttman" <[email protected]> wrote:
> as for your ram usage, all recursions can be unrolled into plain loops by
managing your own stack. this is a classic way to save ram and sub call
overhead. with perl it would be a fairly trivial thing to do. use an array
for the stack and each element could be a hash ref containing all the
data/args for that level's call. then you just loop and decide to 'recurse'
or not. if you recurse you push a new hash ref onto the stack and loop. if
you don't recurse you pop a value from the stack and maybe modify the
previous top of the stack (like doing a return early in recursion). i leave
the details to you. this would save you a ton of ram and cpu for each call
if you go very deep and complex.

Uri, you know more perlguts than I do, so maybe this is a dumb question,
but...  why is this that much faster than actual recursion?  That speaks
poorly of lowercase-p perl.

-Conor

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to