Skip to main content

Warning: Package under development... tons of side effects. Don't rely on it yet!

Metafunctions is an excellent package that allows you to compose functions into metafunctions using a pipe.

Instead of writing:

result = step3(step2(step1(data)))

#or
result_1 = step1(data)
result_2 = step2(result_1)
result_3 = step3(result_2)

You instead write:

pipeline = step1 | step2 | step3
result = pipeline(data)

Here's another example:

# load, parse, clean, validate, and format are functions
preprocess = load | parse | clean | validate | format

# preprocess is now a MetaFunction, and can be reused
clean_data1 = preprocess('path/to/data/file')
clean_data2 = preprocess('path/to/different/file')

# Preprocess can be included in larger pipelines
pipeline = preprocess | step1 | step2 | step3

"Then why are you making a new package?"

The problem is in the repetition:

You have to do this:

from metafunctions import node

@node
def get_name(prompt):
    return input(prompt)

@node
def say_hello(name):
    return 'Hello {}!'.format(name)

And then do this:

greet = get_name | say_hello

Why use the word "@node" over every function? what if I have a big class, or if I'm importing functions from other modules?

Do I have to go and decorate every single function in that module to use this syntax?

No!!111!!1

Unacceptable!

we're developers! We COMPRESS cycles of work, not EXPAND them...

With superfunctions, all you have to do is:

from superfunctions import decorate_all_modules
decorate_all_modules()

Make sure this is at the end of all your imports.

And you're done! That's it!

Wanna use functions from other modules? Piece of cake.

import numpy as np
from superfunctions import decorate_all_modules
decorate_all_modules()

g = np.random.rand | np.squeeze | np.sum | print
g(2,3)

Wanna use functions from files in the same directory/local modules?

greetsomeone.py

def get_name(name):
    return name


def say_hello(name):
    return 'Hello {}!'.format(name)

And importing from your main file:

from greetsomeone import *
from superfunctions import decorate_all_modules
decorate_all_modules()

greet = get_name | say_hello | print

BUT it doesn't yet work with all functions.

This is still alpha, and will break a lot and also give you errors you cannot comprehend or even debug!

What does it do?

It does something dangerous...

It decorates ALL functions in all imported modules with "@node" from metafunctions, and decorates all methods in all classes in all imported modules, and decorates all functions and methods in your current file.

Why is this dangerous?

Because this code hasn't been tested yet, we really have no idea of the side effects.

Why?

Because I've yet to test it!

Want to help me enhance it, test it, maintain it?

Contact me at youssef.avx@gmail.com

Like the package? Make me less broke by donating to

My paypal: youssef.avx@gmail.com

Bitcoin: 15PPdm9SBQAZAwRq6n5q5GLRb7jEZLqsyE

Ethereum: 0xe05e9887bDEa2793A062C2b29908dcd2BE080afA

Psst... if I had it my way I'd want it to get even closer to english like this:

find_first_word_in_titles = get_html parse_html get_titles get_first_word   

where we remove the pipe!

But I don't know how to implement this... oh well.

Metadata

Release files for superfunctions 0.1.3

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

Source distribution (sdist)

Source distribution for superfunctions 0.1.3
File Size Uploaded Provenance Actions
superfunctions-0.1.3.tar.gz 4.4 kB Without provenance Details for superfunctions-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superfunctions 0.1.3
File Interpreter ABI Platform Actions
superfunctions-0.1.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for superfunctions-0.1.3-py2.py3-none-any.whl

Total release size: 10.6 kB

Release files / superfunctions-0.1.3.tar.gz

Download URL superfunctions-0.1.3.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
42a979af043ad640cc42bf47fac6d6f0bc98bacde4189942731e223fd12b732f
BLAKE2b-256 checksum
How to use checksums
2c404feb1570468f0196d376ef5d6148987d17ffb938d01505c374342629c2d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.2

Release files / superfunctions-0.1.3-py2.py3-none-any.whl

Download URL superfunctions-0.1.3-py2.py3-none-any.whl
Size 6.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a092c9da8c26bd44a6f5797a181ab67c60ca2d571547c0f62549e196ec14c867
BLAKE2b-256 checksum
How to use checksums
4317d6b76f508d0e4f95d1d6a87a697a3906cc7441aa5394d72491d0a73a3baa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.2

Security for superfunctions 0.1.3

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.

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