2 ms·
it's difficult to explain everything in a short post, but the type checking part is really a "free extra" that comes from adding type-related metadata that can
by andrewcooke 15y ago
it's difficult to explain everything in a short post, but the type checking part is really a "free extra" that comes from adding type-related metadata that can be used for many other purposes. for example, pytyp can convert between nested json dictionaries and python objects simply by introspecting type annotations. so the motivation was not so much to change the language, but more to explore how type-related annotations could be used in a language like python, in a useful way, without making it something other than python.
in other words, the library is the end result of a process of exploration of some ideas that interested me related to metadata and types in a dynamic language. it's not an attempt to make python like another language, although (of course) it borrows ideas from those languages (because people have already spent a lot of time thinking about how to make a type system orthogonal and elegant).
and because it's dynamic, metadata-based, uses reflection, and works with duck typing, pytyp's type checking is inefficient for global use. it makes more sense as a check when debugging than a global language feature.