Data Structures: Perl vs Python Ordered Hashes

Jeff Pinyan

DALnet/EFNet #perl

Thursday, 12:00 Noon in Rangos II.

How does one create an ordered hash?  What is the thought process involved, and what data structures are needed inside this ordered hash object?

In this talk, we'll analyze two modules, one in Perl, OrderedHash.pm, and one in Python, OrderedDict.py, and see how to implement an ordered associative array (for a nice general term) structure.  Python is more object-oriented by default, so an OrderedDict object appears to be just like an array or a dictionary.  In OrderedHash.pm, I keep an OO approach (for a tying interface, look at GS's Tie::IxHash), and so it is more apparent that there is magic going on underneath.

As an added bonus, we'll look at a module that binds an array and a hash for a read-only approach to ordered hashes, ArrayHash.pm.  Unlike MJD's ArrayHashMonster.pm, ArrayHash.pm is based on mucking around with the symbol table so that it /appears/ that an array and a hash are really the same thing.
 

Next | Previous | Author list | Schedule | YAPC 19100