Powerful and flexible, Python is often depicted as the ultimate all-purpose programming language, equally well suited to functional, object-oriented or reflective coding, and popular across data science, AI, web architecture and application development.
But it has one widely acknowledged drawback – compared to other popular languages, it’s slow to run.
It’s an issue that many in the development community are keen to address – and given its importance as a mainstream commercial development tool, these efforts are attracting major enterprise backing.
For example, a new Python iteration launched in May 2021, Pyston, has now been taken up by Anaconda, a well established Python distribution for data science uses. Pyston promises to speed up Python by 30%, and its creators have now been hired directly by Anaconda to continue their work.
Elsewhere, the man responsible for creating Python three decades ago, Guido van Rossum, has come out of retirement to take up a post at Microsoft. Given free rein to pick an open source development project of his choosing, van Rossum has decided to focus on a next gen revamp of his original masterpiece, promising to make Python twice as fast as it is at present.
With Microsoft’s considerable backing, you’d bet on it happening.
So what exactly would a faster Python mean for developers?
Lessening the load
Part of the reason why Python is slow is because it is dynamically typed. This means that, unlike with a statically typed, compiled language, the data types are not pre-defined. This gives Python a lot more flexibility, as you’re not restricted by the type categories already available – you can tell the computer that a data variable is whatever you want it to be. But it also means extra work, first of all for the programmer who has to define all the types themselves, and then for the machine that has to interpret the definitions at the point of execution.
As this article illustrates, for a simple mathematical formula, with Python you are talking about four times as many lines as code compared to a compiled language like C, all because you have to define and create new Python objects (i.e. specify that an integer is an integer, or whatever it mighty be). With a compiled language, you just use the pre-defined object ‘integer’.
Python gets labelled as a programming language best suited to back-end development, data analysis, AI, scientific computing and so on. In other words, it’s good for handling heavyweight, technical stuff where accuracy and performance is more of a concern than speed.
The huge amount of flexibility it offers is certainly a big help in this regard, and a lot of programmers working in these fields actually find the fact that they have to define everything less onerous than having to navigate a path through static frameworks or existing code that wasn’t really designed to do the job.
But the point is that these are all advanced skills. Expert Python programmers do find it fast and efficient. But it takes quite a learning curve to get to that point.