最新的打字文档 https://docs.python.org/3/library/typing.html有很多弃用通知,如下所示:
class typing.Deque(deque, MutableSequence[T])
A generic version of collections.deque.
New in version 3.5.4.
New in version 3.6.1.
Deprecated since version 3.9: collections.deque now supports []. See PEP 585 and Generic Alias Type.
这意味着什么?我们不应该使用泛型类型吗Deque
(以及其他几个)了?我查看了参考资料,但没有将这些点联系起来(可能是因为我是中级 Python 用户)。
这意味着您应该过渡到使用标准库中的内置类型/类型,而不是由typing
。例如collections.deque[int]
代替typing.Deque[int]
。同样对于list
, tuple
等等。所以tuple[int, str]
是首选方式。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)