I'm computing a "similarity function", which mostly resembles the cosine similarity measure, although I apply a couple of tricks to deal with ordinal values and missing values.
These tricks basically consist on getting some pre-computed values from some dynamically generated (although "readonly") lookup tables (based on some data distributions).
The problem I'm having is that, when I convert my function into a numpy
's ufunc
with np.frompyfunc
, the fact that the function is accessing a "global" python object makes it impossible for numpy
to skip the GIL, and therefore it cannot vectorize/parallelize the execution of that function.
Is there any way to give "complete ownership" (in order to avoid the GIL) of a pre-calculated lookup table to these "ufuncs" (maybe passing a copy)? (taking into account that the values are not known at "coding time").
Thank you in advance.