in reply to Re: Re: Optimizing away calls to functions defined in eval
in thread Optimizing away calls to functions defined in eval

It executes faster. Closures are compiled at (wait for it...) compile time. It uses less memory. Instead of making a new sub, it can point to the same code. All perl has to do is install a pointer in the symbol table and attach a new stash to the CV. The code is checked at compile time, not run time, so errors can be found and corrected.

Besides that, string eval still has a few memory leaks, even in the latest versions of Perl. (That might change in the next week or two, but it doesn't help you right now.)

Here's another thought. If you're generating these with an AUTOLOAD mechanism, you could potentially poison your method dispatch cache. That'll slow down the next method call. (Or I could be crazy... that sounds right, but I can't find it documented right now... sorry.)

Update: It's in gv.c, specifically Perl_gv_fetchmeth. I've read scarier things, but don't ask for an annotation. ow! It's not available from user space, so there's no documentation. Modifying @ISA will mess with it, though.

  • Comment on Re: Re: Re: Optimizing away calls to functions defined in eval

Replies are listed 'Best First'.
Re: Re: Re: Re: Optimizing away calls to functions defined in eval
by demerphq (Chancellor) on Oct 17, 2001 at 17:35 UTC
    Umm if you do find the documentation id be interested to know a bit more about this poisened method cache.

    Cheers,

    Yves
    --
    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)