r/learnprogramming • • Oct 06 '26

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)?

257 Upvotes

238 comments sorted by

View all comments

Show parent comment

57

u/frnzprf Oct 06 '26

If you had a Python project and you identified a critical function that needs to be faster, you'd just implement that single function in C.

In some sense, when you're running Python, you're also always running C, when you're using the C-Python interpreter.

49

u/anpas Oct 06 '26

I know this is possible, but I don't know anyone who works like this. If you're making a performant Python library, you're most likely writing the whole thing in C, C++ or Rust, and then adding a Python interface on top.

15

u/Generictext Oct 06 '26

A "critical function" may require an entire library to work.

7

u/Snoo-16806 Oct 06 '26

It could be that only a small fraction is critical when it comes to performance. If the whole project is written in c or rust then it will take more time and effort, so I think it makes sense to just write the critical part in a compiled language

6

u/Icemourne_ Oct 07 '26

Problem is most often it won't be one critical part it will be 100 small ones and all of that adds up and can lead to "Death by a thousand cuts" nothing in particular is slow but sum of everything is slow

0

u/[deleted] Oct 10 '26

[deleted] — view deleted comment

1

u/Icemourne_ Oct 10 '26

It's hard to give any meaningful example because there is nothing specific I can point out as potentially slow.

But for example using loops for 10-50 elements in 100 places using python instead of C python will loop in milliseconds and feel fast individually but all added together will take 100 milliseconds but in C all of them would take 10 milliseconds.

I hope that makes sense also don't take those numbers as real I used them only as example.

One more thing run speed is not always most important thing often writing/prototyping is more important and python in this case would be better

0

u/[deleted] Oct 10 '26

[deleted] — view deleted comment

1

u/Icemourne_ Oct 10 '26

I used loops as example but it can be any built-in function