Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Do multiple calls to 'use X' abuse the compiler?

by diotalevi (Canon)
on Mar 02, 2008 at 02:18 UTC ( #671453=note: print w/replies, xml ) Need Help??


in reply to Re: Do multiple calls to 'use X' abuse the compiler?
in thread Do multiple calls to 'use X' abuse the compiler?

Quadruple downvotes for saying "Benchmark it" to this question. The real answer is that every use() past the first is only a hash lookup. There's no abuse of the compiler and you should feel very safe in using the same thing from many places.

Caveats are of course, that $class->VERSION eq '...' or die "..." and $class->import(...) are also possibly implicated but neither of those are compiler tasks and you ought to already know if you care about the overhead of each and whether you're invoking them. I can't imagine someone using CGI::Application is going to care about the additional cost of one cheap method call.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^3: Do multiple calls to 'use X' abuse the compiler?
by ikegami (Pope) on Mar 02, 2008 at 03:17 UTC

    The real answer is that every use() past the first is only a hash lookup

    I said use Module qw( ); is just a hash lookup, but use Module; isn't. Are you contradicting that?

    you ought to already know if you care about the overhead of each

    How? I heard import can be fairly costly. But to know for sure, one would been benchmark it.

    And whether or not he ought to know is not important. He asked so I answered.

      ->import is frequently extremely cheap especially when it is just Exporter's. Modules are of course free to write their own import and may gmake them as expensive as they wish.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://671453]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2020-10-24 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?