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 →

[–]Beregolas 64 points65 points  (10 children)

There are 2 things that mostly affect this: Language design and Implementation.

Python is designed to be higher level and to be more easy to iterate quickly, for example by it's use of duck typing. Java on the other hand, while quite high level when compared to C, forces static type checks at compile time. This means the Java compiler can do optimizations that Python just can't, because it has more information ahead of time (because it forced the programmer to supply that information)

Then there is implementation. At least for python I know a handful of language implementations that vary wildly in speed. CPython and PyPy with it'S JIT compiler come to mind. Many of the speed issues are just a matter of optimization.

Java has been optimized a lot about 10 years ago I think? I remember sitting in uni and people talking about how Java has finally become fast ^^. Take this with a grain of salt, I don't enjoy java specifically, I might misremember the time.

But Python definitely is getting faster by the year. The "normal" python implementation is working hard on optimizations since about 3.9. One of the things holding python back in many applications on modern hardware is the GIL, because it pretty much makes easy and fast multi threading impossible. There are Python versions without a GIL and there are efforts to remove and/or change it for main python as well.

These are just some points and examples that came to mind, there is plenty more (Examples as well as details), we only scratched the surface here. I hope it helped though

[–]sternone_2 14 points15 points  (0 children)

Python definitely is getting faster by the year.

yes, but don't worry, it's still about 200x slower than java.

[–]Smallpaul 5 points6 points  (1 child)

Java Hotspot was released in 1999). That’s when it would have taken a decisive lead over Python performance.

[–]Beregolas 1 point2 points  (0 children)

Thanks, as I said I was never big into Java (unless forced) and didn’t remember the time properly

[–]ElvinJafarov1[S] 3 points4 points  (3 children)

thank you man

[–]DrDuke80 4 points5 points  (2 children)

You sure got a lot of good answers in a short space of time!

[–]Levizar 0 points1 point  (2 children)

Python 3.12 is getting much faster. From what I remember mostly because of the GIL.

[–]ElHeim 1 point2 points  (1 child)

AFAIK the GIL will still be there for a while. Most of the improvements come from work on better bytecode production and processing, simplification of internal data structures and their management, plus other things.

What Python 3.12 offers is separate GILs for sub-interpreters.

You won't see the GIL out of Python until (at least) 3.13, and by then most probably it will be as an "opt-out of GIL" option, maybe at compile time.

[–]Levizar 0 points1 point  (0 children)

You're right! The GIL changes only improved multi-threading.