0:00 / 0:00
#typing.protocol#ducktyping#statictyping
`typing.Protocol`: type hints as Guido intended - presented by Luciano Ramalho
EuroPython Conference
36K subscribers • 31 videos on Hallway • Conference channel
- One of the most-watched uploads on EuroPython, a conference or university channel Hallway lists. Nobody has recommended it in the communities yet, so it ranks below community picks.
- Presented by Luciano Ramalho, author of Fluent Python
Intermediate. Assumes working knowledge.
7.1K views4 years ago
Programming languagesPythonLanguage design and type systems
Luciano Ramalho explains how typing.Protocol enables statically checked duck typing in Python, bridging the gap between static and dynamic typing.
EuroPython 2022 - `typing.Protocol`: type hints as Guido intended - presented by Luciano Ramalho [The Auditorium on 2022-07-15] Duck typing and static typing are not opposites. Go is a successful statically checked language with support for duck typing through interfaces that work like `typing.Protocol` does. A `Protocol` subclass defines an interface that past and future classes can implement without any coupling to the interface: they simply provide the required methods. That's statically checked duck typing: a powerful combination! In this talk we'll get back to basics looking at how duck typing is used in Python since the beginning, how `__dunder__` methods leverage that idea to support what we recognize as *Pythonic* code. Then we'll see how `typing.Protocol` fills the gap in the original PEP 484—Type Hints, and finally lets us properly annotate code that leverages the flexibility and loose coupling of duck typing. Finally, we'll look at the experience of the Go community to learn what makes a good Protocol. Spoiler alert: your favorite Python ABC may not be the basis of a useful Protocol! This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License creativecommons.org/licenses/by-nc-sa/4.0/Why it's here
A top upload from a listed channelEuroPython is on Hallway's list of conference and university channels, and this upload is one of its most-watched talks or lectures. Nobody has recommended it in the communities yet, so it ranks below community picks.