Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Symbolic refs aka. dynamic variables again

by eduardo (Curate)
on Apr 24, 2003 at 19:41 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found