I get performance on par with any compiled language. Well, 90% of it considering about 90% of the work being done is pushed down into C code in one form or another.
Out of curiosity, what kind of "dev" are you doing where that's your main work horse??
Not negating or anything, genuinely curious as someone who's primary language has been C or C++ for over 20 years, I've only ever used Python as a "quick-dirty-tool" language similar to shell scripting (e.g. something I needed to be cross-platform but not performant in any way), or when interfacing with various API's.
AI / Machine Learning is mostly written in Python nowadays. Relies heavily on libraries like PyTorch that are written in systems languages and use fast GPU code as much as possible, but the day to day (at least in my experience working in Computer Vision) is in Python land.
Python is huge nowadays for many tasks, especially machine learning and scientific computing related (since as the post mentions, those libraries have a C/C++/Rust backend). Popular libraries include; pandas/polars, scikit learn, PyTorch, etc. Very convenient and easy to use. You can also develop APIās (via fastapi) and even full stack web apps (Django). Iād say itās as general purpose as a general purpose programming language can get. Itās easy to do anything in Python; but of course it may not be the absolute best tool for the job.
Itās common in science like bioinformatics and physics, etc., where you want an interpreted language for easy data analysis scripts, but the underlying numeric code (often custom algorithms) all need to be fast and performant on big data. I do the same, but in R instead of Python.
I'm fullstack, it's React in the frontend with FastAPI running in the backed. I didn't choose python, it's not ideal for the API itself, but a lot of data engineering (I think would be the correct term for the type of work being done, it's a lot of different things) is going on in backend services.
The API service itself is not nearly as efficient as a compiled language, but the API is a small portion of total compute and the read layer is cached in redis anyway. The majority of the actual compute happens in non-python modules, either in python libraries or databases. It's easier to do the data work in python, and then I get to share code with the API, so that 10% of "waste" in API performance is more than made up for in developer velocity.
TLDR; Fullstack, data manipulation in python is easier to write, may as well write everything else in it, too.
Ah! makes sense! I knew it was heavy in the sciences and ML stuff, but I totally understand just "keeping-it-all-the-same" and "not-by-choice" sort of decisions (had to deal with many myself, lol!).
For reference one of our APIs was written by me in C# before I started enforcing strict typing standards in our python (it was driving me insane) - it's way more performant. Less memory footprint, higher traffic volume, etc. But then I have to code around all these "gotchas" in TWO languages, any common db access patterns get written twice, etc. At our scale it'll cost more in labor to implement than you'll save in runtime costs.
Honestly a good bit of the workload is being handled by things like redis, sqlite, ffmpeg, postgres, clickhouse, etc. which tend to dominate our bills compared to the python itself. And I like the flexibility and velocity I get when I can have a single db schema based on the domain models centralized in one place.
Then we like to hire brand new devs when we hire, and since they typically know python its easier to get them working on things hands on quickly (just higher up in the project layers). Honestly lots of pros I think, but the larger your scale goes all the pros get drowned out in the "a 10% saving in compute would pay my entire teams salary" noise so you don't see it working that way at the predominant large businesses.
Sorry I'm rambling now, just don't understand the hate. I like the language, has pros, just the particular cons lend to big businesses not using it.
Oh nah! I totally get it!! I don't hate on Python at all, I really like it too for what I use it for .. I think some of the dev's who hate on Python would hate on just about any language they don't want to use, lol!
And yeah, I get your sentiment about dealing with multiple languages to solve a problem; it's one of those engineering things you have to take into account for your grander architecture ... I had to write some full stack stuff a while back using WebSockets; I was using PHP for the backend so naturally wanted to keep the WS side in PHP as well since that's what our other devs knew and it would keep the architecture more "simple", but at the scale I needed it was going to kill our AWS compute time, so I had to write a C++ WebSocket implementation to interface with the front-end ... it was super fast and worked great, but I still hated that I had to go that route :/
Last semester I was working on a stochastic modelling project. I wanted to ensure I was getting accurate numbers from my simulations so I wanted to run thousands of them at a time. To do this, I wrote the main simulation algorithms in Rust, and then called them in Python where I did my plotting with matplotlibĀ
I think compared to writing the whole thing in Python it wound up being about 4 times faster, which mattered a lot cause the whole set of simulations still took several hours to runĀ
I recently wrote some software in C and friends were looking at it and were baffled I used C. The embedded portion was all C and most of the libraries on the PC side were just pulled from that. And itās blazing fast compared to me doing it in python..
Iāve been saying it for over a decade. C is the first language you should learn..
Python is a language that is interpreted by CPython. Every script is translated into bytecode to run it. That is why it is so fucking slow; it is interpreted every single time at runtime.
A horrible way of wrapping around C, when you could just use C or C++, compile into binaries for the OS and do the same job way faster.
"a C compiler will outperform even the best interpreter" you mean. It's not like the C dev doesn't get the advantage of the compiler over the interpreter in this comparison.
People who write in python donāt need the performance, they need the massive library and easy to read and program code. I know both python and C++ and would always pick python for things I wanna do unless I really REALLY need the performance advantage.
I know this is somewhat of a crazy statement but for most cases in programming (that arenāt like enormous and complex projects) typing is not that important. Iām not saying that it isnāt crucial but for certain projects context clues are enough.
When I try to read something that is dynamically typed or that have to much type inference (looking at you rust) I find it unreadable because you must always have to thing what is the type of this, what does that thing returns.
And please don't speak about type annotations, nobody uses them.
Thatās probably because youāre not used to it. I get why youād prefer information over simplicity, I absolutely agree with you for complex projects.
But if youāre used to python, the simple syntax is much more readable at a quick glance than C++.
It's possible to have decent performance with interpretation, look at JS. But I don't think the kind of money web's only native language got is ever going to be poured into Python.
Technically not but calling modern JS a compiled language is misleading in most contexts. It's dynamically executed with compilation steps, which makes it closer to interpreted than compiled for most practical intents and purposes.
Or write Java.Ā It's a fine language if you avoid the Enterprise bloat.
I've been learning software defined radios. My goal was to start in Java then port to C++ for performance. I was surprised to find that it doesn't need to be ported. The C style core processing code runs crazy fast in Java.Ā
No hurry because there's a new shortcut in Java 25 for when you don't need any program or class arguments:
class HelloWorld {
void main() {
IO.println("Hello, World!");
}
}
At least in real code, I always end up with the traditional form to get the most important program argument - a reference to the bootstrap configuration file.
I mean, yeah. The Python team puts a lot of work into making FFI as convenient as possible, precisely because it lets people do stuff like this. Itās one of the best features of the language.
a ml mm h nu8,m. .m I'm. j.W kTouch and hold a clip to pin it. Unpinned clips will be deleted after 1 hour. .i7 on in a I'm know ; 0, k 636Touch and hold a clip to pin it. Unpinned clips will be88āø. deleted after 1 hour%0l
221
u/fragile_male_eggo May 10 '26
Build the tool in c and rust then give it python hooks. I thought that was the goal.
50
u/Sassaphras May 11 '26
55
u/Methode3 May 10 '26
I recently wrote some software in C and friends were looking at it and were baffled I used C. The embedded portion was all C and most of the libraries on the PC side were just pulled from that. And itās blazing fast compared to me doing it in python..
Iāve been saying it for over a decade. C is the first language you should learn..
9
u/BreakingBaking May 11 '26
38
u/puzzled_orc May 10 '26
Python is a language that is interpreted by CPython. Every script is translated into bytecode to run it.
That is why it is so fucking slow; it is interpreted every single time at runtime.
A horrible way of wrapping around C, when you could just use C or C++, compile into binaries for the OS and do the same job way faster.
7
u/Matthew_Summons May 11 '26
Itās called CPython for a reason
4
u/brunoha May 10 '26
Honestly, yeah, pls write more of that.
Python is meant to be found understandable, and fast is a big plus
2
u/SKRyanrr May 11 '26
Numpy and Scipy routines use fortran
2
u/k-mcm May 11 '26
Or write Java.Ā It's a fine language if you avoid the Enterprise bloat.
I've been learning software defined radios. My goal was to start in Java then port to C++ for performance. I was surprised to find that it doesn't need to be ported. The C style core processing code runs crazy fast in Java.Ā
1
u/dhnam_LegenDUST May 11 '26
Nice practice.
1
u/Ok-Dot2551 May 11 '26
How is django performant despite being written in python?
1
u/PinkCloudMona May 11 '26
Nice.
1
u/Grouchy-Screen6884 May 11 '26
abstraction at its finest
1
u/stumpychubbins May 11 '26
I mean, yeah. The Python team puts a lot of work into making FFI as convenient as possible, precisely because it lets people do stuff like this. Itās one of the best features of the language.
1
u/NeighborhoodSad5303 May 17 '26
Look inside.... its written in machine code!
1
u/JellyfishWeary May 17 '26
If you want to write fast python, you'll write in C.
1
u/Sufficient_Listen901 Jun 21 '26
.nvc. me mm m y k
a ml mm h nu8,m. .m I'm. j.W kTouch and hold a clip to pin it. Unpinned clips will be deleted after 1 hour. .i7 on in a I'm know ; 0, k 636Touch and hold a clip to pin it. Unpinned clips will be88āø. deleted after 1 hour%0l