Skip to main content

Generator-based operators for asynchronous iteration

Project description

https://coveralls.io/repos/github/vxgmichel/aiostream/badge.svg?branch=master https://travis-ci.org/vxgmichel/aiostream.svg?branch=master https://img.shields.io/pypi/v/aiostream.svg https://img.shields.io/pypi/pyversions/aiostream.svg

Generator-based operators for asynchronous iteration

Requirements

  • python 3.6

Example

import asyncio
from aiostream import stream, pipe

# This stream computes 11² + 13² in 1.5 second
xs = (
    stream.count(interval=0.1)         # Count from zero every 0.1 s
    | pipe.skip(10)                    # Skip the first 10 numbers
    | pipe.take(5)                     # Take the following 5
    | pipe.filter(lambda x: x % 2)     # Keep odd numbers
    | pipe.map(lambda x: x ** 2)       # Square the results
    | pipe.reduce(lambda x, y: x + y)  # Add the numbers together
)

# The stream can be awaited
loop = asyncio.get_event_loop()
result = loop.run_until_complete(xs)
print('11² + 13² = ', result)

# The stream can run several times
result = loop.run_until_complete(xs)
print('11² + 13² = ', result)

# Clean up
loop.close()

Operators

  • create operators (non-pipable):
    • iterate

    • just

    • empty

    • throw

    • never

    • repeat

    • range

    • count

  • transform operators:
    • map

    • enumerate

    • starmap

    • cycle

  • select operators:
    • take

    • take_last

    • skip

    • skip_last

    • filter_index

    • slice

    • item_at

    • get_item

    • filter

    • dropwhile

    • takewhile

  • combine operators:
    • map

    • zip

    • merge

    • chain

  • aggregate operators:
    • accumulate

    • reduce

    • to_list

  • timing operators:
    • space_out

    • timeout

  • misc operators:
    • action

    • print

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiostream-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

File details

Details for the file aiostream-0.1.1.tar.gz.

File metadata

  • Download URL: aiostream-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiostream-0.1.1.tar.gz
Algorithm Hash digest
SHA256 879bcd591f553b4205133fcf7e01baa58cc8dfb31284a067e0dbd37c57a7f8b2
MD5 eeaaf10843b5eaae7e9bd6d11d6389a3
BLAKE2b-256 2aaa87234bb12be107bb0eaae99f70b15209881bce35646eceff1c2083f3ec64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page