Keep It Simple, Stupid | |
PerlMonks |
Re: Array vs. Hash for sparsely integer-indexed databy flexvault (Monsignor) |
on Jan 25, 2013 at 19:11 UTC ( [id://1015392]=note: print w/replies, xml ) | Need Help?? |
I'm sure you'll get more technical answers, but I use hashes now even when the indexing is sequential. The ability to use 'defined' or 'exists' to see if the key is present greatly improves the speed of lookups. And think of the storage benefits, since if you do the following:
The array will use 101 ( 0..100 ) locations and the hash will allocate 8 (hashes are allocated in powers of 2). But why not 'benchmark' it for yourself for your exact situation and know for sure :-) Good Luck...Ed "Well done is better than well said." - Benjamin Franklin
In Section
Seekers of Perl Wisdom
|
|