- revealtype can be used during the type checking
- hack for preventing unnecessary module imports
- how should type of lrucache be defined
- The Mypy Blog: Mypy 0.700 Released: Up To 4x Faster
TODO revealtype can be used during the type checking
reveal_type(a) # N: Revealed type is 'builtins.int'
Type annotation will require importing modules that you wouldn't need to import without it. However there is now a workaround (quote the name and import in a dead if):
if False: from bar_module import bar def foo(a: 'bar'): pass
from typing import TYPE_CHECKING, TypeVar if TYPE_CHECKING: F = TypeVar('F', Callable) def lru_cache(f: F) -> F: pass else: from functools import lru_cache
We are now shipping a mypy binary compiled with mypyc by default, which is up to 4x faster than the interpreted version shipped previously. The compiled version has been available as a separate PyPI distribution for a while now, and this is first release where it’s installed by default. Mypyc is a compiler that compiles type-annotated Python modules into efficient CPython C extension modules.