## question about cython performance twice slower than raw PyPy3

trying my usual notebook on PyPy3, I find a 20x slower performance with cython:

- 22 seconds under PyPy3 vs 1 second in Cpython
- not using cython, PyPy3 is quicker : 8 seconds vs 22 seconds ?!?
- time is also 8 seconds on "pure" cPython .... which doesn't look logical to me

==> Is it to be expected ?

==> Is it normal 'non-hpy nor cpyext' situation ?

```
import numpy as np
image = np.zeros((1024, 1536), dtype = np.uint8)
#from pylab import imshow, show
import matplotlib.pyplot as plt
from timeit import default_timer as timer
```

```
# Cython + Mingwpy compiler toolchain test
%load_ext Cython
```

```
%%cython -a
# with %%cython -a , full C-speed lines are shown in white, slowest python-speed lines are shown in dark yellow lines
# ==> put your cython rewrite effort on dark yellow lines
def create_fractal_cython(min_x, max_x, min_y, max_y, image, iters , mandelx):
height = image.shape[0]
width = image.shape[1]
pixel_size_x = (max_x - min_x) / width
pixel_size_y = (max_y - min_y) / height
for x in range(width):
real = min_x + x * pixel_size_x
for y in range(height):
imag = min_y + y * pixel_size_y
color = mandelx(real, imag, iters)
image[y, x] = color
def mandel_cython(x, y, max_iters):
cdef int i
cdef double cx, cy , zx, zy
cx , cy = x, y
zx , zy =0 ,0
for i in range(max_iters):
zx , zy = zx*zx - zy*zy + cx , zx*zy*2 + cy
if (zx*zx + zy*zy) >= 4:
return i
return max_iters
```

```
#Cython speed
start = timer()
create_fractal_cython(-2.0, 1.0, -1.0, 1.0, image, 20 , mandel_cython)
dt = timer() - start
fig = plt.figure()
print ("Mandelbrot created by cython in %f s" % dt)
plt.imshow(image)
```

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information