Coder Social home page Coder Social logo

joshix-1 / typed_stream Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 565 KB

Typed Stream class for Python

Home Page: https://pypi.org/project/typed-stream/

License: European Union Public License 1.2

Python 96.95% Shell 2.93% Makefile 0.12%
iterators python3-library

typed_stream's Introduction

Typed Stream

License Python Implementation Total lines Code size Style: Black Imports: isort Coverage

Downloads Downloads Downloads

The Stream class is an iterable with utility methods for transforming it.

This library heavily uses itertools for great performance and simple code.

Examples

>>> import typed_stream
>>> # Get sum of 10 squares
>>> typed_stream.Stream.range(stop=10).map(lambda x: x * x).sum()
285
>>> # same as above
>>> sum(typed_stream.Stream.counting().limit(10).map(pow, 2))
285
>>> # sum first 100 odd numbers
>>> typed_stream.Stream.counting(start=1, step=2).limit(100).sum()
10000
>>> (typed_stream.Stream.counting()
...     .filter(typed_stream.functions.is_odd).limit(100).sum())
10000
>>> (typed_stream.Stream.counting()
...     .exclude(typed_stream.functions.is_even).limit(100).sum())
10000
>>> # Get the longest package name from requirements-dev.txt
>>> (typed_stream.FileStream("requirements-dev.txt")
...     .filter()
...     .exclude(typed_stream.functions.startswith("#"))
...     .map(str.split, "==")
...     .starmap(lambda name, version = None: name)
...     .max(key=len))
'flake8-no-implicit-concat'

In examples are more complex examples using Streams.

Not yet asked questions

I'll try to answer questions that could occur.

What do the versions mean?

I try to follow something similar to sem-ver. For versions before 1.0.0 this means the format is 0.<major>.<patch>. Any change that could be considered a breaking-change (adding things is not a breaking change) increases the major part. If only patch has changed, there was no breaking-change. I try to avoid changes that break my own code, so even if major has been changed, it should probably be safe to upgrade.

Why are there no changelogs?

I'm too lazy. I don't know of anybody using this (except me) and I don't need to write changelogs for myself. If you need changelogs, please create an issue.

Why EUPL-1.2-or-later?

Is it production-ready?

Probably.

typed_stream's People

Contributors

dependabot[bot] avatar joshix-1 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.