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

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.2
File Size Uploaded
lazy-object-proxy-1.4.2.tar.gz 34.0 kB Details

Built distributions (wheels)

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

Total release size: 509.8 kB

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

Download URL lazy-object-proxy-1.4.2.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fd135b8d35dfdcdb984828c84d695937e58cc5f49e1c854eb311c4d6aa03f4f1
BLAKE2b-256 checksum
How to use checksums
3639d9b7d05775c3d12fe49c1119f53e20adf81757bfd3840f30961a0d57e6d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8

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

Download URL lazy_object_proxy-1.4.2-cp37-cp37m-win_amd64.whl
Size 20.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
84742532d39f72df959d237912344d8a1764c2d03fe58beba96a87bfa11a76d8
BLAKE2b-256 checksum
How to use checksums
01b0467ad69cd8adfe2be737cf69b69c5809c7098a7aa337adda2542b7259bc0
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp37-cp37m-win32.whl
Size 18.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
b4a2b782b8a8c5522ad35c93e04d60e2ba7f7dcb9271ec8e8c3e08239be6c7b4
BLAKE2b-256 checksum
How to use checksums
ecec88fbb82752c22d28e3437b4bbe4619949d900a813d3afd4da4e68cc6dc2e
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-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
874ebf3caaf55a020aeb08acead813baf5a305927a71ce88c9377970fe7ad3c2
BLAKE2b-256 checksum
How to use checksums
11a098687a75455408ce1b222b46ef66062b5af422c3f7451f080663ba68b5df
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp37-cp37m-macosx_10_13_x86_64.whl
Size 18.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
9f5caf2c7436d44f3cec97c2fa7791f8a675170badbfa86e1992ca1b84c37009
BLAKE2b-256 checksum
How to use checksums
b01933c3546fd031d47086c6a66c36cf0d768c78f4428a77856780d57600d4c9
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp36-cp36m-win_amd64.whl
Size 20.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
18f9c401083a4ba6e162355873f906315332ea7035803d0fd8166051e3d402e3
BLAKE2b-256 checksum
How to use checksums
f027bac679deed17fe2114eeae614e0abb9e5c88b34d41ec0fbeb320997312fb
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp36-cp36m-win32.whl
Size 18.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
77b454f03860b844f758c5d5c6e5f18d27de899a3db367f4af06bec2e6013a8e
BLAKE2b-256 checksum
How to use checksums
8196616cc34b7823e38739db67cfe2bdf170c08a5782d2dc02967aa4bd634567
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp36-cp36m-manylinux1_x86_64.whl
Size 49.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a0c8758d01fcdfe7ae8e4b4017b13552efa7f1197dd7358dc9da0576f9d0328a
BLAKE2b-256 checksum
How to use checksums
0e26534a6d32572a9dbca11619321535c0a7ab34688545d9d67c2c204b9e3a3d
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp35-cp35m-win_amd64.whl
Size 20.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a4def978d9d28cda2d960c279318d46b327632686d82b4917516c36d4c274512
BLAKE2b-256 checksum
How to use checksums
5de50898a1c288ecad4650dbd68f1fac1dda6ab4c8f70e437a8f08add75e1650
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp35-cp35m-win32.whl
Size 18.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
2f06d97f0ca0f414f6b707c974aaf8829c2292c1c497642f63824119d770226f
BLAKE2b-256 checksum
How to use checksums
be8fa293db95afc7fc1d15e50994785ec6ffb44583c0d24718464756fd7a1301
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-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
02b260c8deb80db09325b99edf62ae344ce9bc64d68b7a634410b8e9a568edbf
BLAKE2b-256 checksum
How to use checksums
ef3ba171ee9b58103169d26125a5cea1a09d77d20fc7afe1c08a2fa50e5e5042
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp34-cp34m-win_amd64.whl
Size 18.5 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
83fe27ba321e4cfac466178606147d3c0aa18e8087507caec78ed5a966a64905
BLAKE2b-256 checksum
How to use checksums
b5df2d5fd021308ecf443e701acf9553cfef7504062a9ee752d99c632273304f
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp34-cp34m-win32.whl
Size 17.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
c462eb33f6abca3b34cdedbe84d761f31a60b814e173b98ede3c81bb48967c4f
BLAKE2b-256 checksum
How to use checksums
0c96e8449c406c845d54d6164daf545998744975aaf88228480851890ce597a4
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-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
1f2c6209a8917c525c1e2b55a716135ca4658a3042b5122d4e3413a4030c26ce
BLAKE2b-256 checksum
How to use checksums
914394b719a7a1a654cc0a8cb16390fe541e6cec0880e8de50bfaa3967bb2f5d
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-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
63b91e30ef47ef68a30f0c3c278fbfe9822319c15f34b7538a829515b84ca2a0
BLAKE2b-256 checksum
How to use checksums
ede36cf40a286e444698b09cfe65d0a7e58716c2079bb9e9cd58873dbe4ca1a6
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp27-cp27m-win_amd64.whl
Size 18.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
ad4f4be843dace866af5fc142509e9b9817ca0c59342fdb176ab6ad552c927f5
BLAKE2b-256 checksum
How to use checksums
710f7b266ef296511461e0794e1ee0a6ddd6787f262038ff23ddcb0c451f2674
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp27-cp27m-win32.whl
Size 17.2 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
ae33dd198f772f714420c5ab698ff05ff900150486c648d29951e9c70694338e
BLAKE2b-256 checksum
How to use checksums
55698af2084bbf790a03730a4e8d7089ca3e31c77f407d1224c3143ec4288d63
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/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

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

Download URL lazy_object_proxy-1.4.2-cp27-cp27m-macosx_10_13_x86_64.whl
Size 19.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
616c94f8176808f4018b39f9638080ed86f96b55370b5a9463b2ee5c926f6c5f
BLAKE2b-256 checksum
How to use checksums
4bb0101826c1259b932582ad5ac841458bcb717256a3b56ca8eb3586ce62f996
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/41.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

This release

1.4.2 This release

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