Placing cubes in a grid is very slow (using python script)
As far as I can see the code creates for each data point a seperate Blender Mesh Object. For large datasets this will make everything super slow.
I would recommend you to create only one mesh per label-class so that with 3 label classes you would have only 3 Mesh Objects.

Since you are actually using my code, I took your question as feedback and updated it accordingly on github.
https://github.com/cagcoach/BlenderPlot