It is stated (for example, in Mastering Algorithms with Perl) that it's about 30% faster to store data in an array than in a hash, and about 20% faster to retrieve data from an array than from a hash. More or less it is what you are getting with your own benchmark
A simple explanation would be that this happens because the subscript in an array tells Perl where to find that value in memory, while a hash must first convert its key into a hash value.
citromatik
In reply to Re: datastructure of array and hash?
by citromatik
in thread datastructure of array and hash?
by cool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |