• # Comparaison avec numpy?

    Posté par . En réponse à la dépêche Numba 0.14. Évalué à 8.

    Et quelle est le gain de vitesse par rapport à une implémentation en pur numpy?

    def mandelbrot(width,height, max_iters):
     stepx = 4./(width-1.)
     stepy = 4./(height-1.)
     c = numpy.fromfunction(lambda x,y: 
     (-2.+x*stepx)+(-2+y*stepy)*1j, 
     (width, height))
     arr = numpy.zeros((width, height), 
     dtype=complex)
     for i in range(max_iters):
     arr = arr**2 + c
     return abs(arr)>=2.
    In [77]: time mandelbrot(200,200,20)
    CPU times: user 8 ms, sys: 0 ns, total: 8 ms
    Wall time: 6.29 ms

    Une implémentation avec plein de for imbriqués est forcément très lente...