in reply to Re^5: Using AUTOLOAD to create class methods
in thread Using AUTOLOAD to create class methods

Perl has a cache that it uses to avoid walking the inheritance tree, basically if you looked in this package and found the method over there, then it just returns the same method the next time. This speeds things up, but you need to remove the cache if anything happens that could make it invalid - such as defining a function somewhere. It will then build up again.

So if you use an AUTOLOAD that autogenerates methods, then every time you hit that AUTOLOAD you throw away the method cache and have to start generating it again. Depending on your program's profile, this can be significant overhead.

  • Comment on Re^6: Using AUTOLOAD to create class methods

Replies are listed 'Best First'.
Re^7: Using AUTOLOAD to create class methods
by ikegami (Patriarch) on Nov 15, 2005 at 17:34 UTC
    Does defining a function really clear the cache, or just defining a named function? Defining a function should have no effect, just the modification of the symbol table that comes from defining named functions.
      I believe that it is triggered off of the symbol table, so you're right. Named function.