Chapter 4. Using Arrays and Collections

WHAT'S IN THIS CHAPTER?

  • Using arrays for simple data storage

  • Using collections for complex data storage

  • Importing and using dictionaries for advanced data management

When you think about it, arrays, collections, dictionaries, and other similar storage structures provide a means to manage related items. Yes, you can stick any data in the data structure, but normally, the data elements are going to have some kind of relation. Arrays and other data management structures are like apartment mailboxes, with an individual mailbox to hold each individual data element.

The difference between data storage structures comes in the complexity of the data they can hold and the data management functionality they provide. An array (the term is used generically here to mean any ordered storage mechanism that follows the rules of arrays) is an older, simplistic storage mechanism that still sees plenty of use precisely because it's so simple. If you only need to hold a list of items, there isn't a good reason to use a more complex data storage mechanism.

As applications increased in complexity, developers also encountered data with greater storage needs. Collections and dictionaries are just two of many storage mechanisms designed to meet these needs (and the only two that IronPython supports directly). Collections introduce the idea of enumerated access, while dictionaries provide an easier method than numbering to locate a particular data element. You'll discover ...

Get Professional IronPython™ now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.