@jit(nopython=True)
def dot(a, b):
    res = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
return res

@jit
def compute_stuff2(array_to_compute):
    N = array_to_compute.shape[0]
con_mat = np.zeros((N, N))
p0 = np.zeros(3)
p1 = np.zeros(3)
q0 = np.zeros(3)
q1 = np.zeros(3)
p0m1 = np.zeros(3)
p1m0 = np.zeros(3)
q0m1 = np.zeros(3)
q1m0 = np.zeros(3)
p0mq0 = np.zeros(3)
for i in range(N):
    for j in range(i + 1, N):
        for k in range(3):
            p0[k] = array_to_compute[i, k]
p1[k] = array_to_compute[i, k + 3]
q0[k] = array_to_compute[j, k]
q1[k] = array_to_compute[j, k + 3]
p0m1[k] = p0[k] - p1[k]
p1m0[k] = -p0m1[k]
q0m1[k] = q0[k] - q1[k]
q1m0[k] = -q0m1[k]
p0mq0[k] = p0[k] - q0[k]
s = (dot(p1m0, q1m0) * dot(q1m0, p0mq0) - dot(q1m0, q1m0) * dot(p1m0, p0mq0)
    ) / (dot(p1m0, p1m0) * dot(q1m0, q1m0) - dot(p1m0, q1m0) ** 2)
t = (dot(p1m0, p1m0) * dot(q1m0, p0mq0) - dot(p1m0, q1m0) * dot(p1m0, p0mq0)
    ) / (dot(p1m0, p1m0) * dot(q1m0, q1m0) - dot(p1m0, q1m0) ** 2)
for k in range(3):
    con_mat[i, j] += (p0[k] + (p1[k] - p0[k]) * s - (q0[k] + (q1[k] - q0[k]
        ) * t)) ** 2
return con_mat
Межсегментное расстояние с использованием numba jit, Python