Skip to main content

Overview

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 all the tests run:

tox

Acknowledgements

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

Changelog

1.8.0 (2022-10-26)

  • Cleaned up use of cPickle. Contributed by Sandro Tosi in #62.

  • Cleaned up more dead Python 2 code.

  • Added Python 3.11 wheels.

  • Dropped support for Python 3.6.

1.7.1 (2021-12-15)

  • Removed most of the Python 2 support code and fixed python_requires to require at least Python 3.6.

    Note that 1.7.0 has been yanked because it could not install on Python 2.7. Installing lazy-object-proxy on Python 2.7 should automatically fall back to the 1.6.0 release now.

1.7.0 (2021-12-15)

  • Switched CI to GitHub Actions, this has a couple consequences:

    • Support for Python 2.7 is dropped. You can still install it there but it’s not tested anymore and Python 2 specific handling will be removed at some point.

    • Linux wheels are now provided in musllinux and manylinux2014 variants.

  • Fixed __index__ to fallback to int if the wrapped object doesn’t have an __index__ method. This prevents situations where code using a proxy would otherwise likely just call int had the object not have an __index__ method.

1.6.0 (2021-03-22)

  • Added support for async special methods (__aiter__, __anext__, __await__, __aenter__, __aexit__). These are used in the async for, await` and ``async with statements.

    Note that __await__ returns a wrapper that tries to emulate the crazy stuff going on in the ceval loop, so there will be a small performance overhead.

  • Added the __resolved__ property. You can use it to check if the factory has been called.

1.5.2 (2020-11-26)

  • Added Python 3.9 wheels.

  • Removed Python 2.7 Windows wheels (not supported on newest image with Python 3.9).

1.5.1 (2020-07-22)

  • Added ARM64 wheels (manylinux2014).

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.8.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.8.0
File Size Uploaded
lazy-object-proxy-1.8.0.tar.gz 41.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lazy-object-proxy 1.8.0
File
lazy_object_proxy-1.8.0-pp39-pypy39_pp73-any.whl PyPy 3.9 PyPy 3.9 7.3 any Details
lazy_object_proxy-1.8.0-pp38-pypy38_pp73-any.whl PyPy 3.8 PyPy 3.8 7.3 any Details
lazy_object_proxy-1.8.0-pp37-pypy37_pp73-any.whl PyPy 3.7 PyPy 3.7 7.3 any Details
lazy_object_proxy-1.8.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
lazy_object_proxy-1.8.0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
lazy_object_proxy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
lazy_object_proxy-1.8.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
lazy_object_proxy-1.8.0-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
lazy_object_proxy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
lazy_object_proxy-1.8.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
lazy_object_proxy-1.8.0-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
lazy_object_proxy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
lazy_object_proxy-1.8.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
lazy_object_proxy-1.8.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
lazy_object_proxy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
lazy_object_proxy-1.8.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
lazy_object_proxy-1.8.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
lazy_object_proxy-1.8.0-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details

Total release size: 398.5 kB

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

Download URL lazy-object-proxy-1.8.0.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c219a00245af0f6fa4e95901ed28044544f50152840c5b6a3e7b2568db34d156
BLAKE2b-256 checksum
How to use checksums
7437591f89e8a09ae4574391bdf8a5eecd34a3dbe545917333e625c9de9a66b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-pp39-pypy39_pp73-any.whl

Download URL lazy_object_proxy-1.8.0-pp39-pypy39_pp73-any.whl
Size 11.3 kB
Tags PyPy 3.9 PyPy 3.9 7.3
SHA-256 checksum
How to use checksums
ce58b2b3734c73e68f0e30e4e725264d4d6be95818ec0a0be4bb6bf9a7e79aa8
BLAKE2b-256 checksum
How to use checksums
f5dc11168f6697ed68ec29a4f0887308c0d7836d96148a81eb0abb7b8e77b8e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-pp38-pypy38_pp73-any.whl

Download URL lazy_object_proxy-1.8.0-pp38-pypy38_pp73-any.whl
Size 11.3 kB
Tags PyPy 3.8 PyPy 3.8 7.3
SHA-256 checksum
How to use checksums
7e1561626c49cb394268edd00501b289053a652ed762c58e1081224c8d881cec
BLAKE2b-256 checksum
How to use checksums
e3904c8d2ce638791874f48894761e305afa2bf6f85f315f1d51946eb1e2b18f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-pp37-pypy37_pp73-any.whl

Download URL lazy_object_proxy-1.8.0-pp37-pypy37_pp73-any.whl
Size 11.8 kB
Tags PyPy 3.7 PyPy 3.7 7.3
SHA-256 checksum
How to use checksums
ae032743794fba4d171b5b67310d69176287b5bf82a21f588282406a79498891
BLAKE2b-256 checksum
How to use checksums
b9a2e6b92d1ce6da768a1570d436616f4c565420fcf1c4b2b5246cf77624fe36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp311-cp311-win_amd64.whl

Download URL lazy_object_proxy-1.8.0-cp311-cp311-win_amd64.whl
Size 22.1 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
14010b49a2f56ec4943b6cf925f597b534ee2fe1f0738c84b3bce0c1a11ff10d
BLAKE2b-256 checksum
How to use checksums
d78a7bf9154dd7e6e9bda733a105e3baca3636abe72091cd1dcbf636979b667f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp311-cp311-win32.whl

Download URL lazy_object_proxy-1.8.0-cp311-cp311-win32.whl
Size 20.4 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
e20bfa6db17a39c706d24f82df8352488d2943a3b7ce7d4c22579cb89ca8896e
BLAKE2b-256 checksum
How to use checksums
34c51ef17ab530068f7a5549ab376726f83fe2221db592dbdfd4f8fd4662e45d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl

Download URL lazy_object_proxy-1.8.0-cp311-cp311-macosx_10_9_x86_64.whl
Size 22.0 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4e2d9f764f1befd8bdc97673261b8bb888764dfdbd7a4d8f55e4fbcabb8c3fb7
BLAKE2b-256 checksum
How to use checksums
6508836c9e4e6edf3a267e5b1d0c03923a70ee1a233baf6eb00bfab88d795c51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp310-cp310-win_amd64.whl

Download URL lazy_object_proxy-1.8.0-cp310-cp310-win_amd64.whl
Size 22.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
eb329f8d8145379bf5dbe722182410fe8863d186e51bf034d2075eb8d85ee25b
BLAKE2b-256 checksum
How to use checksums
64edad47931e7780a5c39f7439de9124438794137840ffdb5f3ffd2995228071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp310-cp310-win32.whl

Download URL lazy_object_proxy-1.8.0-cp310-cp310-win32.whl
Size 20.4 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
b70d6e7a332eb0217e7872a73926ad4fdc14f846e85ad6749ad111084e76df25
BLAKE2b-256 checksum
How to use checksums
30c381c176ce53d9107947d355b273f9661a4f4cad6d56d1daf1c9d6969902e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL lazy_object_proxy-1.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 22.0 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4fd031589121ad46e293629b39604031d354043bb5cdf83da4e93c2d7f3389fe
BLAKE2b-256 checksum
How to use checksums
7c0f60db0efe9a1d61fc830cfd2806d54c5fb64761e8009b9d163bf0ede5b12d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp39-cp39-win_amd64.whl

Download URL lazy_object_proxy-1.8.0-cp39-cp39-win_amd64.whl
Size 22.1 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
eac3a9a5ef13b332c059772fd40b4b1c3d45a3a2b05e33a361dee48e54a4dad0
BLAKE2b-256 checksum
How to use checksums
9dd16dd90b049748d02d9120a496c3649220ac4f6803dd74c9ae48f2bb001239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp39-cp39-win32.whl

Download URL lazy_object_proxy-1.8.0-cp39-cp39-win32.whl
Size 20.4 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
8f6ce2118a90efa7f62dd38c7dbfffd42f468b180287b748626293bf12ed468f
BLAKE2b-256 checksum
How to use checksums
463555c3650f29858869596871b7fedf4a6b211b61dcc4dd8e8d5702eb85370e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL lazy_object_proxy-1.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 22.0 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
71d9ae8a82203511a6f60ca5a1b9f8ad201cac0fc75038b2dc5fa519589c9288
BLAKE2b-256 checksum
How to use checksums
9d237e78292a5b72121a8bdfff128fcfb8d3630af74336855d3e527f73eaa4c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

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

Download URL lazy_object_proxy-1.8.0-cp38-cp38-win_amd64.whl
Size 22.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
afcaa24e48bb23b3be31e329deb3f1858f1f1df86aea3d70cb5c8578bfe5261c
BLAKE2b-256 checksum
How to use checksums
e0d30cdabfa685eb152a9f4d179fa95f121b3810171f246e8e51f45d100b345c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

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

Download URL lazy_object_proxy-1.8.0-cp38-cp38-win32.whl
Size 20.4 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
d176f392dbbdaacccf15919c77f526edf11a34aece58b55ab58539807b85436f
BLAKE2b-256 checksum
How to use checksums
80aa71f82fd17211767419d6b1fc3dc00ba4641c11f9c9358f7acc5222e693b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL lazy_object_proxy-1.8.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 22.0 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
0c1c7c0433154bb7c54185714c6929acc0ba04ee1b167314a779b9025517eada
BLAKE2b-256 checksum
How to use checksums
959744ee4e0247754bcb878886baf2e06856ff268b0d67e86f1d750f251e3c87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

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

Download URL lazy_object_proxy-1.8.0-cp37-cp37m-win_amd64.whl
Size 22.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
6f593f26c470a379cf7f5bc6db6b5f1722353e7bf937b8d0d0b3fba911998858
BLAKE2b-256 checksum
How to use checksums
f671e0dbe4172135aca4b4f657cf15fefd34247b5392ae42cf2ca2583dfa332f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

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

Download URL lazy_object_proxy-1.8.0-cp37-cp37m-win32.whl
Size 20.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
5b51d6f3bfeb289dfd4e95de2ecd464cd51982fe6f00e2be1d0bf94864d58acd
BLAKE2b-256 checksum
How to use checksums
60c1bf324cf9a0577b0e3781b1a38696405235ac784c4a6d889f97a36dcedc70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / lazy_object_proxy-1.8.0-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL lazy_object_proxy-1.8.0-cp37-cp37m-macosx_10_9_x86_64.whl
Size 21.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
6850e4aeca6d0df35bb06e05c8b934ff7c533734eb51d0ceb2d63696f1e6030c
BLAKE2b-256 checksum
How to use checksums
0a685839136508651d813c1adce568e2f7417bb66083dc8d604a69d465ee53c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.8.0 This release

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

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