A lightweight streaming library, similar to Java stream.
Project description
SuperStream
在用使用过 Typescript 与 Java 方便的链式调用后,回到 Python 再想实现同样的功能 高阶函数的套娃让你很痛苦吧? 性能开销都在其次,主要是写着蛋疼啊!
现在一个轻量级流式处理工具来了,利用 python 内置特性,他可以轻松实现
- 更高的可读性
- 惰性求值(无论中途map,filter多少次,数据只在最后遍历一次)
- 完善的类型提示,即使你使用 lambda
安装
pip install superstream
使用
与 java stream 的对照
- 暂不支持并行 parallel
- 大部分功能已支持,行为相同
主要方法支持列表
- map
- forEach
- filter
- reduce
- sorted
- limit
- skip
- count
- min/max
- distinct
- flatMap
- findAny/findFirst
- anyMatch/allMatch/noneMatch
- of
- collect(toList/toSet/toMap/groupingBy)
| Java Stream | Python Stream | 备注 |
|---|---|---|
| filter | filter | |
| map | map | |
| flatMap | flat_map | |
| collect | collect | |
| collect(groupingBy) | group_by | |
| collect(toList) | to_list | |
| collect(toSet) | to_set | |
| collect(toMap) | to_dict | |
| collect(toMap) | to_map | to_dict 的别名,保持与 Java 的一致 |
| distinct | distinct | |
| sorted | sorted | |
| peek | - | peek 在 java stream 多为调试功能, python stream 将不会实现,可用 map 并返回元素本身代替 |
| limit | limit | |
| skip | skip | |
| forEach | for_each | |
| reduce | reduce | |
| count | count | |
| min | min | |
| max | max | |
| findAny | find_first | findAny 可用 findFirst 代替 |
| findFirst | find_first | |
| anyMatch | any_match | |
| noneMatch | none_match | |
| allMatch | all_match | |
| of | of | |
| empty | - | 我在业务中没用过这个方法,如果有需要我会提供 |
| iterate | - | 不常用,不会提供 |
| generate | - | 不常用,不会提供 |
| concat | - | 不常用,不会提供 |
| mapToInt | - | 不提供 |
| mapToLong | - | 不提供 |
| mapToDouble | - | 不提供 |
| flatMapToInt | - | 不提供 |
| flatMapToLong | - | 不提供 |
| flatMapToDouble | - | 不提供 |
FAQ
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
SuperStream-0.2.6.tar.gz
(5.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
File details
Details for the file SuperStream-0.2.6.tar.gz.
File metadata
- Download URL: SuperStream-0.2.6.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b3000ef3a3d1bc912e756ec13ff3a2bbe09fb9667038c1d9225079cf3f749ae
|
|
| MD5 |
d1b642b340f6a444a68604777ca87e17
|
|
| BLAKE2b-256 |
f994c3617622a2896ed66f583d7cccf442448080854bc70b7df03d308f58b72e
|
File details
Details for the file SuperStream-0.2.6-py3-none-any.whl.
File metadata
- Download URL: SuperStream-0.2.6-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bbc8fe7fa252359d3471ca7b0bba32501194f22ae89018cc3eac8a5e81ab170
|
|
| MD5 |
98928ec551da12598e5f9c69576ed4db
|
|
| BLAKE2b-256 |
85ef86991d75fff5512784c5846cab064804e43ae675bea70e3f607cb453e1d8
|