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 http://creativecommons.org/licenses/b...
Поделиться в:
Доступные форматы для скачивания:
Скачать видео mp4
Информация по загрузке:
Скачать аудио mp3
Похожие видео
array(10) {
[0]=>
object(stdClass)#4264 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "9OOJcTp8dqE"
["related_video_title"]=>
string(70) "Keynote: Multithreaded Python without the GIL - presented by Sam Gross"
["posted_time"]=>
string(21) "2 года назад"
["channelName"]=>
string(21) "EuroPython Conference"
}
[1]=>
object(stdClass)#4237 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "Lddegb2ToNY"
["related_video_title"]=>
string(73) "Protocols in Python: Why You Need Them - presented by Rogier van der Geer"
["posted_time"]=>
string(21) "2 года назад"
["channelName"]=>
string(21) "EuroPython Conference"
}
[2]=>
object(stdClass)#4262 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "6P68IBou_cg"
["related_video_title"]=>
string(57) "Writing Faster Python 3 - presented by Sebastian Witowski"
["posted_time"]=>
string(21) "2 года назад"
["channelName"]=>
string(21) "EuroPython Conference"
}
[3]=>
object(stdClass)#4269 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "6txNXbY3joU"
["related_video_title"]=>
string(79) "TIA-942 vs Uptime – Choosing the Right Certification for Your Data Center"
["posted_time"]=>
string(21) "1 день назад"
["channelName"]=>
string(24) "EPI Data Centre Services"
}
[4]=>
object(stdClass)#4248 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "dryNwWvSd4M"
["related_video_title"]=>
string(52) "Protocols vs ABCs in Python - When to Use Which One?"
["posted_time"]=>
string(19) "1 год назад"
["channelName"]=>
string(10) "ArjanCodes"
}
[5]=>
object(stdClass)#4266 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "kDDCKwP7QgQ"
["related_video_title"]=>
string(61) "TALK / Luciano Ramalho / Protocol: the keystone of type hints"
["posted_time"]=>
string(21) "4 года назад"
["channelName"]=>
string(8) "PyCon US"
}
[6]=>
object(stdClass)#4261 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "ST33zDM9vOE"
["related_video_title"]=>
string(45) "Talk: Dustin Ingram - Static Typing in Python"
["posted_time"]=>
string(19) "5 лет назад"
["channelName"]=>
string(8) "PyCon US"
}
[7]=>
object(stdClass)#4271 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "Q-97WXKe6H0"
["related_video_title"]=>
string(27) "Оформляем protocol"
["posted_time"]=>
string(21) "7 дней назад"
["channelName"]=>
string(14) "Python Russian"
}
[8]=>
object(stdClass)#4247 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "C7MRkqP5NRI"
["related_video_title"]=>
string(62) "Clean Architectures in Python - presented by Leonardo Giordani"
["posted_time"]=>
string(21) "2 года назад"
["channelName"]=>
string(21) "EuroPython Conference"
}
[9]=>
object(stdClass)#4265 (5) {
["video_id"]=>
int(9999999)
["related_video_id"]=>
string(11) "WhdRmBOW58M"
["related_video_title"]=>
string(204) "«Мы ПОЖАЛЕЕМ о создании искусственного интеллекта»: | Роман Ямпольский, исследователь | «Как теперь»"
["posted_time"]=>
string(19) "2 дня назад"
["channelName"]=>
string(50) "Как теперь / проект ОВД-Инфо"
}
}