in reply to
RE: RE: RE: RE: My views on pseudohashes
in thread My views on pseudohashes
Array access is faster than hash access. Yes, with a good hashing algorithm, access is O(1), but it'll never be as fast as array index access. You still have to pay the overhead of the hashing algorithm. There's also the increased memory requirement.
Of course, with arrays you either use numbers for indexes or constants. That's a bit of trouble to go to either way, and with constants you still have some memory overhead.
Let's not forget autovivification of hash keys. That could bite you when you least expect it.
The pseudo-hash tries to solve all of those. Yes, it's a little more complex than your average array, but you can access it either way, and it's faster than a hash, doesn't autovivify keys, and it allows you to refer to values by name instead of by index.
See perlref for more information, as well as the documentation for fields.pm. (I learned about them from Object Oriented Perl, a fine book.)