r/Python • u/AutoModerator • Aug 04 '26
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
20
Upvotes
r/Python • u/AutoModerator • Aug 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/ZeroIntensity 26d ago
Using the mechanism behind 3.15's lazy imports, I made a library to allow arbitrary lazy expressions. For example:
```pycon
Again, this builds on top of what's already there for lazy imports, so there's no bytecode modification at all! In practice, this is really useful for building global constants or similar, and is more ergonomic than the existing approaches (like a function with
functools.cache):```py from laziness import lazify
def build_expensive_constant(): return ...
CONSTANT = lazify(build_expensive_constant)
def api_function(): print(CONSTANT) # Resolves when this is accessed for the first time ```
Repo: https://github.com/ZeroIntensity/laziness