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]
[Corion]: I found Android Studio quite nice as a Java IDE, but then, I didn't try anything serious with it
[chacham]: it is a nice ide. its just that upgrading it always causes issues with mismatched versions of whatever
[Corion]: chacham: Oh, yes, reinstalling all the SDK versions and Gradle and whatnot, yes, even in the short time I used it (2 weeks?) I felt that pain
[chacham]: right now im editing the versions in the applications gradle file to use a version it wants. sheesh.
[Corion]: Ow, "but you're not supposed to do that" ;)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-03-29 08:02 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (344 votes). Check out past polls.