Method interface vs Function Interface
I have recently came across a mod_perl document that suggested Perl's Method Interface is more 'memory friendly' compare to Perl's Function Interface. I'm not too sure I've got the meaning of this 'Method Interface' and 'Function Interface' correctly, is it referring to the procedural function call and the Object Oriented Method invoking? or is it trying to suggest to use 'use' instead of 'require'? Quote From : http://perl.apache.org/dist/mod_perl.html Importing Functions When possible, avoid importing of a module functions into your namespace. The aliases which are created can take up quite a bit of space. Try to use method interfaces and fully qualified Package::function names instead. Here's a freshly started httpd who's served one request for a script using the CGI.pm method interface: TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND p4 5016 dougm 154 20 3808K 2636K sleep 0:01 9.62 4.07 httpd Here's a freshly started httpd who's served one request for the same script using the CGI.pm function interface: TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND p4 5036 dougm 154 20 3900K 2708K sleep 0:01 3.19 2.18 httpd Now do the math: take that difference, figure in how many other scripts import the same functions and how many children you have running. It adds up!
Re: Method interface vs Function Interface
On Sun, 10 Jun 2001 [EMAIL PROTECTED] wrote: > I have recently came across a mod_perl document that suggested Perl's > Method Interface is more 'memory friendly' compare to Perl's Function > Interface. > > I'm not too sure I've got the meaning of this 'Method Interface' and > 'Function Interface' correctly, is it referring to the procedural > function call and the Object Oriented Method invoking? or is it trying > to suggest to use 'use' instead of 'require'? Quite a lot of Perl modules allow you to "import" functions or even variables, that means to make them available within your current namespace. (e.g. you can call "foo()" instead of "Foo::foo()"). Some of them even export functions per default. This importing requires adding entries into the so called "symbol table", which then of course means consuming more memory. So it's basically suggesting you either use the object oriented interface - if available - ( Foo->foo() ) or you use fully qualified function names ( Foo::foo() ). Also, as a rule of thumb, to avoid importing functions, you can use require instead of use as this usually even avoids importing default exports. -- Markus Peter - SPiN AG [EMAIL PROTECTED]