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.4.tar.gz
(25.0 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.4-py3-none-any.whl
(30.6 kB
view details)
File details
Details for the file ygo-1.0.4.tar.gz.
File metadata
- Download URL: ygo-1.0.4.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4cd19857b411a8433ad0f27782d7488dd810e20ab796b85aa66c146263dbe7d
|
|
| MD5 |
2f34747dfabf0408df93db4bbb3f1055
|
|
| BLAKE2b-256 |
a8aa20a9cc436878255a241b42761e14a56131ac3649c25e87ed24e16d30bc99
|
File details
Details for the file ygo-1.0.4-py3-none-any.whl.
File metadata
- Download URL: ygo-1.0.4-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1107633d9da8fdd6c99f1614542ccda3d2cb4e1b01e0329bcf66b2e4f122fae
|
|
| MD5 |
1eee354e0f90b0db27b190ed9921f91b
|
|
| BLAKE2b-256 |
837873a2d2f789e458694e4a2322a46bc981248de5b9ed0a93733ec337368512
|