Skip to main content

deferpy

Deferred function calls are pushed onto a stack. When a function returns, its deferred calls are executed in last-in-first-out order.

The Go Blog has a good explanation of the behavior of defer. This package attempts to recreate the behavior as closely as possible.

Installation

 $ pip install deferpy

Usage

Check out the tests to see more examples.

>>> from deferpy import defer
>>> @defer()
... def function(a, b, c):
...     function.defer(print, a)
...     function.defer(print, b)
...     function.defer(print, c)
...     return a + b + c
... 
>>> print(function(1, 2, 3))
3
2
1
6
>>> @defer()
... def func():
...     for i in range(10):
...         func.defer(print, i)
... 
>>> func()
9
8
7
6
5
4
3
2
1
0

Metadata

Release files for deferpy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deferpy 1.0.1
File Size Uploaded
deferpy-1.0.1.linux-x86_64.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deferpy 1.0.1
File Interpreter ABI Platform
deferpy-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / deferpy-1.0.1.linux-x86_64.tar.gz

Download URL deferpy-1.0.1.linux-x86_64.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b787342bd91756998944a1f45c6b7381db55d9b3d0d1643edea92371d8fd25ed
BLAKE2b-256 checksum
How to use checksums
3dbb3b1dc7a58a82fc88021ac08fcd40ef04cbc3e140e0c1e02642ef32b548b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

Release files / deferpy-1.0.1-py3-none-any.whl

Download URL deferpy-1.0.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80e775f88ed2a46dc91baee7660972c6983063a17d90e7a3d07ce3a1279b9845
BLAKE2b-256 checksum
How to use checksums
6dd4f87220dcb32ef5b1dd91411049a3a258d36cf19646a96d3ec7b9ea379754
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page