A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pypi.org/project/lazy-object-proxy/ below:

lazy-object-proxy · PyPI

A fast and thorough lazy object proxy.

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

You can also install the in-development version with:

pip install https://github.com/ionelmc/python-lazy-object-proxy/archive/master.zip
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.11.0 (2025-04-16) 1.10.0 (2023-12-15) 1.9.0 (2023-01-04) 1.8.0 (2022-10-26) 1.7.1 (2021-12-15) 1.7.0 (2021-12-15) 1.6.0 (2021-03-22) 1.5.2 (2020-11-26) 1.5.1 (2020-07-22) 1.5.0 (2020-06-05) 1.4.3 (2019-10-26) 1.4.2 (2019-08-22) 1.4.1 (2019-05-10) 1.4.0 (2019-05-05) 1.3.1 (2017-05-05) 1.3.0 (2017-05-02) 1.2.2 (2016-04-14) 1.2.1 (2015-08-18) 1.2.0 (2015-07-06) 1.1.0 (2015-07-05) 1.0.2 (2015-04-11)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4