Makes lazy modules in a more readable and friendly way.
Project description
lazyr
Creates lazily-imported modules in a more readable and safer way.
A lazily-imported module (or a lazy module, to be short) is not physically loaded in the Python environment until its attributes are being accessed. This could be very useful when you are importing some modules that are hardly used but take a lot of time to be loaded.
Installation
pip install lazyr
Usage
Let pandas be a lazy module, for example:
import lazyr
lazyr.register("pandas") # pandas is a lazy module from now on
import pandas as pd
print(pd)
# Output: LazyModule(pandas, ignore=set())
df = pd.DataFrame # pandas is activated and actually loaded now
print(df)
# Output: <class 'pandas.core.frame.DataFrame'>
There is also a simpler way to create a lazy module, but may cause type hints to lose efficacy:
pd = lazyr.register("pandas")
print(pd)
# Output: LazyModule(pandas, ignore=set())
Wake up a module
The lazy modules are not actually loaded until their attrubutes are imported or used, but sometimes you may want to activate a lazy module without excessing any of its attributes. In this case, you can wake up it like this:
lazyr.wakeup(pd) # pandas is no longer lazy now
See Also
Github repository
PyPI project
License
This project falls under the BSD 2-Clause License.
History
v0.0.2
- Added the feature
lazyr.wakeup.
v0.0.1
- Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lazyr-0.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: lazyr-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
692a16b31b2367dfe02d6261f2986f8b0620a46a26dc5b648dc6be24c572a64c
|
|
| MD5 |
091e931538b923471879b4fdd4ba1328
|
|
| BLAKE2b-256 |
e8a8afbd3d403dc4d53a1d926f61d20d221811123e4f6f531ac144bbfb137f71
|