Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

•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.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2023-09-30 06:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found