About this video

An investigation into why Python tuples exist when they look almost identical to lists. Chuck creates both, confirms their types differ, and identifies the core distinction: tuples are immutable, meaning their values cannot be changed, while lists are mutable — demonstrated by successfully reassigning an item in a list and getting an error when trying the same with a tuple. Dissatisfied with that answer alone, he digs further and finds a speed advantage: using the timeit tool to create 1 million of each, a list took 1.43 seconds while a tuple took 0.13 seconds, which he attributes to storage — mutable lists need two blocks of memory to allow changes, while tuples fit in one block because they will not change. He then covers use cases: lists suit homogeneous data you may add to, change, or remove, such as lists of names, while tuples suit heterogeneous grouped data, such as a record combining a name, a subscriber count, and video types, and they appear in SQL library results and function returns. He finishes with quirks: tuples can be unpacked into multiple variables at once, a comma alone — not parentheses — is what actually creates a tuple, and tuples and lists can be converted into and nested inside each other.

Key takeaways

  • The core difference is mutability: lists can be changed after creation, tuples cannot
  • Tuples are faster to create — in his timeit test of 1 million, 0.13 seconds versus 1.43 seconds for lists
  • Tuples are faster because their fixed contents are stored in one block of memory, unlike mutable lists
  • Use lists for homogeneous data that may change, and tuples for heterogeneous grouped records and read-once data
  • A trailing comma, not parentheses, is what makes a tuple, and tuples can be unpacked into several variables at once

Episode details: published February 23, 2023 · 7:28 long. Summary written by Self Growth Videos from the episode itself. Business results and any income figures mentioned are NetworkChuck’s own claims, shared for education — they are not typical or guaranteed.


← Previous: The Best PC I Have Ever Built! · Next: You NEED to learn Machine Learning, RIGHT NOW!! →

All NetworkChuck videos · NetworkChuck profile · NetworkChuck on YouTube

Sister brand · Vacation Club Promo

All-inclusive resort stays from $435

Qualified couples: promotional Mexico and Caribbean packages at real resorts. Short presentation during your stay — enjoy the rest of the trip.

Qualifications apply · presentation during stay · no purchase required

Subscribe YouTube Suggest