COLS = 100
PATLEN = 20
a = np.random.rand(ROWS, COLS)
pattern = np.random.rand(PATLEN)
tmp = np.empty([ROWS, COLS - PATLEN])
for i in range(COLS - PATLEN):
    window = a[:, i:i + PATLEN]
tmp[:, (i)] = np.sum((window - pattern) ** 2, axis=1)
result = np.sqrt(tmp)
Fast algorithm to search for pattern within text file