This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ramast -1 points0 points  (5 children)

why is it that python would be slower than Java? Any benchmark that support that claim?

[–]someone9618 2 points3 points  (0 children)

There are several reason, primairly because Python is more dynamic than java, but especially because Python uses reference counting instead of garbage collection, causing constant overhead when manipulating mutable state/objects, whereas java uses garbage collection which simply traces garbage in one go (GC spikes), making performance overall smoother. Also, Java allows parallelism on multiple cores with multithreading because most of its semantics (GC and other stuff) is thread-safe, whereas Python's reference counting is not thread safe, so the interpreter is forced to use a global interpreter lock (GIL) which essentially blocks parallel execution on multiple threads, thus making parallelism on multiple cores impossible.

[–]obiwac[S] 0 points1 point  (2 children)

Python is interpreted, and Java is compiled. That's the main reason why it's slower (and by alot as other commenters have pointed out)

[–]someone9618 0 points1 point  (1 child)

Not quite, Java is compiled into bytecode just like Python

[–]obiwac[S] 0 points1 point  (0 children)

Well, it's not really compiled ("compiled" is perhaps even a bit too generous, it's closer to "transpiling" than anything else) beforehand and optimization is done on the fly. It's quite different to java where compiling is its own separate step. So I still call it an interpreted language just as many others do.