def einsum_based(A, B):
    subs = A - B
return np.sqrt(np.einsum('ijk,ijk->ij', subs, subs))

def numexpr_based(A, B):
    return np.sqrt(ne.evaluate('sum((A-B)**2,2)'))

def numexpr_based_with_slicing(A, B):
    a0 = A[..., (0)]
a1 = A[..., (1)]
b0 = B[..., (0)]
b1 = B[..., (1)]
return ne.evaluate('sqrt((a0-b0)**2 + (a1-b1)**2)')
Numpy: find the euclidean distance between two 3-D arrays