Skip to main content

a-kits

English | 中文

把可迭代对象按固定大小分批,或均分成指定份数。

安装

pip install a-kits

用法

from a_kits import split_equal, split_fixed

split_fixed(range(5), 2)      # [[0, 1], [2, 3], [4]]
split_equal(range(7), 3)      # [[0, 1, 2], [3, 4], [5, 6]]
split_equal([1, 2], 3)        # [[1], [2], []]

说明

split_fixed 除最后一批外每批大小相同;split_equal 保证份数固定且各份大小相差不超过 1,余数分给靠前的份。尺寸或份数小于 1 抛 ValueError。

许可证

MIT


English

Split any iterable into fixed-size or evenly sized batches.

Install

pip install a-kits

Usage

from a_kits import split_equal, split_fixed

split_fixed(range(5), 2)      # [[0, 1], [2, 3], [4]]
split_equal(range(7), 3)      # [[0, 1, 2], [3, 4], [5, 6]]
split_equal([1, 2], 3)        # [[1], [2], []]

Notes

split_fixed gives every batch the same size except the last. split_equal always returns exactly the requested number of parts whose sizes differ by at most one, with the remainder going to the leading parts.

License

MIT

Metadata

Release files for a-kits 0.0.4

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

Source distribution (sdist)

Source distribution for a-kits 0.0.4
File Size Uploaded Provenance
a_kits-0.0.4.tar.gz 3.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for a-kits 0.0.4
File Interpreter ABI Platform
a_kits-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / a_kits-0.0.4.tar.gz

Download URL a_kits-0.0.4.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
43326625397e2044e2a3130638bdb1bdf284c3755732174be4bd8d76199fad22
BLAKE2b-256 checksum
How to use checksums
3fe327ef45cb3577de74701a9dae064af20950f9df569a1d4220ccd21ce67bda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / a_kits-0.0.4-py3-none-any.whl

Download URL a_kits-0.0.4-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8897f881f002a940c1fffebe8a6340661f70f6936543f88873b47e43b008044
BLAKE2b-256 checksum
How to use checksums
dfa20266a714bef78a3102a6c1db14c741ecbf44268d2f94f18619878bbfda95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for a-kits 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.

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