Name | tf-lazy-loader JSON |
Version |
0.1.1
JSON |
| download |
home_page | |
Summary | Lazy loading of Python modules, based on TensorFlow's LazyLoader util. |
upload_time | 2024-01-02 22:00:51 |
maintainer | |
docs_url | None |
author | Nathan Jones |
requires_python | >=3.10,<4.0 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# tf-lazy-loader
## Installation
```bash
pip install tf-lazy-loader
```
## Usage
```python
from tf_lazy_loader import dynamic_import
# Lazily import the "os" module
os = dynamic_import("os")
# Trigger the actual import by referencing a name in the "os" module:
print(os.environ)
```
### Conditionally switching between lazy and eager imports
You can set the `lazy` arg of the `dynamic_import` function to `False` to eagerly import the given module. This can be useful if you only want to perform lazy imports based on a flag.
For example, if you have a Django project and you only want to enable lazy imports when in DEBUG mode, and do imports eagerly in production, you would do something like this:
```python
from django.conf import settings
DEBUG = settings.DEBUG
os = dynamic_import("os", lazy=DEBUG)
```
Raw data
{
"_id": null,
"home_page": "",
"name": "tf-lazy-loader",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Nathan Jones",
"author_email": "purkinje90@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8a/a2/0d511e50ce9795d8c35756c97fad9ef95ba5cdb207cbc5698f09fc261e61/tf_lazy_loader-0.1.1.tar.gz",
"platform": null,
"description": "# tf-lazy-loader\n\n\n## Installation\n\n```bash\npip install tf-lazy-loader\n```\n\n## Usage\n\n```python\nfrom tf_lazy_loader import dynamic_import\n\n# Lazily import the \"os\" module\nos = dynamic_import(\"os\")\n\n# Trigger the actual import by referencing a name in the \"os\" module:\nprint(os.environ)\n```\n\n### Conditionally switching between lazy and eager imports\n\nYou can set the `lazy` arg of the `dynamic_import` function to `False` to eagerly import the given module. This can be useful if you only want to perform lazy imports based on a flag.\n\nFor example, if you have a Django project and you only want to enable lazy imports when in DEBUG mode, and do imports eagerly in production, you would do something like this:\n\n```python\nfrom django.conf import settings\n\nDEBUG = settings.DEBUG\n\nos = dynamic_import(\"os\", lazy=DEBUG)\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Lazy loading of Python modules, based on TensorFlow's LazyLoader util.",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "af0dd4cc88514ac16d548939665137a44206cb6e59b4bdc84e9eee31b28192fd",
"md5": "082eea4d64d9de2b0df7a5b8a6a6ed8b",
"sha256": "7b2623126274f07158d47e7acfdbf3781916c36ba5a3c4800ca6d01f18887dc1"
},
"downloads": -1,
"filename": "tf_lazy_loader-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "082eea4d64d9de2b0df7a5b8a6a6ed8b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 7212,
"upload_time": "2024-01-02T22:00:50",
"upload_time_iso_8601": "2024-01-02T22:00:50.020695Z",
"url": "https://files.pythonhosted.org/packages/af/0d/d4cc88514ac16d548939665137a44206cb6e59b4bdc84e9eee31b28192fd/tf_lazy_loader-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8aa20d511e50ce9795d8c35756c97fad9ef95ba5cdb207cbc5698f09fc261e61",
"md5": "c3b792036578602cd0deab6f5dbf97b6",
"sha256": "da132676d1dbee56775ef85536d64c43196191c29023425e6567b300f285bce9"
},
"downloads": -1,
"filename": "tf_lazy_loader-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "c3b792036578602cd0deab6f5dbf97b6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 6555,
"upload_time": "2024-01-02T22:00:51",
"upload_time_iso_8601": "2024-01-02T22:00:51.631049Z",
"url": "https://files.pythonhosted.org/packages/8a/a2/0d511e50ce9795d8c35756c97fad9ef95ba5cdb207cbc5698f09fc261e61/tf_lazy_loader-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-02 22:00:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "tf-lazy-loader"
}