Skip to main content

A fast and thorough lazy object proxy.

Project description

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.

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.4.0.tar.gz (33.7 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.4.0-cp37-cp37m-win_amd64.whl (25.1 kB view details)

Uploaded CPython 3.7mWindows x86-64

lazy_object_proxy-1.4.0-cp37-cp37m-win32.whl (22.8 kB view details)

Uploaded CPython 3.7mWindows x86

lazy_object_proxy-1.4.0-cp37-cp37m-manylinux1_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.7m

lazy_object_proxy-1.4.0-cp37-cp37m-macosx_10_13_x86_64.whl (35.8 kB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

lazy_object_proxy-1.4.0-cp36-cp36m-win_amd64.whl (25.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

lazy_object_proxy-1.4.0-cp36-cp36m-win32.whl (22.9 kB view details)

Uploaded CPython 3.6mWindows x86

lazy_object_proxy-1.4.0-cp36-cp36m-manylinux1_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.6m

lazy_object_proxy-1.4.0-cp35-cp35m-win_amd64.whl (25.1 kB view details)

Uploaded CPython 3.5mWindows x86-64

lazy_object_proxy-1.4.0-cp35-cp35m-win32.whl (22.8 kB view details)

Uploaded CPython 3.5mWindows x86

lazy_object_proxy-1.4.0-cp35-cp35m-manylinux1_x86_64.whl (54.2 kB view details)

Uploaded CPython 3.5m

lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl (23.0 kB view details)

Uploaded CPython 3.4mWindows x86-64

lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl (21.5 kB view details)

Uploaded CPython 3.4mWindows x86

lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl (54.0 kB view details)

Uploaded CPython 3.4m

lazy_object_proxy-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl (54.7 kB view details)

Uploaded CPython 2.7mu

lazy_object_proxy-1.4.0-cp27-cp27m-win_amd64.whl (23.2 kB view details)

Uploaded CPython 2.7mWindows x86-64

lazy_object_proxy-1.4.0-cp27-cp27m-win32.whl (21.7 kB view details)

Uploaded CPython 2.7mWindows x86

lazy_object_proxy-1.4.0-cp27-cp27m-macosx_10_13_x86_64.whl (36.2 kB view details)

Uploaded CPython 2.7mmacOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for lazy-object-proxy-1.4.0.tar.gz
Algorithm Hash digest
SHA256 7fb11d33d99a374e4b0c3fb20128890b9cf784ca7e4b91ecbb191d34618bd9fe
MD5 389b54e3b83088c57154c45bd3eaa1d9
BLAKE2b-256 babdc259aae1ef43cd887e08959b70768861272e65c7a0fd44c66864bcc585f4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 da7f2a6c82a11dc4e05bab73522f0d6dd4f3bbc8378cd4b0769137f342cdb3f0
MD5 567ea136dd334f210bd73061478936ae
BLAKE2b-256 a4da5d6a57d6d7cb8b4fae47c6f3eb9412ee6036fa949db9e31739c1bb430a42

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 f6c718ffca055852479880debbe717da952fcfd60067a0ddb6fe3b053b1d4de0
MD5 76ac135b9b641c425b9f03c06a73e9c7
BLAKE2b-256 b90590c14de8ad9834e00262c88196ba987b48a28eba00accd4097077582a238

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9b41ec246d31ca6a840dcf67673b2668adc5a095c64310d26d73292588563ea3
MD5 e114a0f6a6e44aaeb7c8a1ee8525b561
BLAKE2b-256 676b1a9086c111cd99ca66b60dd8985e71ead25b904f784d304eadeffb789062

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d49a90c27074f44c8dc147d83e31140523948ee147b3248634c540e053caea58
MD5 7064a4348be16012a0ac22e52ca073c1
BLAKE2b-256 f53d209533332df3eb3a6ef512118ae910d4985df804f58d06016e0201b56090

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 642fc0a9b61920669dab66e400f79f1b8b0e8f698dcde85f7e9ae5528dbcaf4a
MD5 faa11cc09f317752971f05484163993d
BLAKE2b-256 e237a122e38598fa7f76ddbe6ed9759aa461f29f7a45e12eea0c239e182c3853

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 7003959a170fde9b92936c38562810f94679c80608fb4b007e026b915bef8b27
MD5 3eb12c6b17012afc96471b1c70aa8b60
BLAKE2b-256 3eae02c33be48997e1a2e45b2a18ef3c87dac3d0d62b89838d5509b56034568b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8995543f47a8b81962e384f12791114af9f4997be7a0db71abc40d2a2dfee961
MD5 119d2620fd393290daff26db672ba852
BLAKE2b-256 94e91e82e3b5d4f48625e7f5e6907a5dcf56acec8904f0c472718a13204f963d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 55fa9eab93482891ce97473e63610efdd9c8fa5c05cca9f60468c412e602e499
MD5 0fda56f043a8021e304f5ac58d004dd4
BLAKE2b-256 8c76a3fcad4788b665a68f53841d659886a2bbe169f5d1b19c0bda65bd180429

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 118d53f8819f9457732dd0e418752f2850f395c5405b2e12485f52336e4ad0f5
MD5 1118b7888177c7570156bc63e2dc8cb5
BLAKE2b-256 0e01a9d91f83207bfd3a0dcbf94008a362222116d3559e89f98852e83b62b30a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d6957cadc9c079ef4697564af500d52fba6d14fb2f08d20ce92f52201fb77050
MD5 a16568dd5bf5e8cc6acfd9bec189ef77
BLAKE2b-256 2de5cae191672863102cb2a0a299dfe4e86e54309aabc3650391d41078d9d7df

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: CPython 3.4m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 7e63da94f5a1ddb0d2dcdb5d17ff4d1d33f51f3368bdf0475d5f56c0f3b99592
MD5 51f37cd9b913540e61c46ae0f26b3550
BLAKE2b-256 9486f1938b17669a5de8c2057b8c5063753e6065cf3fc15ea63d425f253862eb

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl.

File metadata

  • Download URL: lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: CPython 3.4m, Windows x86
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 f03a21f6f6e54778860122a620f70c8b148ec4ee175968782bcaaa94955a46f9
MD5 10672b1bb6f92d83e925b3d7283385e4
BLAKE2b-256 309ab6ebf166210ecba00d68c81f551d95d52c8abd29c2b2662d8522a7c8d063

See more details on using hashes here.

File details

Details for the file lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: CPython 3.4m
  • Uploaded using 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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8758715ea005afa293783797498d64f40ab14d1ded208b3e282760cde9512f1d
MD5 f4422670075333f230c7421f34d5fb81
BLAKE2b-256 8008d6d137ccc8cfeef6cb160bd4961a941411e0f880e008a927cea3875c42b4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 afcab74f471652b643900e0862b31892ac5fe5a75e435b786a1825855f4effdf
MD5 95da7a95293825f631092d2589073a40
BLAKE2b-256 631eb31f5d8db6259d7ec558b903efed7caf3a45a605378f3fb0157bccca4a11

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 a8be3cfd7c3154e8d39276c627c5e7ee55d1f2094597b060ece99620ef9fe86b
MD5 f0ebed378ac126bf0acb58294b906fa7
BLAKE2b-256 515ce57c95f342d0d000f3c097957aedaa6379d329f72b3b64b109e73cd59f17

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 495c583b363c3eded649e2c00177093f03f856f5c9f95b527420084a9ce17b9d
MD5 a5173a60a4ce69599b6300ff00bc8480
BLAKE2b-256 835ca4c886fe4580f751c84c24bc479f8fe2186736a1637d39c96480d1f41a6f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lazy_object_proxy-1.4.0-cp27-cp27m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 91c7e1316116fedda36818ce7cd269378fffc4219781536eff441ea1e68e1caf
MD5 e1c0b0f60df2882e3ccc2d7999937a17
BLAKE2b-256 639b8f862314853198df85d6bb9b33403d96589e76ef7f6f6cd1a77c40adc728

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