The Stream Api in Python
Project description
Streamcpy can provide an approach of processing the data in a high-effenciency way. Like in Java, you can use stream-like methods (map, filter, for_each and so on) to do parrallel calculation and lazy calculation, which can accelerating your programs. What’s more, The package is implemented in pure C, which means its runtime speed is even higher!
Currently, the methods bellow is implemented.
☒ filter
☒ map
☒ for_each
☒ collect
☒ distinct
☒ limit
☒ reduce
☒ sorted
☒ max/min
☒ count
☒ any_match/all_match
Installation
(Not Uploaded yet)
Usage
Like Stream Api in Java but slightly different in details
from streampy import *
Stream.of([1, 2, 3])
.map(lambda x: x * x)
.for_each(lambda x: print(x))
This api supports various Iterable object in Python, like list, tuple and generator. As a result, you can call it in these ways:
from streampy import *
Stream.of((1, 2, 3))
.map(lambda x: x * x)
.for_each(lambda x: print(x))
# OR
def gen():
l = [1, 2, 3]
for i in l:
yield i
g = gen()
Stream.of(g)
.map(lambda x: x * x)
.for_each(lambda x: print(x))
# OR
Stream.of(open("foo.txt", 'r'))
.map(lambda x: x * x)
.for_each(lambda x: print(x))
Contribution
Welcome to contribute to the project. The project is written in C. If you cannot understand Python’s C API, you can refer to the code in python package. It is the streamcpy implemented in python but will not be packed in the package. Here is the detailed description for each directory or file:
benchmark: a roughly comparison between Python and C++ (Python wins)
build: the built file of the package (.pyd for Windows and .so for Linux or Mac)
modules: the source code for streamcpy in C
python: the source code for streamcpy in python and only for reference
vs: the project files for Visual Studio
setup.py: the setup file for python
streamcpy.c: the entrance file for streamcpy package
streamcpy.pyi: the .pyi file for streamcpy package
Build on Windows
Download and install the latest Visual Studio
Install Python Development workload. The workload includes the Python native development tools, which bring in the C++ workload and toolsets that are necessary for native extensions
Install Desktop Development with C++ workload. It comes with the default core editor, which includes basic code editing support for C/C++
Double-click the .vcxproj in vs folder and build the .sln file
Run the project!
Build on Linux/Mac
Download the Python interpreter from the offcial website
Download the gcc(>7.5.0)
Run the command below for building
python setup.py build
Run the command below for installing
python setup.py install
NOTE: The method is also suitable for Windows if Visual Studio or Visual Studio Build Tools installed.
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
Built Distribution
File details
Details for the file streamcpy-1.0.1.tar.gz
.
File metadata
- Download URL: streamcpy-1.0.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e40bacee5c7062543ca39e4a055b82decbaed06a323f7ab47f2cbeb3f5badb |
|
MD5 | c21a09baec5ed75b8bdd8c71a1c699a5 |
|
BLAKE2b-256 | 14b0e141f62b817af59c3087bf43e54359549339d30240e60b8803db009c7428 |
File details
Details for the file streamcpy-1.0.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: streamcpy-1.0.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 25.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1f597ab000f7a910af58c6db1a96afdd10bacaba12ac90d9525b3f28dcb949 |
|
MD5 | 3fd438921957f554b683fc3e70e3f9eb |
|
BLAKE2b-256 | fa33b4c2885b17f61b4e6164d73942aaae7e015c06c8657050a4b1ed92b8df6f |