-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
This is not a bug report but just an enhancement proposal.
I think it would be useful and important to be able to easily set the number of threads used by Numpy after Numpy import.
From the perspective of library developers, it is often useful to be able to control the number of threads used by Numpy, see for example biopython/biopython#1401.
It is not difficult to do in a simple script when we are sure that Numpy or Scipy have not been imported previously with something like:
import os
os.environ["OMP_NUM_THREADS"] = "1"
import numpy as np
However, in a library there is a good chance that the user has already imported Numpy in its main script, with something like
import numpy as np
import fluidimage
In this case, I don't see how to set the number of threads used by Numpy from the fluidimage code.
Thus, it would be very convenient to have a function np.set_num_threads
.