Parallel for loop computation

I’m currently doing mix-coding with MATLAB and Python. Unfortunately in MATLAB ‘parfor’ function cannot call Python function if it returns a python object. So I would like to move the parallel for loop into my python function. Is there any descent way that I can do parallel for loop in python? I’m kinda new to python coding so maybe it is a very basic problem.

Kevin

Note sure about the nature of your loop, but if it is compute-bound, I would avoid using Python since its infamous GIL (global interpreter lock) will prevent more than one thread to run at the same time. If your loop is IO-bound you might want to check out Python’s asyncio or concurrent packages.