iifunc
English | 中文
把普通函数组合成管道,不需要类或框架。
安装
pip install iifunc
用法
from iifunc import compose, pipe
def double(x): return x * 2
def bump(x): return x + 1
pipe(double, bump)(3) # bump(double(3)) == 7
compose(double, bump)(3) # double(bump(3)) == 8
pipe()(5) # 5
clean = pipe(str.strip, str.lower)
clean(" ABC ") # 'abc'
说明
pipe 从左到右(g(f(x))),compose 从右到左(f(g(x)));不传参数返回恒等函数,生成的管道不用特判空列表。额外实参只给第一个被调用的函数,后续每级只收一个值。
许可证
MIT
English
Compose functions into a pipeline, right to left or left to right.
Install
pip install iifunc
Usage
from iifunc import compose, pipe
def double(x): return x * 2
def bump(x): return x + 1
pipe(double, bump)(3) # bump(double(3)) == 7
compose(double, bump)(3) # double(bump(3)) == 8
pipe()(5) # 5
clean = pipe(str.strip, str.lower)
clean(" ABC ") # 'abc'
Notes
pipe reads left to right (g(f(x))), compose right to left (f(g(x))). No arguments gives the identity function. Extra arguments go only to the first function; later stages take exactly one value.
License
MIT
Metadata
Release files for iifunc 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iifunc-0.0.4.tar.gz | 3.2 kB | Without provenance | Details for iifunc-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iifunc-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for iifunc-0.0.4-py3-none-any.whl |
Total release size: 6.7 kB
Release files / iifunc-0.0.4.tar.gz
| Download URL | iifunc-0.0.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f0a32230e68050f77fbf493f95f35979642aa02bf2b86362b4d70adfa30faba
|
|
BLAKE2b-256 checksum How to use checksums |
dcd49edcf13af3f2d6b3c30b5149e89be35715cc54dd2f149a9fef51b0eeb77a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / iifunc-0.0.4-py3-none-any.whl
| Download URL | iifunc-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a6a04e0870d9ce28f6f6f9438633ff7e99aa20bd56b47edeaab974afd1c539e
|
|
BLAKE2b-256 checksum How to use checksums |
139a2dd77562bcf9abbb2b15ba6e8e7ba4ea61ae8088f1f1d7c3a67b4dd2e52d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for iifunc 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.