Common Lisp has a very powerful type system, but conventional Common Lisp
implementations typically only recognize the small set of types
special in that implementation. In these systems, there is an
unfortunate paradox: a declaration for a relatively general type like
fixnum will be recognized by the compiler, but a highly
specific declaration such as
(integer 3 17) is totally
This is obviously a problem, since the user has to know how to specify the type of an object in the way the compiler wants it. A very minimal (but rarely satisfied) criterion for type system support is that it be no worse to make a specific declaration than to make a general one. Python goes beyond this by exploiting a number of advantages obtained from detailed type information.
Using more restrictive types in declarations allows the compiler to do better type inference and more compile-time type checking. Also, when type declarations are considered to be consistency assertions that should be verified (conditional on policy), then complex types are useful for making more detailed assertions.
Python “understands” the list-style
function, array and number type specifiers. Understanding
For related information, see numeric-types for numeric types, and section array-types for array types.