def count(a):
    cnt = 0
for x, i in enumerate(islice(a, 0, None)):
    for y, j in enumerate(islice(a, x + 1, None)):
        for k in islice(a, y + x + 2, None):
            if i + j + k == 0:
                cnt += 1
return cnt
Python very slow as compared to Java for this algorithm