Is python faster than java?
sturlamolden at yahoo.no
Mon Aug 24 04:28:10 CEST 2009
On 23 Aug, 21:59, Emile van Sebille <em... at fenx.com> wrote:
> Speed of what? Development? User interaction? Responsiveness to queries?
My personal view on the 'Is Python faster than Java' question:
- Coding? Yes, if you program 'pythonic'.
- String handling? Often.
- I/O and networking? Often.
- Iteration? No.
- Function calls and recursion? No.
- Arithmetics with elemental types? No.
- Numerics? Yes, if you use NumPy.
Is never interesting which language generates the most efficient code.
If that were the case, we would be writing everything in assembly. If
the code is fast enough, it is fast enough. Fast enough is sufficient.
If some part of the code turn out to be too slow, we have two options:
Either we use faster hardware, which is often the cheapest solution.
Or we can alternatively try to move that part to something less high-
level (Cython, C, C++, Fortran, assembly). Unlike Java, Python
integrates easily with C.
Also beware that Python is not Java: There is an old saying that you
can write FORTRAN in any language. You can also write Java in Python.
It will be just as slow to program as Java, and it will run a lot
slower than Java. Most of the complaints about 'Python being slow'
stems from people writing Java in Python.
More information about the Python-list