Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

•Re: A (memory) poor man's hash

by merlyn (Sage)
on Nov 21, 2003 at 17:52 UTC ( #308981=note: print w/ replies, xml ) Need Help??


in reply to A (memory) poor man's <strike>hash</strike> lookup table.

However, loading the same 1 million integers into a hash as keys, with undef as the value requires 95 MB!
I stopped reading there. I don't see your point. Besides storing all the data, you now have a meta-data structure that can tell you rather rapidly if $x is a member of this set you've created, as well as associate another scalar with each of those million keys!

You've got a lot more information than what you started with. You're not merely storing the keys.

If your complaint is that you want to be able to just store the keys, then yes, a hash was a bad choice, as you go on to point out.

But don't fault Perl's hash structure. It's very efficient for the task at hand.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


Comment on •Re: A (memory) poor man's hash
Re: &bull;Re: A (memory) poor man's hash
by BrowserUk (Pope) on Nov 21, 2003 at 19:12 UTC

    I've changed the title of the post to more accurately reflect the intent of the post.

    I thought my opening paragraph(s) made it very clear that I have no "complaint", nor was I " fault<ing> Perl's hash structure" for the vast majority of applications.

    The only application I was suggesting this would be useful for is the "... perhaps the most oft-used use of hashes is as fast lookup tables..." as exampled by the referenced post Memory Management Problem.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!
    Wanted!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-08-20 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (118 votes), past polls