Skip to main content

A fast and thorough lazy object proxy.

Project description

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.


import lazy_object_proxy

def expensive_func():
    from time import sleep
    print('starting calculation')
    # just as example for a very slow computation
    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


pip install lazy-object-proxy


To run the all tests run:



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


1.4.1 (2019-05-10)

  • Fixed wheels being built with -coverage cflags. No more issues about bogus cext.gcda files.
  • Removed useless C file from wheels.
  • Changed to use setuptools-scm.

1.4.0 (2019-05-05)

  • Fixed __mod__ for the slots backend. Contributed by Ran Benita in #28.
  • Dropped support for Python 2.6 and 3.3. Contributed by “hugovk” in #24.

1.3.1 (2017-05-05)

  • Fix broken release (sdist had a broken

1.3.0 (2017-05-02)

  • Speed up arithmetic operations involving cext.Proxy subclasses.

1.2.2 (2016-04-14)

  • Added manylinux wheels.
  • Minor cleanup in readme.

1.2.1 (2015-08-18)

  • Fix a memory leak (the wrapped object would get bogus references). Contributed by Astrum Kuo in #10.

1.2.0 (2015-07-06)

  • Don’t instantiate the object when __repr__ is called. This aids with debugging (allows one to see exactly in what state the proxy is).

1.1.0 (2015-07-05)

  • Added support for pickling. The pickled value is going to be the wrapped object without any Proxy container.
  • Fixed a memory management issue in the C extension (reference cycles weren’t garbage collected due to improper handling in the C extension). Contributed by Alvin Chow in #8.

1.0.2 (2015-04-11)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lazy-object-proxy, version 1.4.1
Filename, size & hash File type Python version Upload date
lazy_object_proxy-1.4.1-cp27-cp27m-macosx_10_13_x86_64.whl (19.3 kB) View hashes Wheel cp27
lazy_object_proxy-1.4.1-cp27-cp27mu-manylinux1_x86_64.whl (50.3 kB) View hashes Wheel cp27
lazy_object_proxy-1.4.1-cp27-cp27m-win32.whl (17.5 kB) View hashes Wheel cp27
lazy_object_proxy-1.4.1-cp27-cp27m-win_amd64.whl (19.0 kB) View hashes Wheel cp27
lazy_object_proxy-1.4.1-cp34-cp34m-manylinux1_x86_64.whl (49.6 kB) View hashes Wheel cp34
lazy_object_proxy-1.4.1-cp34-cp34m-win32.whl (17.3 kB) View hashes Wheel cp34
lazy_object_proxy-1.4.1-cp34-cp34m-win_amd64.whl (18.8 kB) View hashes Wheel cp34
lazy_object_proxy-1.4.1-cp35-cp35m-manylinux1_x86_64.whl (49.7 kB) View hashes Wheel cp35
lazy_object_proxy-1.4.1-cp35-cp35m-win32.whl (18.7 kB) View hashes Wheel cp35
lazy_object_proxy-1.4.1-cp35-cp35m-win_amd64.whl (20.9 kB) View hashes Wheel cp35
lazy_object_proxy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (49.7 kB) View hashes Wheel cp36
lazy_object_proxy-1.4.1-cp36-cp36m-win32.whl (18.7 kB) View hashes Wheel cp36
lazy_object_proxy-1.4.1-cp36-cp36m-win_amd64.whl (20.9 kB) View hashes Wheel cp36
lazy_object_proxy-1.4.1-cp37-cp37m-macosx_10_13_x86_64.whl (19.2 kB) View hashes Wheel cp37
lazy_object_proxy-1.4.1-cp37-cp37m-manylinux1_x86_64.whl (49.8 kB) View hashes Wheel cp37
lazy_object_proxy-1.4.1-cp37-cp37m-win32.whl (18.7 kB) View hashes Wheel cp37
lazy_object_proxy-1.4.1-cp37-cp37m-win_amd64.whl (20.9 kB) View hashes Wheel cp37
lazy-object-proxy-1.4.1.tar.gz (34.8 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page