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.3
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 | |
|---|---|---|---|---|
| a_kits-0.0.3.tar.gz | 3.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| a_kits-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / a_kits-0.0.3.tar.gz
| Download URL | a_kits-0.0.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
810988f9257054d56f62dc340400dc0b65d4d4553dbc56642934f3fb9cbece29
|
|
BLAKE2b-256 checksum How to use checksums |
498ee4bcebf1fc8c813762e527c224874503d242b9ec5ecdef6aa7655d0a7fb5
|
| 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.3-py3-none-any.whl
| Download URL | a_kits-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
863a398f1ceef6707c926468844a1521efb5b45b4f04c82cc01f651e248a4339
|
|
BLAKE2b-256 checksum How to use checksums |
744a6a1ea38ae27dae439464a9c43143f5183ba6cbe9490e059f80e3f8fbe61e
|
| 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.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.