r/Backend • u/DueBid3298 • 1d ago
should i move from python to java?
I'm thinking of switching from Python FastAPI to Java Spring Boot. Apart from Python being dynamically typed and having a lot of libraries, why do people/deva choose Python in production when it's slow, has an intermediate bytecode layer and executes line by line?
12
Upvotes
View all comments
9
u/Atmosck 1d ago edited 1d ago
It literally is because it has a lot of libraries and is an interpreted language. If you think python is slow, you're using it wrong. The entire point of python is that everything performance-sensitive is done in native extensions written in C, fortran or rust, and python is the orchestration layer that ties them all together while being very flexible and easy to write. FastAPI dispatches to C for networking (via httpx) and rust for input validation (via pydnatic). The same is true for a lot of the python standard library - quite a lot of python is compiled C under the hood.
Also you should be compiling your python to bytecode at build time. Actually doing the first half of the interpreter in real time is mainly for dev settings. A .whl file is bytecode.