No project description provided
Project description
ygo
并发执行(加入进度条)以及延迟调用(基于joblib),以及获取对应函数的相关信息
安装
pip install -U git+https://github.com/link-yundi/ygo.git
示例
├── a
│ ├── __init__.py
│ └── b
│ ├── __init__.py
│ └── c.py
└── test.py
c.py 中定义了目标函数
def test_fn(a, b=2):
return a+b
场景1: 并发
import ygo
import ylog
from a.b.c import test_fn
with ygo.pool(job_name="test parallel", show_progress=True) as go:
for i in range(10):
go.submit(test_fn)(a=i, b=2*i)
for res in go.do():
ylog.info(res)
场景2: 延迟调用
>>> fn = delay(test_fn)(a=1, b=2)
>>> fn()
3
>>> # 逐步传递参数
>>> fn1 = delay(lambda a, b, c: a+b+c)(a=1)
>>> fn2 = delay(fn1)(b=2)
>>> fn2(c=3)
6
>>> # 参数更改
>>> fn1 = delay(lambda a, b, c: a+b+c)(a=1, b=2)
>>> fn2 = delay(fn1)(c=3, b=5)
>>> fn2()
9
场景3: 获取目标函数信息
>>> ygo.fn_info(test_fn)
=============================================================
a.b.c.test_fn(a, b=2)
=============================================================
def test_fn(a, b=2):
return a+b
场景4: 通过字符串解析函数并执行
>>> ygo.fn_from_str("a.b.c.test_fn")(a=1, b=5)
6
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
ygo-1.0.9.tar.gz
(25.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ygo-1.0.9-py3-none-any.whl
(31.2 kB
view details)
File details
Details for the file ygo-1.0.9.tar.gz.
File metadata
- Download URL: ygo-1.0.9.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8797c1c458ee8df01a52e71bdd08b86453239d6e5e9fdb39d91158ff6520cbb
|
|
| MD5 |
74a76ac2d8af7d74950383858585d5ea
|
|
| BLAKE2b-256 |
bae1f123625b93da2badfb3391da49acdeacac85ea4bc6c3dd92ad7b2c9ab7f8
|
File details
Details for the file ygo-1.0.9-py3-none-any.whl.
File metadata
- Download URL: ygo-1.0.9-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcaece3c0e6330b5414c7f3feecc1bf9c5e322585fac705636b35301cf54c19d
|
|
| MD5 |
7694869defb078564de0df70e92b27d6
|
|
| BLAKE2b-256 |
196774aaf439850cd61d563ea9191018d8818be42b1698dac424ca7b2d6babb6
|