Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by merlyn (Sage)
on Nov 21, 2003 at 17:52 UTC ( [id://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.

Replies are listed 'Best First'.
Re: &bull;Re: A (memory) poor man's hash
by BrowserUk (Patriarch) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://308981]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found