Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by TimToady (Parson)
on Nov 24, 2008 at 17:30 UTC ( [id://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 (Patriarch) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found