Speed Up Python Script in PLAXIS 3D

Hi,

I am working on a python script for the random field analysis in PLAXIS 3D. I have one nested loop to read the random field parameters from a spreadsheet and assign them to desired spatial locations, however, it takes a couple of hours to finish one simulation. The most time-consuming code is: g_i.setmaterial(desired soil volume, materials), please note that I have millions of soil volumes to assign. I am wondering if the multiprocessing or multi-threads will help my problem, and is there another way to speed up the python script in PLAXIS.

Thanks!