Skip to main content

streamcpy: The Stream Api in Python

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.

Metadata

Release files for streamcpy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamcpy 1.0.1
File Size Uploaded Provenance
streamcpy-1.0.1.tar.gz 15.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamcpy 1.0.1
File Interpreter ABI Platform
streamcpy-1.0.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details

Total release size: 41.1 kB

Release files / streamcpy-1.0.1.tar.gz

Download URL streamcpy-1.0.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
06e40bacee5c7062543ca39e4a055b82decbaed06a323f7ab47f2cbeb3f5badb
BLAKE2b-256 checksum
How to use checksums
14b0e141f62b817af59c3087bf43e54359549339d30240e60b8803db009c7428
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / streamcpy-1.0.1-cp39-cp39-win_amd64.whl

Download URL streamcpy-1.0.1-cp39-cp39-win_amd64.whl
Size 25.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
8c1f597ab000f7a910af58c6db1a96afdd10bacaba12ac90d9525b3f28dcb949
BLAKE2b-256 checksum
How to use checksums
fa33b4c2885b17f61b4e6164d73942aaae7e015c06c8657050a4b1ed92b8df6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for streamcpy 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page