Hacker News new | past | comments | ask | show | jobs | submit login
Python Lazy Imports with Cinder (facebook.com)
3 points by jamesfinlayson on Sept 20, 2022 | hide | past | favorite | 2 comments



I was super interested until I got to the end of the article. The considerable list of gotchas is downright nasty.

One example:

* Applying type annotations may inadvertently defeat Lazy Imports.

- Modules should use from __future__ import annotations

- Use string type annotations for typing.TypeVar() and typing.NewType()

- Wrap type aliases inside a TYPE_CHECKING conditional block

https://github.com/facebookincubator/cinder/blob/cinder/3.8/...

Caveat emptor (buyer beware).

Python at scale doesn't sound fun at all. Having so many opaque required conventions would suck.


Yeah I thought that was a bit odd but guess types are in modules too.

I have done much Python type hinting besides the integral types and I guess they shouldn't cause any issues with lazy importing.




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

Search: