Selecting the right data structure

Selecting the right data structure can have a profound impact on the performance of a program. If your program requires you to spend considerable time on lookups, use a dictionary, if feasible. When all that you need is to traverse over a collection, prefer lists over dictionaries because dictionaries take up more space. When your data is immutable, prefer tuples over lists because tuples can be traversed faster than lists.

Get Tkinter GUI Application Development Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.