Skip to Content
Hands-On Reactive Programming with Python
book

Hands-On Reactive Programming with Python

by Romain Picard
October 2018
Intermediate to advanced
420 pages
10h 26m
English
Packt Publishing
Content preview from Hands-On Reactive Programming with Python

Chapter 6

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Programming with Design Patterns

Python Programming with Design Patterns

James W. Cooper

Publisher Resources

ISBN: 9781789138726Supplemental Content