First we would have to answer WHY we would want to pack a hash (You probably meant 'pack' as in 'compress' or 'zip', right? The perl function pack has a different purpose than compression).
It would have the following advantage:
1. You could keep those few applications unchanged that are so big that they don't fit into memory anymore but that would still fit if compressed by about 5 to 50% (the usual compression rate of general compression algorithms, assuming you even could reach that with a hash compression, which is very doubtful). Most people would tell you to buy more RAM instead or adapt your algorithm/data structure
... and the following disadvantages
1. A compressed hash isn't a hash anymore, before accessing it you would have to uncompress it. You couldn't use $hash{'bla'} anymore. So you add a lot of inconvenience to the handling of hashes for the programmer
2. Uncompressing takes time. More than the time it takes to access a hash, so we are talking about a speed penalty of more than 100%. For a few free bytes more the hashes are seriously slower now.
3. Compressing algorithms don't guarantee compression. So even if you had a program that just needed 5% compression to fit into memory you never could be sure that your compressed hash could deliver it. With the "wrong" data your compression rate could be 0.
4.
In reply to Re: Packing hashes or complex structures?
by jethro
in thread Packing hashes or complex structures?
by theantler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |