Skip to content

*Proof-of-concept*: hack Python's bytecode for allowing pipelines

License

Notifications You must be signed in to change notification settings

vollcheck/pypelines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pypelines

pypelines allows you to use | like in the Unix shell.

Look at that (really dumb) example:

from pypelines import pypeline

def mul_two(x):
    return x * 2


@pypeline()
def hard_computations(x):
    return x | mul_two


hard_computations(210)   # => 420

It's also possible to call anonymous functions:

from pypelines import pypeline


@pypeline()
def hard_computations(x):
    return x | (lambda x: x * 2)

In case you want to make interesting, functional stuff, partial is on your command:

from functools import partial

from pypelines import pypeline


@pypeline()
def even_more_interesting_computations(x: int) -> list:
    return x | range | partial(map, lambda x: x * 2) | list



even_more_interesting_computations(10)  # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

Also there is more interesting examples in usage file.

Inspiration

This bytecode play is heavily inspired by the: borzunov's plusplus package.

About

*Proof-of-concept*: hack Python's bytecode for allowing pipelines

Topics

Resources

License

Stars

Watchers

Forks

Languages