Skip to content

Commit 2f5e1a5

Browse files
committed
this is slightly faster
1 parent 73c5e77 commit 2f5e1a5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

examples/extensions/python/mandel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def mandelbrot(N,
1717
m = np.zeros((N, N), dtype=np.int32)
1818

1919
for i in range(1, max_iter+1):
20-
z[m == 0] = z[m == 0]**2 + c[m == 0]
21-
22-
m[np.logical_and(np.abs(z) > 2, m == 0)] = i
20+
idx = m == 0
21+
z[idx] = z[idx]**2 + c[idx]
22+
m[np.logical_and(np.abs(z) > 2, idx)] = i
2323

2424
return m

0 commit comments

Comments
 (0)