Skip to main content

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.3

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

Source distribution (sdist)

Source distribution for iifunc 0.0.3
File Size Uploaded Provenance Actions
iifunc-0.0.3.tar.gz 3.3 kB Without provenance Details for iifunc-0.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 6.7 kB

Release files / iifunc-0.0.3.tar.gz

Download URL iifunc-0.0.3.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
02de0cfbb73ac368c51328aaaf56af48dc03b9c4dcb70e4a06b63bf3d9a5080d
BLAKE2b-256 checksum
How to use checksums
27a4d51c9a3f4093325b5172adeb734cda3851244a27005ad654bf4e693f4c4e
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.3-py3-none-any.whl

Download URL iifunc-0.0.3-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6429f0be4eeb72f54a4cea248803e3cfbdadbc42221478a06c7131ef1f6b56ba
BLAKE2b-256 checksum
How to use checksums
8f6fe6c241f8e538d192cd52a45e5fcb3badc35b968ab79b2ebd09967dfc71f4
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.3

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.

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