multiprocessing.Process - Variable as function
Question: I am using the code below to parallelize the processing of a numpy array. The
target function in this case performs a simple linear stretch on the input
data. The array is segmented and then fed to the pool in chunks. This is
working quite well thanks to the numerous parallel processing with python
posts.

    
    
            pool = [multiprocessing.Process(target=linear_stretch, args= (shared_arr,slice(i, i+step), 35, 200, 2.0)) for i in range (0, y, step)]
    

My question is, is it possible to do something like the following:

    
    
    stretch = Linear.linear_stretch()
    

Where I create an object of the function (please correct my vocab!) and then
call it in the multiprocessing.Process.

The module that the function resides in currently looks like:

    
    
    Linear.py
    
    import numpy
    
    def linear_stretch(args):
        #Do some stuff
    


Answer: Yes, like this:

    
    
    stretch = Linear.linear_stretch
    

In Python, functions are already first-class objects and are capable of being
manipulated like any other object, or passed by reference to another variable.
Note that parentheses after a function or method signals the interpreter to
call the function and pass the return value, which is why:

    
    
    stretch = Linear.linear_stretch()
    

will not work as expected.

