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
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.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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for lazy_object_proxy-1.6.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5144c75445ae3ca2057faac03fda5a902eff196702b0a24daf1d6ce0650514b |
|
MD5 | 4979770bafc913cf298e6290f1e55c06 |
|
BLAKE2b-256 | 9bacafd3b1efaf5e6c22383d067260eea0c958591b21d8bb372b4eae543694eb |
Hashes for lazy_object_proxy-1.6.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fee665d2638491f4d6e55bd483e15ef21f6c8c2095f235fef72601021e64f61 |
|
MD5 | 87e2e52e5fa8860e432e038eb6d60ca5 |
|
BLAKE2b-256 | f0b945a041d3bc406528bf0bcb0b8025e712b812bbcf2dde0c111757feee140d |
Hashes for lazy_object_proxy-1.6.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9698110e36e2df951c7c36b6729e96429c9c32b3331989ef19976592c5f3c77a |
|
MD5 | b0a71880a344b30be8f2eb9553bfbe98 |
|
BLAKE2b-256 | 5e0e998f4ba8c182a7d916cb23bed65554cd32efda13de433c73ed504d8272ec |
Hashes for lazy_object_proxy-1.6.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4732c765372bd78a2d6b2150a6e99d00a78ec963375f236979c0626b97ed8e43 |
|
MD5 | 57707672aea08c4ac574b0ed05595a6a |
|
BLAKE2b-256 | b66dca30420d414e6203117b2968fa6f8e883aac0d582bf378658753ce71c98b |
Hashes for lazy_object_proxy-1.6.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b865b01a2e7f96db0c5d12cfea590f98d8c5ba64ad222300d93ce6ff9138bcad |
|
MD5 | f3ad09042bf8850b2f5032850fb3a7e3 |
|
BLAKE2b-256 | 31f419e265c3ded483829cf5310748a5724db94d20946ae197a5c1819d061f46 |
Hashes for lazy_object_proxy-1.6.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1c2676e3d840852a2de7c7d5d76407c772927addff8d742b9808fe0afccebdf |
|
MD5 | e43b5400d7e6330a08b0efde1171aa47 |
|
BLAKE2b-256 | c931cfe96235f4121cb020820bb01c5d2b7306d4e3c93901413a92a886c0811b |
Hashes for lazy_object_proxy-1.6.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85fb7608121fd5621cc4377a8961d0b32ccf84a7285b4f1d21988b2eae2868e8 |
|
MD5 | bf7dc9263005996c0885117728376b73 |
|
BLAKE2b-256 | f46f0bf517a97bf0123025ced84986b81a181c73a0ad650db7f658f1138b092a |
Hashes for lazy_object_proxy-1.6.0-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 410283732af311b51b837894fa2f24f2c0039aa7f220135192b38fcc42bd43d3 |
|
MD5 | fb59e0f4ac806b05471585b2ed1a4369 |
|
BLAKE2b-256 | 62c680e0f4eba49f7e76f9ccf15a4fabdaf28b3c9fb053ff61b0c5cec65b53c4 |
Hashes for lazy_object_proxy-1.6.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17e0967ba374fc24141738c69736da90e94419338fd4c7c7bef01ee26b339653 |
|
MD5 | 6efc6621acad8011aadf430f795e8bad |
|
BLAKE2b-256 | 87c4da8ed7f77c85347c0bc50911d27faa563b85b46d136f8ce6c0f8d05f610d |
Hashes for lazy_object_proxy-1.6.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a5045889cc2729033b3e604d496c2b6f588c754f7a62027ad4437a7ecc4837 |
|
MD5 | cbc01a63af666e572e454fced9cb445a |
|
BLAKE2b-256 | b885fc16a62b5ac11dac4c271fd367e3537a83f288061f9866b4fa7da6736628 |
Hashes for lazy_object_proxy-1.6.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d397bf41caad3f489e10774667310d73cb9c4258e9aed94b9ec734b34b495fd |
|
MD5 | 1ede78c5a4145bbc566e18311b007428 |
|
BLAKE2b-256 | bf072c297ee6328b69f0e8d553825656d1c225dd7aba7b5c047709fbaf992249 |
Hashes for lazy_object_proxy-1.6.0-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22ddd618cefe54305df49e4c069fa65715be4ad0e78e8d252a33debf00f6ede2 |
|
MD5 | e8782e20afbe3855772cb8047c6f3486 |
|
BLAKE2b-256 | cf528190504939b9610ac0817a05c56ada148d0e1f3bdc387570275c175e499c |
Hashes for lazy_object_proxy-1.6.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7124f52f3bd259f510651450e18e0fd081ed82f3c08541dffc7b94b883aa981 |
|
MD5 | 3cb348ad12313fe75ab21a96c809d934 |
|
BLAKE2b-256 | 6eb0f055db25fd68ab4859832a887c8b304274fc12dd5a3f8e83e61250733aeb |
Hashes for lazy_object_proxy-1.6.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f60460e9f1eb632584c9685bccea152f4ac2130e299784dbaf9fae9f49891b3 |
|
MD5 | df2966082a0e0cb00fab1c973ec2a5af |
|
BLAKE2b-256 | 0140f895cdd92d7876f276f25766c0b9f0cbf860a76cae18e15a129d5890f15a |
Hashes for lazy_object_proxy-1.6.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b579f8acbf2bdd9ea200b1d5dea36abd93cabf56cf626ab9c744a432e15c815f |
|
MD5 | ba35e8ce2179b6cc66fd3f6c53d3c44a |
|
BLAKE2b-256 | ec4eecdece3b3af47c97bca1a7d503f7671441364d71e2e3385ae23cda0a702d |
Hashes for lazy_object_proxy-1.6.0-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf34e368e8dd976423396555078def5cfc3039ebc6fc06d1ae2c5a65eebbcde4 |
|
MD5 | 3f1b2653992510a08c4ea8c2357adb3d |
|
BLAKE2b-256 | 1213e126336e750874410290709cdb6304f5143f70166b29afbcf6ffdb0691ea |
Hashes for lazy_object_proxy-1.6.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5743a5ab42ae40caa8421b320ebf3a998f89c85cdc8376d6b2e00bd12bd1b587 |
|
MD5 | 884d13a7bf05fe9e6d124b7ede0a7ff0 |
|
BLAKE2b-256 | 46d477e45a07602cfddc0d32bac3feaf4f548de56744a9436d31cb3b00aa96c2 |
Hashes for lazy_object_proxy-1.6.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d900d949b707778696fdf01036f58c9876a0d8bfe116e8d220cfd4b15f14e741 |
|
MD5 | 9dd1f125cdf109a517bd9e24872986ed |
|
BLAKE2b-256 | 4738a1c09bf77d6a161bb42e8f81b6144e6e4e2d9b3eb32e0acad139033e8cb7 |
Hashes for lazy_object_proxy-1.6.0-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed361bb83436f117f9917d282a456f9e5009ea12fd6de8742d1a4752c3017e93 |
|
MD5 | f5297c8cfbf5a28c48e67c6a5161730c |
|
BLAKE2b-256 | fda69ed6cfc82cb482f2f22c2837d8fc825bce15e69fb7ee0468d5a07886d789 |
Hashes for lazy_object_proxy-1.6.0-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebfd274dcd5133e0afae738e6d9da4323c3eb021b3e13052d8cbd0e457b1256e |
|
MD5 | 28f45e437eaf5ded56ca25a80fc3fa38 |
|
BLAKE2b-256 | 9a23808e15b2d75755be50f91c5feb54290e6b7e743342dec794f8b5d20390bd |
Hashes for lazy_object_proxy-1.6.0-cp27-cp27m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6938967f8528b3668622a9ed3b31d145fab161a32f5891ea7b84f6b790be05b |
|
MD5 | d4de51675ff29978fde628614a468edd |
|
BLAKE2b-256 | 5d5df7a2ae1d9e6b6c536ae8adc6f6d190590fe9b5d7a174da0f5b03013c59cb |