Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> In Python, type annotations have no impact on runtime behavior

That's true of any "scripting" language types.

E.g. TypeScript

  const x: number = 0n; // still is a bigint
Granted, in both the Python and the TypeScript example, the type checker will complain at your incorrect type annotation.


But in Python the type checker does not complain about `x: float = 0`, because for the purpose of type checking (but not at runtime), `int` is considered a subtype of `float`: https://typing.python.org/en/latest/spec/special-types.html#...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: