One of the most time taking part while working with images in Blender is to get pixels to numpy arrays and then to assign them back. As Blender supports multi-thread render I've thought it could be possible to make an image processing faster using
concurrent.futures like this (the script adds 10 images, 10 numpy arrays and assigns arrays as images' pixels):
import bpy, concurrent.futures, time import numpy as np def test(counter, multi): t1 = time.perf_counter() x = 1920 y = 1080 px = x*y*4 images = bpy.data.images counts = [i for i in range(counter)] all_images =  for i in counts: num = np.ones(px, dtype = 'f') name = 'imgtest_'+str(i) new = images.new(name, x, y) all_images.append(new) if multi: def pixels(img): img.pixels[:] = num[:] with concurrent.futures.ThreadPoolExecutor() as executor: executor.map(pixels, all_images) else: for img in all_images: img.pixels[:] = num[:] t2 = time.perf_counter() print(t2-t1) test(10, True) test(10, False)
But it gives almost no time benefit. Also I've tried to split pixels lists to slices and process them with threading, but it doesn't speed up processes as well. I've never used threading before. Am I doing something wrong here or does Blender just not support threading for such tasks?