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.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.4.1

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.1
File Size Uploaded
lazy-object-proxy-1.4.1.tar.gz 34.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lazy-object-proxy 1.4.1
File
lazy_object_proxy-1.4.1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.1-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.1-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.1-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.1-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.1-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.1-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.1-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.1-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.1-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.1-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.1-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.1-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.1-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.1-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.4.1-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.4.1-cp27-cp27m-macosx_10_13_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64 Details

Total release size: 513.7 kB

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

Download URL lazy-object-proxy-1.4.1.tar.gz
Size 34.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4ba73f6089cd9b9478bc0a4fa807b47dbdb8fad1d8f31a0f0a5dbf26a4527a71
BLAKE2b-256 checksum
How to use checksums
ad57a36f682668ffc453e86ddfb5a2a49848edcb7bd04a210a5a8692a48ed9c4
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.1-cp37-cp37m-win_amd64.whl

Download URL lazy_object_proxy-1.4.1-cp37-cp37m-win_amd64.whl
Size 20.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
159a745e61422217881c4de71f9eafd9d703b93af95618635849fe469a283661
BLAKE2b-256 checksum
How to use checksums
bb8610c9846c822ee923c157d0abe24d322472315ea47a216e6bf99e3b5b771f
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.1-cp37-cp37m-win32.whl

Download URL lazy_object_proxy-1.4.1-cp37-cp37m-win32.whl
Size 18.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
8559b94b823f85342e10d3d9ca4ba5478168e1ac5658a8a2f18c991ba9c52c20
BLAKE2b-256 checksum
How to use checksums
59d488c4ce70219fe30ffa62a6dd2a8d3ef98fe1075991b4cefe72cc8034d214
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.1-cp37-cp37m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp37-cp37m-manylinux1_x86_64.whl
Size 49.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
bfab710d859c779f273cc48fb86af38d6e9210f38287df0069a63e40b45a2f5c
BLAKE2b-256 checksum
How to use checksums
43a51b19b094ad19bce55b5b6d434020f5537b424fd2b3cff0fbef23d7bb5a95
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.1-cp37-cp37m-macosx_10_13_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp37-cp37m-macosx_10_13_x86_64.whl
Size 19.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
6f72d42b0d04bfee2397aa1862262654b56922c20a9bb66bb76b6f0e5e4f9229
BLAKE2b-256 checksum
How to use checksums
933c279faaa32f456946c8b692576fc994f7401e905034c7428696409b80d3ce
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.1-cp36-cp36m-win_amd64.whl

Download URL lazy_object_proxy-1.4.1-cp36-cp36m-win_amd64.whl
Size 20.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
dd6e2b598849b3d7aee2295ac765a578879830fb8966f70be8cd472e6069932e
BLAKE2b-256 checksum
How to use checksums
82ea78cb915aac2150831141f2cc91824d078fcc394906867264a31aad5132df
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.1-cp36-cp36m-win32.whl

Download URL lazy_object_proxy-1.4.1-cp36-cp36m-win32.whl
Size 18.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
3f447aff8bc61ca8b42b73304f6a44fa0d915487de144652816f950a3f1ab821
BLAKE2b-256 checksum
How to use checksums
fbd73f5b37011350ed055938e750a3a8fb353df9592ac9b1d65723f7a39ec48c
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.1-cp36-cp36m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl
Size 49.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c10d29019927301d524a22ced72706380de7cfc50f767217485a912b4c8bd82a
BLAKE2b-256 checksum
How to use checksums
1a2ad73b99e9407be3acd7c0328fcc44bcf6f5c42e6d03d1fb192032c0057d13
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.1-cp35-cp35m-win_amd64.whl

Download URL lazy_object_proxy-1.4.1-cp35-cp35m-win_amd64.whl
Size 20.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
7c8b1ba1e15c10b13cad4171cfa77f5bb5ec2580abc5a353907780805ebe158e
BLAKE2b-256 checksum
How to use checksums
cfe863348e4d8f524658e8787a0d8c919b37a74b54864cc829ce4658f9dc7ad8
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.1-cp35-cp35m-win32.whl

Download URL lazy_object_proxy-1.4.1-cp35-cp35m-win32.whl
Size 18.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e408f1eacc0a68fed0c08da45f31d0ebb38079f043328dce69ff133b95c29dc1
BLAKE2b-256 checksum
How to use checksums
429042c4c109ae03e322d5bdcd8f38683319cd5ad156dfbcc001f0a3638bab30
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.1-cp35-cp35m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp35-cp35m-manylinux1_x86_64.whl
Size 49.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
64483bd7154580158ea90de5b8e5e6fc29a16a9b4db24f10193f0c1ae3f9d1ea
BLAKE2b-256 checksum
How to use checksums
1ff465eb90d5c1d22861d80faac4af74e3adc41cd63c8aea198e21a00372f875
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.1-cp34-cp34m-win_amd64.whl

Download URL lazy_object_proxy-1.4.1-cp34-cp34m-win_amd64.whl
Size 18.8 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
7c7f1ec07b227bdc561299fa2328e85000f90179a2f44ea30579d38e037cb3d4
BLAKE2b-256 checksum
How to use checksums
6e525f1774fddc55e21a9e3e0a8fea39a11dea139a55cf85089d6f452d0ac5e4
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.1-cp34-cp34m-win32.whl

Download URL lazy_object_proxy-1.4.1-cp34-cp34m-win32.whl
Size 17.3 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
be089bb6b83fac7f29d357b2dc4cf2b8eb8d98fe9d9ff89f9ea6012970a853c7
BLAKE2b-256 checksum
How to use checksums
1de43fdf0f7780e1903a450a5fd2717d2b83177c3a6cafe0cb9d495a29037fef
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.1-cp34-cp34m-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp34-cp34m-manylinux1_x86_64.whl
Size 49.6 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
23f63c0821cc96a23332e45dfaa83266feff8adc72b9bcaef86c202af765244f
BLAKE2b-256 checksum
How to use checksums
707ea6e7004d86e9de8f709dfad0fb67360b5e461e8cf419d37c2ba4eaf37d56
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.1-cp27-cp27mu-manylinux1_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp27-cp27mu-manylinux1_x86_64.whl
Size 50.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
acce4e3267610c4fdb6632b3886fe3f2f7dd641158a843cf6b6a68e4ce81477b
BLAKE2b-256 checksum
How to use checksums
ea1961b76168025e732601b3c8927d4ea346784507707fcfac1f6a386e6f3843
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.1-cp27-cp27m-win_amd64.whl

Download URL lazy_object_proxy-1.4.1-cp27-cp27m-win_amd64.whl
Size 19.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a262c7dfb046f00e12a2bdd1bafaed2408114a89ac414b0af8755c696eb3fc16
BLAKE2b-256 checksum
How to use checksums
dea8736e35b5b55616e1538efcf915946d0b39ce50c91ecb7dc42bf247ad8fe1
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.1-cp27-cp27m-win32.whl

Download URL lazy_object_proxy-1.4.1-cp27-cp27m-win32.whl
Size 17.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
4f53eadd9932055eac465bd3ca1bd610e4d7141e1278012bd1f28646aebc1d0e
BLAKE2b-256 checksum
How to use checksums
3936cb2b3be5cb25537000670dbcfcf013873b6d970b1ba0edeb100c137e7d47
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.1-cp27-cp27m-macosx_10_13_x86_64.whl

Download URL lazy_object_proxy-1.4.1-cp27-cp27m-macosx_10_13_x86_64.whl
Size 19.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
3b11be575475db2e8a6e11215f5aa95b9ec14de658628776e10d96fa0b4dac13
BLAKE2b-256 checksum
How to use checksums
762bf830a32540f01a6966fed67971c3b278bebde61e02e5f5e557549e33a0ce
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

This release

1.4.1 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