python – Defining pipelines of functions when passing a main argument across multiple functions


Discovering sk-learn pipelines (https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html) made me wonder why weren’t I using the same idea for any set of functions applied to a single main argument.
Based on this idea I developed the following code (Using kwargs treatment from https://stackoverflow.com/a/58543357):

import inspect
def create_sequential_pipe(func_list):
    """
    Create a pipeline for a series of functions to be applied to a single main argument

    Args:
        func_list: List of functions
    """

    def sequential_pipe(main_arg, **kwargs):

        for func in sequential_pipe._func_list:

            func_args = (k for k, v in inspect.signature(func).parameters.items())
            func_dict = {k: kwargs.pop(k) for k in dict(kwargs) if k in func_args}
            main_arg = func(main_arg, **func_dict)

        return main_arg

    sequential_pipe._func_list = func_list

    return sequential_pipe


def example_func_1(n, power=1):
    return n ** power


def example_func_2(n, sum=0):
    return n + sum


def example_func_3(n, divide=1):
    return n / divide


if __name__ == "__main__":

    example_pipe= create_sequential_pipe((example_func_1, example_func_2, example_func_3))

    out = example_pipe(2)
    print(out)  # 2.0

    out = example_pipe(2, power=2, sum=1, divide=5)
    print(out)  # 1.0

I feel I could get used to its use, but I couldn’t find something similar already implemented in Python, so I feel there must be a downside I am not seeing.

I could just create a wrapper function for the pipeline of functions, but I’m not sure it would be as simple.
Is there something similar commonly used in other languages? Do you think it’s obfuscates the code? Are there clear downsides to using this?