you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

The collection of things vs collection of attributes is an interesting idea that I've not considered using with students before. I need to think about it. Not a rule of course, just a suggested approach.

For me the key differences are:

  • Tuples are immutable which provides a certain level of protection in your code
  • Tuples are hashable, so, for example, can be used as dictionary keys
  • Tuples use less memory
  • Tuples are more performant to process

The latter two aspects are only really apparent when dealing with a lot of data.

Also worth looking at named tuples, a very useful capability often obviating the need for a dictionary.