DEV Community

Super Kai (Kazuya Ito)
Super Kai (Kazuya Ito)

Posted on

Glossary in Python (1)

Buy Me a Coffee

dynamic type

  • an implicit type always inferred by Python interpreter at runtime.
  • can also be called a runtime type.

generic type

  • the type besed on a generic class, function or type alias to reuse them within a type hint.
  • list, tuple, set, dict, Callable, etc.
  • makes [] required in strict mode in mypy.
  • makes [] optional in unstrict mode in mypy.

generics

  • a feature to create the generic class, function or type alias to reuse them as a generic type within a type hint.

non-union type

  • other type which isn't union type in general.
  • a single type for a type hint because it's not interpreted as Union by Python interpreter at runtime:
    • Python interpreter at runtime is more important program than type checkers at pre-runtime.

pre-runtime

  • the time before runtime to (static) type-check, lint code, etc.
  • can also be called compile time, static analysis time, etc.

runtime

  • the time when Python code is running.
  • can also be called execution time, running time, etc.

special typing form

  • the type to do something special within a type hint.
  • Union, Optional, Concatenate, Literal, etc:
    • UnionType isn't a special typing form.
  • basically makes [] required whether strict mode or not in mypy.
  • I use the term special typing form instead of special form which is used in Python doc because special typing form is more descriptive.

static type

  • an explicitly written optional type hint checked, or a type inferred by type checkers at pre-runtime.
  • can also be called a pre-runtime type.

strict mode

  • checking strictly.

subtype

  • the child type which has parent types as supertypes by extending them:
    • Basically, a subtype is accepted by its supertypes but its supertypes aren't accepted by the subtype. For example, bool is a subtype of int so bool is accepted by int but int isn't accepted by bool.

subtype-like type

  • the type which isn't actually a subtype of other type but the type is accepted by the other type as if the type is a subtype of the other type. For example, bool isn't actually a subtype of complex and float but bool is accepted by them like bool is a subtype of them so bool is a subtype-like type of complex and float.

supertype

  • the parent type which has child types as subtypes by extended by them:
    • Basically, a supertype accepts its subtypes but its subtypes don't accept the supertype. For example, int is a supertype of bool so int accepts bool but bool doesn't accept int.

supertype-like type

  • the type which isn't actually a supertype of other type but the type accepts the other type as if the type is a supertype of the other type. For example, complex isn't actually a supertype of float, int and bool but complex accepts them like complex is a supertype of them so complex is a supertype-like type of float, int and bool.

typed

  • having type hints.

union type

  • union type as the name suggests in general.
  • a set of multiple types for a type hint because it's interpreted as Union by Python interpreter at runtime:
    • Python interpreter at runtime is more important program than type checkers at pre-runtime.

unstrict mode

  • not checking strictly.

untyped

  • not having type hints.

Top comments (0)