A fast and thorough lazy object proxy.
Python C Batchfile
Latest commit 7033131 Nov 18, 2016 @ionelmc Styling.
Permalink
Failed to load latest commit information.
ci Upgrade skel. Aug 11, 2016
docs Oops. Apr 14, 2016
src/lazy_object_proxy Bump version: 1.2.1 → 1.2.2 Apr 14, 2016
tests Fix assertions. Nov 18, 2016
.bumpversion.cfg Bump version: 1.2.1 → 1.2.2 Apr 14, 2016
.cookiecutterrc Upgrade skel. Aug 11, 2016
.coveragerc Upgrade skel. Aug 11, 2016
.editorconfig Upgrade skel. Apr 14, 2016
.gitignore Upgrade skel. Aug 11, 2016
.travis.yml Fix env names. Apr 14, 2016
AUTHORS.rst Fix url. Apr 13, 2016
CHANGELOG.rst Update changelog. Apr 13, 2016
CONTRIBUTING.rst Upgrade skel. Apr 14, 2016
LICENSE Upgrade skel. Apr 14, 2016
MANIFEST.in Upgrade skel. Apr 14, 2016
README.rst Add example. Closes #17. Nov 18, 2016
appveyor.yml Fix expr. Apr 14, 2016
setup.cfg Fix env names. Apr 14, 2016
setup.py Styling. Nov 18, 2016
tox.ini Upgrade skel. Aug 11, 2016

README.rst

Overview

docs Documentation Status
tests
package PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported implementations

A fast and thorough lazy object proxy.

  • Free software: BSD 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:

def expensive_func():
    # create expensive object
    return stuff

obj = lazy_object_proxy.Proxy(expensive_func)
# function is called only when object is actually used
print(obj.foobar)  # now expensive_func is called

Installation

pip install lazy-object-proxy

Documentation

https://python-lazy-object-proxy.readthedocs.io/

Development

To run the all tests run:

tox

Acknowledgements

This project is based on some code from wrapt as you can see in the git history.