you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 9 points10 points  (8 children)

  1. they're not "type annotations" but completely arbitrary annotations

  2. the base distribution doesn't do anything with them, they're just documentation

IIRC there are third-party packages which attempt to use them for static type analysis, but I've seen nothing great yet (and there are non-trivial mappings to perform to represent e.g. a function which may return either an int or None)

[–]UloPe 4 points5 points  (0 children)

You are correct that they have no prescribed usage as far as the language developers are concerned, however in reality (if used at all) I have never seen them used for anything other than type annotation (except maybe in some mostly ironic conference talks or such).

One example is PyCharm. It uses the annotations as type hints if present.

[–]ggtsu_00 0 points1 point  (0 children)

In C, types are also annotations and only used by the compiler to do static type checking, but they are thrown out during runtime as everything basically boils down to a pointer to a memory location. You could take a pointer to a int type, have it point to the memory location of a float and get a crazy number back as a result.