Skip to main content

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:

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.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.4.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.4.0
File Size Uploaded
lazy-object-proxy-1.4.0.tar.gz 33.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lazy-object-proxy 1.4.0
File
lazy_object_proxy-1.4.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.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.4.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.4.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.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.4.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.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.4.0-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
lazy_object_proxy-1.4.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.4.0-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.0-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.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: 610.3 kB

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

Download URL lazy-object-proxy-1.4.0.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7fb11d33d99a374e4b0c3fb20128890b9cf784ca7e4b91ecbb191d34618bd9fe
BLAKE2b-256 checksum
How to use checksums
babdc259aae1ef43cd887e08959b70768861272e65c7a0fd44c66864bcc585f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

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

Download URL lazy_object_proxy-1.4.0-cp37-cp37m-win_amd64.whl
Size 25.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
da7f2a6c82a11dc4e05bab73522f0d6dd4f3bbc8378cd4b0769137f342cdb3f0
BLAKE2b-256 checksum
How to use checksums
a4da5d6a57d6d7cb8b4fae47c6f3eb9412ee6036fa949db9e31739c1bb430a42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp37-cp37m-win32.whl
Size 22.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
f6c718ffca055852479880debbe717da952fcfd60067a0ddb6fe3b053b1d4de0
BLAKE2b-256 checksum
How to use checksums
b90590c14de8ad9834e00262c88196ba987b48a28eba00accd4097077582a238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp37-cp37m-manylinux1_x86_64.whl
Size 54.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9b41ec246d31ca6a840dcf67673b2668adc5a095c64310d26d73292588563ea3
BLAKE2b-256 checksum
How to use checksums
676b1a9086c111cd99ca66b60dd8985e71ead25b904f784d304eadeffb789062
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp37-cp37m-macosx_10_13_x86_64.whl
Size 35.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
d49a90c27074f44c8dc147d83e31140523948ee147b3248634c540e053caea58
BLAKE2b-256 checksum
How to use checksums
f53d209533332df3eb3a6ef512118ae910d4985df804f58d06016e0201b56090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp36-cp36m-win_amd64.whl
Size 25.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
642fc0a9b61920669dab66e400f79f1b8b0e8f698dcde85f7e9ae5528dbcaf4a
BLAKE2b-256 checksum
How to use checksums
e237a122e38598fa7f76ddbe6ed9759aa461f29f7a45e12eea0c239e182c3853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp36-cp36m-win32.whl
Size 22.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
7003959a170fde9b92936c38562810f94679c80608fb4b007e026b915bef8b27
BLAKE2b-256 checksum
How to use checksums
3eae02c33be48997e1a2e45b2a18ef3c87dac3d0d62b89838d5509b56034568b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp36-cp36m-manylinux1_x86_64.whl
Size 54.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8995543f47a8b81962e384f12791114af9f4997be7a0db71abc40d2a2dfee961
BLAKE2b-256 checksum
How to use checksums
94e91e82e3b5d4f48625e7f5e6907a5dcf56acec8904f0c472718a13204f963d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp35-cp35m-win_amd64.whl
Size 25.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
55fa9eab93482891ce97473e63610efdd9c8fa5c05cca9f60468c412e602e499
BLAKE2b-256 checksum
How to use checksums
8c76a3fcad4788b665a68f53841d659886a2bbe169f5d1b19c0bda65bd180429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp35-cp35m-win32.whl
Size 22.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
118d53f8819f9457732dd0e418752f2850f395c5405b2e12485f52336e4ad0f5
BLAKE2b-256 checksum
How to use checksums
0e01a9d91f83207bfd3a0dcbf94008a362222116d3559e89f98852e83b62b30a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
Size 54.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d6957cadc9c079ef4697564af500d52fba6d14fb2f08d20ce92f52201fb77050
BLAKE2b-256 checksum
How to use checksums
2de5cae191672863102cb2a0a299dfe4e86e54309aabc3650391d41078d9d7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl

Download URL lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl
Size 23.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
7e63da94f5a1ddb0d2dcdb5d17ff4d1d33f51f3368bdf0475d5f56c0f3b99592
BLAKE2b-256 checksum
How to use checksums
9486f1938b17669a5de8c2057b8c5063753e6065cf3fc15ea63d425f253862eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl

Download URL lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl
Size 21.5 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
f03a21f6f6e54778860122a620f70c8b148ec4ee175968782bcaaa94955a46f9
BLAKE2b-256 checksum
How to use checksums
309ab6ebf166210ecba00d68c81f551d95d52c8abd29c2b2662d8522a7c8d063
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl
Size 54.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8758715ea005afa293783797498d64f40ab14d1ded208b3e282760cde9512f1d
BLAKE2b-256 checksum
How to use checksums
8008d6d137ccc8cfeef6cb160bd4961a941411e0f880e008a927cea3875c42b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl
Size 54.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
afcab74f471652b643900e0862b31892ac5fe5a75e435b786a1825855f4effdf
BLAKE2b-256 checksum
How to use checksums
631eb31f5d8db6259d7ec558b903efed7caf3a45a605378f3fb0157bccca4a11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp27-cp27m-win_amd64.whl
Size 23.2 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a8be3cfd7c3154e8d39276c627c5e7ee55d1f2094597b060ece99620ef9fe86b
BLAKE2b-256 checksum
How to use checksums
515ce57c95f342d0d000f3c097957aedaa6379d329f72b3b64b109e73cd59f17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp27-cp27m-win32.whl
Size 21.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
495c583b363c3eded649e2c00177093f03f856f5c9f95b527420084a9ce17b9d
BLAKE2b-256 checksum
How to use checksums
835ca4c886fe4580f751c84c24bc479f8fe2186736a1637d39c96480d1f41a6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.0-cp27-cp27m-macosx_10_13_x86_64.whl
Size 36.2 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
91c7e1316116fedda36818ce7cd269378fffc4219781536eff441ea1e68e1caf
BLAKE2b-256 checksum
How to use checksums
639b8f862314853198df85d6bb9b33403d96589e76ef7f6f6cd1a77c40adc728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

1.4.3

21 release files

1.4.2

18 release files

1.4.1

18 release files

This release

1.4.0 This release

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