Skip to main content

A fast and thorough lazy object proxy.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lazy-object-proxy-1.5.0.tar.gz (35.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl (21.4 kB view details)

Uploaded CPython 3.8Windows x86-64

lazy_object_proxy-1.5.0-cp38-cp38-win32.whl (19.0 kB view details)

Uploaded CPython 3.8Windows x86

lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl (59.6 kB view details)

Uploaded CPython 3.8

lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl (21.2 kB view details)

Uploaded CPython 3.7mWindows x86-64

lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl (18.9 kB view details)

Uploaded CPython 3.7mWindows x86

lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl (57.4 kB view details)

Uploaded CPython 3.7m

lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl (19.4 kB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl (21.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl (18.9 kB view details)

Uploaded CPython 3.6mWindows x86

lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl (56.4 kB view details)

Uploaded CPython 3.6m

lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl (21.2 kB view details)

Uploaded CPython 3.5mWindows x86-64

lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl (18.9 kB view details)

Uploaded CPython 3.5mWindows x86

lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl (56.2 kB view details)

Uploaded CPython 3.5m

lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl (55.0 kB view details)

Uploaded CPython 2.7mu

lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl (19.3 kB view details)

Uploaded CPython 2.7mWindows x86-64

lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl (17.7 kB view details)

Uploaded CPython 2.7mWindows x86

lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl (19.6 kB view details)

Uploaded CPython 2.7mmacOS 10.13+ x86-64

File details

Details for the file lazy-object-proxy-1.5.0.tar.gz.

File metadata

  • Download URL: lazy-object-proxy-1.5.0.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for lazy-object-proxy-1.5.0.tar.gz
Algorithm Hash digest
SHA256 a0aed261060cd0372abf08d16399b1224dbb5b400312e6b00f2b23eabe1d4e96
MD5 ea5c009f1995d86942d024714096624e
BLAKE2b-256 f25e36a324082c534512b94ed1ddc9d0ee522fddd70f85ec6ca178c6bf6651f8

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 35c3ad7b7f7d5d4a54a80f0ff5a41ab186237d6486843f8dde00c42cfab33905
MD5 b077312b976f898f5a7e104d95ebfc4c
BLAKE2b-256 0c5be5d7acfc3886ef608aa448d2cd326a87aa4b2c53a36765a91a7bdeab6644

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 da82b2372f5ded8806eaac95b19af89a7174efdb418d4e7beb0c6ab09cee7d95
MD5 031b0d72ae8fa554cf52c7fe764b2bea
BLAKE2b-256 d9ffef488f2e73ee6db44cd3a5e798a1842acb20b1587674e33ea7e465d9d0af

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.6 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a6052c4c7d95de2345d9c58fc0fe34fff6c27a8ed8550dafeb18ada84406cc99
MD5 7752d2201351dc2435f3a0b67ef87918
BLAKE2b-256 378579099051446e3a615d3977ea81fa6245f62e061e60fcd3d63c19b8346d5a

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0aef3fa29f7d1194d6f8a99382b1b844e5a14d3bc1ef82c3b1c4fb7e7e2019bc
MD5 b944da7c736947a0438c79e33b26e080
BLAKE2b-256 4d1c5d85076eaf6d105f2ce7c1b8440372f51146f40dd35977d135d5c155b95c

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 311c9d1840042fc8e2dd80fc80272a7ea73e7646745556153c9cda85a4628b18
MD5 58d72d45562febc295d61c585e69e926
BLAKE2b-256 7a9dba4f06c946d95659acc6f38f45820b13e84b4a7514a79ffccfaa310219d4

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 161a68a427022bf13e249458be2cb8da56b055988c584d372a917c665825ae9a
MD5 e959b9c94e7036120fdf2e5b5c3158b6
BLAKE2b-256 a0cb179c709fda5d99f8ddc1abd98b6300d98c8d1fce20aa73ab56545f10d1bb

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 159ae2bbb4dc3ba506aeba868d14e56a754c0be402d1f0d7fdb264e0bdf2b095
MD5 40b3994cf4be114e74714e4f894357d4
BLAKE2b-256 a9754bac9e82b17048343b23bbe087d3e3571047d3fb08090a04f6cc5a082b74

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4a50513b6be001b9b7be2c435478fe9669249c77c241813907a44cda1fcd03f4
MD5 a9685fe16d82fc57044c6d446ae21059
BLAKE2b-256 0dd56ecf8929b64a4024d3217f05216da33c2fc086f2212ab854b54da02c2c95

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 dd89f466c930d7cfe84c94b5cbe862867c88b269f23e5aa61d40945e0d746f54
MD5 7faeb9fa03464b8ddbaf2559a886793d
BLAKE2b-256 a83e8885c18abba02bf709b54292a2c907c792ff7d6059cfb9f026b630b1377e

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 459ef557e669d0046fe2b92eb4822c097c00b5ef9d11df0f9bd7d4267acdfc52
MD5 32c251937969b8ee776b4f8a4c4aa012
BLAKE2b-256 cd2f68176f910e32eec13d2db184442fe2242d067ce5abe4c095ff3a95d34907

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 cbf1354292a4f7abb6a0188f74f5e902e4510ebad105be1dbc4809d1ed92f77e
MD5 c0dd2e640666c3d6cf95e2070bb78220
BLAKE2b-256 c287790229ad22bf91555373daf0ea6d80f9315057bb02b2f3560f1c72b7e475

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 2d58f0e6395bf41087a383a48b06b42165f3b699f1aa41ba201db84ab77be63d
MD5 42a7e1032c7cd673e1e8c6e199de3fe7
BLAKE2b-256 460b892b7a0344807c82d1f7e69db4abd93db89f2892563cffa5185d183babbb

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 56.2 kB
  • Tags: CPython 3.5m
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 51035b175740c44707694c521560b55b66da9d5a7c545cf22582bc02deb61664
MD5 b077bf61e1520e78c4597c7f8c862915
BLAKE2b-256 da3eff0811bd7f6d1847f3e21000b2a072ccdf136ccca8159e68f28281c9f9b0

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 55.0 kB
  • Tags: CPython 2.7mu
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 96f2cdb35bdfda10e075f12892a42cff5179bbda698992b845f36c5e92755d33
MD5 6a8d9180a4aa027ab0bd5b004c2621a4
BLAKE2b-256 f31f3e31313f557e0b97bd8f9716f502fa85c5fef181f582f816a4796b8f9ee1

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 e3183fbeb452ec11670c2d9bfd08a57bc87e46856b24d1c335f995239bedd0e1
MD5 13461dd9c93fbcede2463a3f6f3bf821
BLAKE2b-256 e5879e409a297f41bf3542990c9bd6984462bc4b7208114cf9f0abe0bb502449

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 e9a571e7168076a0d5ecaabd91e9032e86d815cca3a4bf0dafead539ef071aa5
MD5 b1c236ad1033cc31a3687cb06ad40a6a
BLAKE2b-256 a2fbb3ad4515aef5d423fbd6864c0390f5eb604c6623e9afbac88b900a02ee2a

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: CPython 2.7m, macOS 10.13+ x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.5.0-cp27-cp27m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ec6aba217d0c4f71cbe48aea962a382dedcd111f47b55e8b58d4aaca519bd360
MD5 accc94d815ed10b267ab20c85e36f125
BLAKE2b-256 75d5837744b46b09b593f27568b978e3a7bea46177ca9754ddaba483b7cb309c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page