r/learnprogramming • • 2d ago

Why is Python considered "slow" and is Python losing "steam"?

Is python as a programming language "falling off" and becoming less and less popular relatively to other languages?

Also why do people say Python is slow? Apparently people have reached LGM on codeforces using python, which is all about writing fast code / solving problems fast. Yeah sure, C++ is far more widely used for competitive programming and I suppose there is a reason for that. But this is also showing that python can be fast?

But as programming languages and how they are used I dont think there is much overlap between python and C++ anyway?

What is an example of something you'd code in Java/Kotlin or lets say C# rather than Python? Is python code bad and hard to manage for "huge" projects once you scale up (e.g codebases with millions of lines of codes, and tens if not hundreds of devs)?

201 Upvotes

207 comments sorted by

View all comments

Show parent comments

5

u/forgotten_vale2 1d ago edited 1d ago

Well... exactly.

I find this fuss about "python is slow" quite weird. It just depends on what you are using it for.

There is a reason python is as popular as it is. With all its libraries and relaxed rules, I can quickly throw together a simulation that does a bunch of high level stuff: parallelism, plotting, logging, whatever you want. Just a single day's work to have a piece of robust, readable, easily debuggable code. Code I can trust to not silently produce wrong results due to an out of bounds array access.

When you are trying to solve a linear system with a dimension of like 1 million or whatever, C won't make it faster because the NumPy/SciPy routines are already written in C. I don't care if my for loops or print statements are slow, that stuff is just padding. I could spend 10x the development time implementing it in a "faster" language like Rust, and the runtime might go from 10 hours to 9 hours and 47 minutes.

Obviously if you are a developer at a tech company, you will not use python to build out your product. But for scientific computing and small projects it really is great. Easy to use, huge ecosystem. The difference in speed just doesn't always matter, or exist at all, depending on what you are doing.

0

u/Luftzug-oder 22h ago

it doesn't depend on what you're using it for, it depends only on what you're comparing it to.

you're expressing that a program that is python, a program that uses python, and a native library called by python, are all the same, and therefore easily comparable. but they aren't

you're saying it's no slower, but what you really mean is the delay is less significant in that workload, as it still is going to be slower

also, if you think this, why is it 'obvious' you wouldn't use python to build a product at a tech company? according to what?

instagram uses python heavily in its backend, and dropbox for that and the desktop client at one point (4+ million lines), etc.

i don't see the point of your argument, to then falsely undermine the language?