/
Depends on
- dh-python (dh-sequence-python3, pybuild-plugin-pyproject)
- pytest (python3-pytest)
- python-django (python3-django)
- python-pytest-benchmark (python3-pytest-benchmark)
- python3-defaults (python3-all, python3-all-dev)
- setuptools (python3-setuptools)
- setuptools-scm (python3-setuptools-scm)
- debhelper-compat
Used by
README (full)
Overview
:target: https://readthedocs.org/projects/python-lazy-object-proxy/ :alt: Documentation Status
:alt: GitHub Actions Build Status :target: https://github.com/ionelmc/python-lazy-object-proxy/actions
:alt: Coverage Status :target: https://coveralls.io/github/ionelmc/python-lazy-object-proxy?branch=master
:alt: Coverage Status :target: https://app.codecov.io/github/ionelmc/python-lazy-object-proxy
:alt: PyPI Package latest release :target: https://pypi.org/project/lazy-object-proxy
:alt: PyPI Wheel :target: https://pypi.org/project/lazy-object-proxy
:alt: Supported versions :target: https://pypi.org/project/lazy-object-proxy
:alt: Supported implementations :target: https://pypi.org/project/lazy-object-proxy
:alt: Commits since latest release :target: https://github.com/ionelmc/python-lazy-object-proxy/compare/v1.12.0...master
A fast and thorough lazy object proxy.
Free software: BSD 2-Clause License
Note that this is based on wrapt's ObjectProxy with one big change: it calls a function the first time the proxy object is used, while `wrapt.ObjectProxy` just forwards the method calls to the target object.
In other words, you use `lazy-object-proxy` when you only have the object way later and you use `wrapt.ObjectProxy` when you want to override few methods (by subclassing) and forward everything else to the target object.
Example::
import lazy_object_proxy
def expensive_func(): from time import sleep print('starting calculation') # just as example for a very slow computation sleep(2) print('finished calculation') # return the result of the calculation return 10
obj = lazy_object_proxy.Proxy(expensive_func) # function is called only when object is actually used print(obj) # now expensive_func is called
print(obj) # the result without calling the expensive_func
Installation
pip install lazy-object-proxy
You can also install the in-development version with::
pip install https://github.com/ionelmc/python-lazy-object-proxy/archive/master.zip
Documentation
https://python-lazy-object-proxy.readthedocs.io/
Development
To run all the tests run::
tox
Acknowledgements
This project is based on some code from wrapt as you can see in the git history.
| dir | .github/ |
| dir | ci/ |
| dir | debian/ |
| dir | docs/ |
| dir | src/ |
| dir | tests/ |
| file | .bumpversion.cfg |
| file | .cookiecutterrc |
| file | .coveragerc |
| file | .editorconfig |
| file | .git-archival.txt |
| file | .gitattributes |
| file | .gitignore |
| file | .pre-commit-config.yaml |
| file | .readthedocs.yml |
| file | .taplo.toml |
| file | AUTHORS.rst |
| file | CHANGELOG.rst |
| file | CONTRIBUTING.rst |
| file | LICENSE |
| file | README.rst |
| file | SECURITY.md |
| file | pyproject.toml |
| file | pytest.ini |
| file | setup.py |
| file | tox.ini |