Skip to main content

Lazy evaluation for Python.

Project description

Lazy evaluation for Python.

Build status Test coverage

PyPI Package latest release Supported implementations Supported versions PyPI Wheel


To use yzal:

from yzal import lazy, strict

def add(x, y):
    sum = x + y
    print('Adding {:d} + {:d} = {:d}', x, y, sum)

The following only creates a Thunk, it does not run the lazy function above.

>>> sum = add(3, 7)

There are two ways to get the result of the lazy evaluation. The first is simply to perform an operation that requires a strict value.

>>> 5 + sum
Adding 3 + 7 = 10

The second way is to explicitly request a strict value.

>>> sum = add(3, 7)
>>> strict(sum)
Adding 3 + 7 = 10


If we did not recreate the Thunk the side effect string would not have displayed again. This is because Thunk’s will only evaluate the lazy expression they contain once. Further requests for a strict value will return a cached result. It is important to remember this when the lazy function is not pure.



Python 3.4 support requires mypy.


yzal is on PyPI so the best way to install it is:

$ pip install yzal


We wish to thank the following projects, without which yzal would have been much harder to write:

Project details

Download files

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

Files for yzal, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size yzal-0.0.5.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View
Filename, size yzal-0.0.5-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page