Whatever it is that you’re using code for, it’s hard not to eventually become interested in the problem of optimization. Just as many people go from simply driving a car everyday to becoming fascinated by the mechanics of the underlying machine, software engineers often begin casting around for faster ways of solving problems.
Making software that’s lean, effective, and efficient is not only a great way to approach design, it’s also an intriguing question of engineering and computer science.
How Fast Is Python?
Python is a lightweight, flexible language that tends to be ‘fast enough’ for almost anything. While it isn’t built to execute as quickly as it possibly can, it does tend to make developers more effective so projects get done rapidly.
Python is comparable to interpreted languages like Ruby in terms of execution speed. One reason it isn’t as fast is it could be is due to the limitations of some of the underlying technology. Java compiles down to bytecode which is executed on a Java Virtual Machine, which makes it fast. Python goes through more high-level translation layers before it finally becomes code that the hardware understands. This slows it down. It isn’t impossible that the Python core developers could fix some of these issues and make a faster version of Python, and indeed there are projects aimed at doing this exact thing in the works.
It’s pretty hard to provide a general, all-purpose answer to this question. Speed varies tremendously by problem domain, implementation, and code design. Well-written algorithms will almost always outperform poorly-written ones, even when they’re written in ‘faster’ languages.
Given how fast modern computer hardware is, it’s pretty rare for developers to come up against serious latency problems stemming from language implementations that are just too slow. It happens in places like supercomputing and ultra-hardcore graphics processing, but almost nowhere else.