Records and Sets: Selecting the Ideal Data Structure

There are a variety of ways for storing and managing data in your program and the choice of the right data structure has an effect on the readability of your code, ease of writing, and performance. Python has a wide selection of built-in mechanisms that meet most of your data structure needs. This course introduces you to two types of data structures: data records and sets.

There are multiple types and classes for both of these data structures and this course discusses them and provides information on how to choose the right one.

In this course you’ll learn about:

  • What are the advantages of using the built-in dict type as a Data Record
  • What flexibility do DataClasses add for Records compared to regular Classes
  • How to store C-type Data with struct.Struct
  • How to define Sets
  • Where to use a Frozenset
  • How to create a counter with a multiset

This course is the second part of an ongoing series, exploring how to find the right Data Structure for your projects. The first course is Dictionaries and Arrays: Selecting the Ideal Data Structure and the third part is Stacks and Queues: Selecting the Ideal Data Structure.

What’s Included:

Downloadable Resources:

Records and Sets: Selecting the Ideal Data Structure

1 Lesson 3m

Selecting the Ideal Set

1 Lesson 9m

About Christopher Trudeau

Christopher Trudeau Christopher Trudeau

Christopher has a passion for the Python language and writes for Real Python. He is a consultant who helps advise organizations on how to improve their technical teams.

» More about Christopher

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

fairchild on Oct. 23, 2021

A couple months ago I was working on a script that involved character encoding. As part of it, I tried teaching myself re little and big endianness. At the time I only was able to grasp just to the point where it was practical for the project I was working on at the time. Your discussion re here explained it much better than I had previously. Thank you.

« Browse All Courses