Skip to main content

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

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.

Changelog

1.5.0 (2020-06-05)

  • Added support for __fspath__.

  • Dropped support for Python 3.4.

1.4.3 (2019-10-26)

  • Added binary wheels for Python 3.8.

  • Fixed license metadata.

1.4.2 (2019-08-22)

  • Included a pyproject.toml to allow users install the sdist with old python/setuptools, as the setuptools-scm dep will be fetched by pip instead of setuptools. Fixes #30.

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 setup.py 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 MANIFEST.in).

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.

Metadata

Release files for lazy-object-proxy 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lazy-object-proxy 1.5.0
File Size Uploaded
lazy-object-proxy-1.5.0.tar.gz 35.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lazy-object-proxy 1.5.0
File
lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
lazy_object_proxy-1.5.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64 Details
lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64 Details

Total release size: 557.1 kB

Release files / lazy-object-proxy-1.5.0.tar.gz

Download URL lazy-object-proxy-1.5.0.tar.gz
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0aed261060cd0372abf08d16399b1224dbb5b400312e6b00f2b23eabe1d4e96
BLAKE2b-256 checksum
How to use checksums
f25e36a324082c534512b94ed1ddc9d0ee522fddd70f85ec6ca178c6bf6651f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl

Download URL lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl
Size 21.4 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
35c3ad7b7f7d5d4a54a80f0ff5a41ab186237d6486843f8dde00c42cfab33905
BLAKE2b-256 checksum
How to use checksums
0c5be5d7acfc3886ef608aa448d2cd326a87aa4b2c53a36765a91a7bdeab6644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp38-cp38-win32.whl

Download URL lazy_object_proxy-1.5.0-cp38-cp38-win32.whl
Size 19.0 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
da82b2372f5ded8806eaac95b19af89a7174efdb418d4e7beb0c6ab09cee7d95
BLAKE2b-256 checksum
How to use checksums
d9ffef488f2e73ee6db44cd3a5e798a1842acb20b1587674e33ea7e465d9d0af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl
Size 59.6 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a6052c4c7d95de2345d9c58fc0fe34fff6c27a8ed8550dafeb18ada84406cc99
BLAKE2b-256 checksum
How to use checksums
378579099051446e3a615d3977ea81fa6245f62e061e60fcd3d63c19b8346d5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl

Download URL lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl
Size 21.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0aef3fa29f7d1194d6f8a99382b1b844e5a14d3bc1ef82c3b1c4fb7e7e2019bc
BLAKE2b-256 checksum
How to use checksums
4d1c5d85076eaf6d105f2ce7c1b8440372f51146f40dd35977d135d5c155b95c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl

Download URL lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl
Size 18.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
311c9d1840042fc8e2dd80fc80272a7ea73e7646745556153c9cda85a4628b18
BLAKE2b-256 checksum
How to use checksums
7a9dba4f06c946d95659acc6f38f45820b13e84b4a7514a79ffccfaa310219d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl
Size 57.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
161a68a427022bf13e249458be2cb8da56b055988c584d372a917c665825ae9a
BLAKE2b-256 checksum
How to use checksums
a0cb179c709fda5d99f8ddc1abd98b6300d98c8d1fce20aa73ab56545f10d1bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl
Size 19.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
159ae2bbb4dc3ba506aeba868d14e56a754c0be402d1f0d7fdb264e0bdf2b095
BLAKE2b-256 checksum
How to use checksums
a9754bac9e82b17048343b23bbe087d3e3571047d3fb08090a04f6cc5a082b74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl

Download URL lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl
Size 21.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
4a50513b6be001b9b7be2c435478fe9669249c77c241813907a44cda1fcd03f4
BLAKE2b-256 checksum
How to use checksums
0dd56ecf8929b64a4024d3217f05216da33c2fc086f2212ab854b54da02c2c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl

Download URL lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl
Size 18.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
dd89f466c930d7cfe84c94b5cbe862867c88b269f23e5aa61d40945e0d746f54
BLAKE2b-256 checksum
How to use checksums
a83e8885c18abba02bf709b54292a2c907c792ff7d6059cfb9f026b630b1377e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl
Size 56.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
459ef557e669d0046fe2b92eb4822c097c00b5ef9d11df0f9bd7d4267acdfc52
BLAKE2b-256 checksum
How to use checksums
cd2f68176f910e32eec13d2db184442fe2242d067ce5abe4c095ff3a95d34907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl

Download URL lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl
Size 21.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
cbf1354292a4f7abb6a0188f74f5e902e4510ebad105be1dbc4809d1ed92f77e
BLAKE2b-256 checksum
How to use checksums
c287790229ad22bf91555373daf0ea6d80f9315057bb02b2f3560f1c72b7e475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl

Download URL lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl
Size 18.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
2d58f0e6395bf41087a383a48b06b42165f3b699f1aa41ba201db84ab77be63d
BLAKE2b-256 checksum
How to use checksums
460b892b7a0344807c82d1f7e69db4abd93db89f2892563cffa5185d183babbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl
Size 56.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
51035b175740c44707694c521560b55b66da9d5a7c545cf22582bc02deb61664
BLAKE2b-256 checksum
How to use checksums
da3eff0811bd7f6d1847f3e21000b2a072ccdf136ccca8159e68f28281c9f9b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl
Size 55.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
96f2cdb35bdfda10e075f12892a42cff5179bbda698992b845f36c5e92755d33
BLAKE2b-256 checksum
How to use checksums
f31f3e31313f557e0b97bd8f9716f502fa85c5fef181f582f816a4796b8f9ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl

Download URL lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl
Size 19.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e3183fbeb452ec11670c2d9bfd08a57bc87e46856b24d1c335f995239bedd0e1
BLAKE2b-256 checksum
How to use checksums
e5879e409a297f41bf3542990c9bd6984462bc4b7208114cf9f0abe0bb502449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl

Download URL lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl
Size 17.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e9a571e7168076a0d5ecaabd91e9032e86d815cca3a4bf0dafead539ef071aa5
BLAKE2b-256 checksum
How to use checksums
a2fbb3ad4515aef5d423fbd6864c0390f5eb604c6623e9afbac88b900a02ee2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release files / lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl

Download URL lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl
Size 19.6 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
ec6aba217d0c4f71cbe48aea962a382dedcd111f47b55e8b58d4aaca519bd360
BLAKE2b-256 checksum
How to use checksums
75d5837744b46b09b593f27568b978e3a7bea46177ca9754ddaba483b7cb309c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.3

Release history Release notifications | RSS feed

1.8.0

19 release files

1.7.1

37 release files

1.7.0

37 release files

1.6.0

22 release files

1.5.2

24 release files

1.5.1

22 release files

This release

1.5.0 This release

18 release files

1.4.3

21 release files

1.4.2

18 release files

1.4.1

18 release files

1.2.2

16 release files

1.2.1

11 release files

1.2.0

7 release files

1.1.0

7 release files

1.0.2

7 release files

1.0.1

7 release files

1.0.0

7 release files

0.1.0

7 release files

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page