Am 20.04.2021 um 19:03 schrieb Mark Shannon:
PEP 544 supports structural typing, but to declare a structural type
you must inherit from Protocol.
That smells a lot like nominal typing to me.
I'm not sure what inheriting from Protocol has to do with nominal
typing, even though I would personally prefer to have a separate keyword
for declaring protocols. But current typing philosophy is to prefer
structural over nominal typing:
* Use abstract types like "Iterable" or "Sequence" over concrete types
list "list".
* Use protocols instead of instances where it makes sense (although
pragmatism very often means using an existing concrete class instead
of defining a protocol).
* We are slowly replacing typing.IO et al. with more restricted protocols.
Personally I think that the typing infrastructure should move even more
towards structural typing than it does at the moment and there is
certainly a lot of room to grow. But overall I feel that typing is
moving towards allowing more duck typing than it does at the moment.
- Sebastian
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/4SDOHDJENVLNDZVJYZN47JSHWJMN4SHV/
Code of Conduct: http://python.org/psf/codeofconduct/