When working with containers and collections, we have a multistep design strategy:
- Consider the built-in versions of sequence, mapping, and set.
- Consider the library extensions in the collection module, as well as extras such as heapq, bisect, and array.
- Consider a composition of existing class definitions. In many cases, a list of tuple objects or a dict of lists provides the needed features.
- Consider extending one of the earlier mentioned classes to provide additional methods or attributes.
- Consider wrapping an existing structure as another way to provide additional methods or attributes.
- Finally, consider a novel data structure. Generally, there is a lot of careful analysis available. Start with Wikipedia articles such as this one: http://en.wikipedia.org/wiki/List_of_data_structures.
Once the design alternatives have been identified, there...