Skip to content

KOLANICH-libs/lazily.py

Repository files navigation

lazily.py Unlicensed work

GitLab Build Status PyPi Status GitLab Coverage Libraries.io Status Code style: antiflash

We have moved to https://codeberg.org/KOLANICH-libs/lazily.py (the namespace has changed to KFmts, which groups packages related to parsing or serialization), grab new versions there.

Under the disguise of "better security" Micro$oft-owned GitHub has discriminated users of 1FA passwords while having commercial interest in success and wide adoption of FIDO 1FA specifications and Windows Hello implementation which it promotes as a replacement for passwords. It will result in dire consequencies and is competely inacceptable, read why.

If you don't want to participate in harming yourself, it is recommended to follow the lead and migrate somewhere away of GitHub and Micro$oft. Here is the list of alternatives and rationales to do it. If they delete the discussion, there are certain well-known places where you can get a copy of it. Read why you should also leave GitHub.


Imports lazily. Supports hooks.

Useful when some long loading packages are optional to use by your app, so you don't want to spend time on loading them every time. The arguments are the same as in importlib.import_module.

Requirements

  • lazy_object_proxy PyPi Status Libraries.io Status It hooks into cpython and can catch more kinds of actual using of the object than any pure python implementation.
import freeLunch # ModuleNotFoundError: No module named 'freeLunch'
from lazily import freeLunch

freeLunch.consume() # ModuleNotFoundError: No module named 'freeLunch'

There is a hooks mechanics, but it is a bit broken, don't use for now:

import lazily
def bar():
	raise ImportError("There ain't no such thing as a free lunch.")
lazily.hooks["freeLunch"] = bar
freeLunch = lazily.lazily("freeLunch")

freeLunch.consume() # ImportError: There ain't no such thing as a free lunch.

Obviously, * in fromlist is UB, as it relies on __all__, so _bootstrap.py in CPython impl tries to read it.

About

A module to import lazily using lazy_object_proxy

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages