No project description provided
Project description
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
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 Distribution
File details
Details for the file deferpy-1.0.1.linux-x86_64.tar.gz
.
File metadata
- Download URL: deferpy-1.0.1.linux-x86_64.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b787342bd91756998944a1f45c6b7381db55d9b3d0d1643edea92371d8fd25ed |
|
MD5 | 8e4ff2991a89f4b841c03f18f82052d8 |
|
BLAKE2b-256 | 3dbb3b1dc7a58a82fc88021ac08fcd40ef04cbc3e140e0c1e02642ef32b548b0 |
File details
Details for the file deferpy-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: deferpy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80e775f88ed2a46dc91baee7660972c6983063a17d90e7a3d07ce3a1279b9845 |
|
MD5 | 52a5f344d78e37cd71ae458731009259 |
|
BLAKE2b-256 | 6dd4f87220dcb32ef5b1dd91411049a3a258d36cf19646a96d3ec7b9ea379754 |