Metadata-Version: 2.5
Name: a-kits
Version: 0.0.3
Summary: Split any iterable into fixed-size or evenly sized batches.
Project-URL: Homepage, https://pypi.org/project/a-kits/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: batch,chunk,iterable,pagination,split
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# a-kits

[English](#english) | 中文

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

## 安装

```console
pip install a-kits
```

## 用法

```python
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

---

<a id="english"></a>
## English

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

## Install

```console
pip install a-kits
```

## Usage

```python
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
