Python and Lua (2019)
The Python-only version can be sped up using vectorized numpy operations:<p><pre><code>  import time
  from PIL import Image
  import numpy as np
  
  def PyMandelbrot(size):
      t1 = time.time()
      xPts = np.arange(-1.5, 0.5, 2.0 &#x2F; size).reshape((1, size))
      yPts = (np.arange(-1, 1, 2.0 &#x2F; size) * 1j).reshape((size, 1))
      cs = xPts + yPts
      z = np.zeros_like(cs)
      red = np.zeros_like(cs, dtype=np.uint8)
      mask = np.full_like(cs, True, dtype=np.bool_)
  
      max_idx = 0
      while max_idx &lt; 199:
          np.putmask(z, mask, np.multiply(z, z) + cs)
          np.putmask(red, mask, red + 1)
          mask &amp;= np.abs(z) &lt; 2
          max_idx += 1
  
      dt = time.time() - t1
      print(f&quot;dt={dt:.2f}&quot;)
      zeros = np.zeros_like(red)
      pixels = np.dstack((red, zeros, zeros))
      Image.fromarray(pixels).show()
  
  if __name__ == &#x27;__main__&#x27;:
      PyMandelbrot(1_280)
</code></pre>
On my machine (Core i9, Win 10, CPython 3.7):<p><pre><code>  &gt; python .\mandelbrot_orig.py
  dt=32.01

  &gt; python .\mandelbrot.py
  dt=5.86
</code></pre>
I&#x27;m sure my version can be improved upon.