Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Symbolic refs aka. dynamic variables again

by eduardo (Curate)
on Apr 24, 2003 at 19:41 UTC ( #252978=note: print w/ replies, xml ) Need Help??

in reply to Symbolic refs aka. dynamic variables again

Ok. I'm confused. I hope one of the more knowledgable internals monks is able to explain why storing a variable in the symbol table is so much more expensive than in a hash. My gut instinct is that it has something to do with the fact that storing something in the symbol table involves more overhead due to reserving a GLOB or something along those lines, but I just tested it on my box, and it's 3 times the memory for a symbolic ref than it is for a hash value. Is it something along those lines, is the fact that the container is the symbol table instead of an actual "container object" causing perl to do more work that a pedestrian monk such as myself wouldn't usually encounter? Am I at least on the right track?

Comment on Re: Symbolic refs aka. dynamic variables again
Replies are listed 'Best First'.
Re: Re: Symbolic refs aka. dynamic variables again
by grantm (Parson) on Apr 24, 2003 at 19:57 UTC

    I'm not going to pretend deep knowledge of Perl internals, but the typeglob structure allocates sufficient space to point to ...

    • a scalar value - $foo
    • an array value - @foo
    • a hash value - %foo
    • a subroutine - &foo
    • a filehandle - foo
    • a format - foo

    Whereas each hash key points directly to a scalar value (SV)

      you forgot one slot in the glob, the glob itself - *foo

      ~Particle *accelerates*

        Globs are not Klein bottles. There is no slot in a glob for the glob.

        (Aristotle noted that I spelled "Klein" wrong)

Re: Re: Symbolic refs aka. dynamic variables again
by perrin (Chancellor) on Apr 24, 2003 at 19:46 UTC
    Well, for one thing, variables in the symbol table are globals. It has long been known that lexically-scoped (my) variables use less memory than globals because they don't have to do as much.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-10-07 02:53 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls