A Better Mandelbrot Set

How well optimised is the Mandelbrot Set code? What is meant by "well optimised"?

Too often one thinks solely of speed when considering optimisation. But perhaps there are other issues too which should be considered.

For the above code, the human interface is poor (need to edit the source and re-run to change any parameters), the accuracy is possibly not an issue, the algorithmic efficiency is rather basic, and so is the efficiency of its implimentation.

Is the code a complete mess? Not quite: it could be claimed that it was optimised for brevity and readability. And the human interface is not a complete disaster, for the mouse cursor is tracked with co-ordinates, and there is an option to save the image. Some Mandelbrot set generators simply produce an image file and expect one to find another program to view this image, and this code is a step above that, particularly as it updates the on-screen image whilst calculating.

But it could be better, and, as a small step in the direction of "better" the following is offered.


(Any error on running about colorama being insufficiently recent can be ignored, and arises from an inconsistency between the packages in Raspbian.)

What is better? There are three areas of improvement, and one of regression.