Boy, when you said it was a naive realization, you probably werenβt joking!
But yes, a performance difference of one or two orders of magnitude is not a surprise when comparing a JIT-compiled optimized machine code with an interpreted language. An alternative Python implementation, such as Jython, which runs on a Java virtual machine, may be faster for this task; you could give him a whirlwind. Cython, which allows you to add static typing to Python and get C-like performance in some cases, may also be worth exploring.
Even when considering the standard Python interpreter, CPython, however, the question arises: is Python enough for this task? Will there be a time when you save a code entry in a dynamic language such as Python will offset the extra time it works? If you had to write this program in Java, would it be too much work to cost the problem?
Consider, for example, that a Python program running on a modern computer will be about as fast as a Java program running on a 10-year-old computer. The computer you had ten years ago was fast enough for many things, right?
Python has a number of functions that make it great for numerical work. These include an integer type that supports an unlimited number of digits, a decimal type with unlimited precision, and an additional library called NumPy, specifically for calculations. However, the speed of execution, as a rule, is not one of the main claims to fame. Where this is excellent, you need to get the computer to do what you want with minimal cognitive friction.
source share