What are the benefits of using named tuples instead of dictionaries to define operators item types?
There are three benefits of using named tuples compared to dictionaries:
- The first is the fact that the named tuples fields can be accessed with a dot notation instead of a dictionary square-bracket-style notation. The dot notation is easier to read and write than the square bracket notation. This makes the code easier to follow.
- The second is the fact that named tuples are more efficient than dictionaries at accessing their fields. This may have a beneficial impact on performance in an application that uses such objects widely.
- The last is the fact that named tuples are immutable. Object immutability is one of the principles used ...