Is Python is too Slow?
Bryan Cafferky
YouTube Creator and Data and AI Consultant at BPC Global Solutions LLC
I had an interesting question in the comments on my YouTube video 'Python for Everything'. What do you do when Python is just too slow? It's a common question and I wanted to share my reply. Comment back with your thoughts.
Yes. Python is slow and the interesting thing is that in most languages that results in Yet Another Language to address the slowness. Not in Python. For example, Python is horrible as a data science language because it's arrays perform badly. The answer? Someone developed a super-fast array processing engine in C called NumPy and wrote a Python wrapper around it so Python is now very fast with arrays and this was extended to dataframes via Pandas. This is a common theme. PyOpenGL is wrapper that uses the OpenGL libraries to get fast dynamically perspective graphics. The key is to find the bottlenecks and optimize them. There may be libraries available with can help. Another example, PyGame supports game development by wrapping around C libraries and there are many such libraries for other uses. If you have a C library, you can write a Python wrapper and use it to speed things up. Also, there are multiple Python interpreters but most only know about CPython. Another, much faster alternative is call PyPy. See https://www.pypy.org/ This can improve performance massively. In my experience, every language has weaknesses, Python just taps into another language library to get around them. And because there is such a massive Python development community, these bottlenecks are disappearing quickly via new packages.
Chief Executive Officer at Wuhan Hengji technologies
4 年Not suitable for CPU intensive programming!
consultant
4 年Bryan Cafferky good informative blog
AI/ML & HPC | Computational Physicist
4 年And don't forget Dask-Rapids for big data in Python!