Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mokeyish/pyiter
PyIter is a Python package for iterative operations inspired by the Kotlin、CSharp(linq)、TypeSrcipt and Rust . Enables strong **typing** and type inference for iterative operations.
https://github.com/mokeyish/pyiter
chain-operation functional-programming linq typing
Last synced: 2 months ago
JSON representation
PyIter is a Python package for iterative operations inspired by the Kotlin、CSharp(linq)、TypeSrcipt and Rust . Enables strong **typing** and type inference for iterative operations.
- Host: GitHub
- URL: https://github.com/mokeyish/pyiter
- Owner: mokeyish
- License: apache-2.0
- Created: 2022-06-04T04:27:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T23:30:53.000Z (9 months ago)
- Last Synced: 2024-05-22T12:17:16.512Z (8 months ago)
- Topics: chain-operation, functional-programming, linq, typing
- Language: Python
- Homepage: https://pyiter.yish.org/pyiter/sequence.html
- Size: 1.62 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# PyIter
[![Pypi version](https://img.shields.io/pypi/v/pyiter?style=for-the-badge)](https://pypi.org/project/pyiter/)
PyIter is a Python package for iterative operations inspired by the Kotlin、CSharp(linq)、TypeSrcipt and Rust .
Enables strong **typing** and type inference for iterative operations.- Chain operations like map, reduce, filter, map
- Lazy evaluation
- parallel execution
- strong **typing**## Install
```bash
pip install pyiter
```## Quickstart
```python
from pyiter import it
from tqdm import tqdmtext = ["hello", "world"]
it(text).map(str.upper).to_list()
# ['HELLO', 'WORLD']words = 'I dont want to believe I want to know'.split()
it(words).group_by(lambda x: x).map(lambda g: (g.key, g.values.count())).to_list()
# [('I', 2), ('dont', 1), ('want', 2), ('to', 2), ('believe', 1), ('know', 1)]# use tqdm
it(range(10)).map(lambda x: str(x)).progress(lambda x: tqdm(x, total=x.len)).parallel_map(lambda x: x, max_workers=5).to_list()```
**Type inference**
![.](https://github.com/mokeyish/pyiter/raw/main/screenshots/screenshot.png)## API
See [API](https://pyiter.yish.org/pyiter/sequence.html) documention.
- You no need to read API documention. all functions are listed by the code completion as follows.
![.](https://github.com/mokeyish/pyiter/raw/main/screenshots/apilist.png)- All documentions are showed as follows.
![.](https://github.com/mokeyish/pyiter/raw/main/screenshots/apidoc.png)
## Similar libraries
Note that none of the following libraries are providing full strong typing for code completion.
- [Pyterator](https://github.com/remykarem/pyterator)
- [PyFunctional](https://github.com/EntilZha/PyFunctional)
- [fluent](https://github.com/dwt/fluent)
- [Simple Smart Pipe](https://github.com/sspipe/sspipe)
- [pyxtension](https://github.com/asuiu/pyxtension)## License
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or )at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.