Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^4: Could we save the memory occupied by "undef" in an array?

by TimToady (Parson)
on Nov 24, 2008 at 17:30 UTC ( #725649=note: print w/replies, xml ) Need Help??

in reply to Re^3: Could we save the memory occupied by "undef" in an array?
in thread Could we save the memory occupied by "undef" in an array?

Your program is already heavily invested in the performance of hashes. Most objects use hashes as their underlying data structure. Every reference to a package variable results in multiple hash lookups (I think). And every call to a subroutine results in multiple hash lookups (I think).
Well, then, think again. :)

To the first approximation, only packages use hashes for their internal structure, and most package symbol lookups happen only at compile time. (Any stored GV* is post-hash-lookup.) Apart from symbolic references (which are discouraged), the only major operation that historically used hash lookups implicitly at run time was method calls, and I think even that has been heavily optimized these days when the method name is known in advance.

There are other implicit uses of hashes, but these typically come into play only when you start using higher Unicodes characters in patterns, and even there the internals typically try to avoid using the hash in the common cases.

In any event, normal sub calls don't use any implicit hashes. They're already too slow as it is...

Replies are listed 'Best First'.
Re^5: Could we save the memory occupied by "undef" in an array?
by ikegami (Pope) on Nov 24, 2008 at 18:26 UTC
    Thanks for the correction. I can't figure out what lead me to think function lookups were made at run-time.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2016-10-25 04:27 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.