In contrast to variable declarations in statically typed languages, the goal of annotation syntax is to provide an easy way to specify structured type metadata for third party tools and libraries via the abstract syntax tree and the annotations attribute.
Python中的静态类型并不能使其成为编译的编程语言。因此,在性能方面,您应该总是从Cython获得更好的性能(编译应该总是优于解释的)。在
Python新添加的静态类型的主要目的是通过牺牲Python的一些哲学思想来无缝地执行类型检查。在
简而言之,:Cython表示速度,Python3.6表示解释/更多python方法。在
任何现有版本的CPython、3.7或更早版本中都没有静态类型。在
cpython3.6(也后移植到3.5)中对可选类型注释的支持有助于外部工具(如静态代码分析器)验证类型在程序中的一致性。在
类型提示对字节码编译或执行没有影响。
来自CPython 3.6 What's new:
注意,在Cython中可以使用类型暗示语法来定义C类型(Type Declaration Syntax)。在
相关问题 更多 >
编程相关推荐