5.1.1 Types
Python’s support for types is unusual in three major ways:
- Precise type checking encourages the specific use of type
declarations as a form of run-time consistency checking. This
speeds development by localizing type errors and giving more
meaningful error messages. See precise-type-checks. Python
produces completely safe code; optimized type checking maintains
reasonable efficiency on conventional hardware
(see type-check-optimization.)
- Comprehensive support for the Common Lisp type system makes complex
type specifiers useful. Using type specifiers such as
or
and
member
has both efficiency and robustness advantages.
See advanced-type-stuff.
- Type inference eliminates the need for some declarations, and
also aids compile-time detection of type errors. Given detailed
type declarations, type inference can often eliminate type checks
and enable more efficient object representations and code sequences.
Checking all types results in fewer type checks. See sections
type-inference and non-descriptor.