... arrays are probably not that much faster than hashes ...
Indeed not. Instead of switching from arrays to hashes you can probably get a similar speed-up by getting some slightly faster hardware — which'll likely be cheaper than what it'd cost in extra development time to have to deal with inappropriate data structures.
... but hashes sure do take up a lot of extra memory with those verbose keys.. particularly if the verbose keys are containing redundant information.
That simply isn't true. Wanting to have several separate hashes with the same keys is a common situation. Indeed it's one the Perl 5 Porters considered, so they explicitly coded to optimize the memory usage: all hash keys are only stored in memory once no matter no many hashes they are used in -- see perl5004delta.
To summarise: use hashes where each key contains some unique information, and use arrays where key names would be duplicated under a hash arrangement.
To summarize: don't try to second-guess Perl, and don't assume that you are cleverer that the Perl 5 Porters.
Smylers
In reply to Re^3: Which, if any, is faster?
by Smylers
in thread Which, if any, is faster?
by rvosa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |