`typing.Protocol`: type hints as Guido intended - presented by Luciano Ramalho

  Рет қаралды 6,737

EuroPython Conference

EuroPython Conference

Күн бұрын

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...

Пікірлер
Keynote: Multithreaded Python without the GIL - presented by Sam Gross
53:26
EuroPython Conference
Рет қаралды 20 М.
Protocols in Python: Why You Need Them - presented by Rogier van der Geer
28:40
EuroPython Conference
Рет қаралды 11 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Carl Meyer - Type-checked Python in the real world - PyCon 2018
32:10
Writing Faster Python 3 - presented by Sebastian Witowski
42:05
EuroPython Conference
Рет қаралды 17 М.
Pythonic type hints with typing.Protocol - Luciano Ramalho
46:59
What happens when you import a module? - presented by Reuven M. Lerner
29:07
EuroPython Conference
Рет қаралды 4,2 М.
Clean Architectures in Python - presented by Leonardo Giordani
47:48
EuroPython Conference
Рет қаралды 27 М.
Rant: Entity systems and the Rust borrow checker ... or something.
1:01:51
"Python Performance Matters" by Emery Berger (Strange Loop 2022)
38:51
Strange Loop Conference
Рет қаралды 80 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
When Python Practices Go Wrong - Brandon Rhodes - code::dive 2019
1:00:51
code::dive conference
Рет қаралды 97 М.
Protocol Or ABC In Python - When to Use Which One?
23:45
ArjanCodes
Рет қаралды 206 М.