welcome to the Plugin Café and thank you for reaching out to us. While Python, both our interpreter and the vanilla CPython interpreter, offers parallelism, the module
threading is not the parallelism you want. There are two variants of parallelism in most languages:
- Parallelism just for the sake of parallelism, this form often slows code down and is only meant to decouple things (a GUI from its logic for example).
- Parallelism to improve the speed of execution. The classical example is sorting. You want to sort 100e6 elements and implement a parallelized sorting algorithm which does the job in 10% of the time a sequential algorithm requires.
In Python you can achieve the first form of parallelism with
threading or in our Python flavor with
c4d.threading (which are entirely different modules, and you must use ours). This form of parallelism is mostly meant to provide something like non-blocking GUIs, handle user inputs in a non-block manner, etc. CPython offers the module
multiprocessing for providing the second form of parallelism, but it is sort of a hack, as Python cannot do "make-code-run-faster"-parallelism due to how the GIL works, and
multiprocessing is just an elaborate way of running two (or more) interpreters in parallel. The module
multiprocessing is not supported by our interpreter, and while you can make it run, it will result in odd behaviors.
Or to quote myself from the docs:
Please note that C4DThread, just as its native Python counterpart threading.Thread, is a mechanism to decouple the execution of code, but not to speed it up. Its intended use is to make computationally complex tasks non-blocking for the main-thread of Cinema 4D and by that ensure the responsiveness of the user interface. Parallelism in the sense of executing multiple parts of a larger task in parallel is currently not offered by the Python SDK. This also applies by extension to the multiprocessing module of Python which offers such functionality but it is not supported by Cinema 4D. Trying to use C4DThread to speed up the parallel execution of such multiple parts task will not only yield no execution speed improvements but will most likely even be slower than a single threaded execution of the same task.