`d_nan` and `d_ninf` are not used, you are right about that, but `d_inf` is used in the calculation of the return value of `DOUBLE_bray_curtis_distance`, `d_ninf` will come up in handling all possible values of the parameter of the Minkowski distance, and `d_nan` may eventually be used . All of these are [defined in `npy_math.h`](https://github.com/numpy/numpy/blob/d071d3f9d80886868c5ce790289f2af03bed43b1/numpy/core/include/numpy/npy_math.h#L53)  as a casting of the corresponding float values, so for performance you want to have them casted once and then stored in a local variable, which is what happens in `init_constants`, which is called at module initialization. The code structure is shamelessly copied from [the implementation of `umath_linalg.c.src`](https://github.com/numpy/numpy/blob/d071d3f9d80886868c5ce790289f2af03bed43b1/numpy/linalg/umath_linalg.c.src#L398)