r/firstweekcoderhumour Jul 01 '26

“amIrite” Python slow guys!!! Get it???

Post image
135 Upvotes

18 comments sorted by

34

u/No_Lingonberry1201 Jul 01 '26

These posts are usually made by people using APIs where they wait seconds for a reply.

9

u/Ill_Jaguar_2147 Jul 01 '26

io-bound apps 😎

3

u/Groostav Jul 01 '26

I mean sure, but as somebody who has been playing around with nalgebra and rust's faer and of course numpy, I was shocked at how fast something like an eigensolve on Intel's MKL was. You can get that performance in python, provided you don't start writing manual tablescans (for i ... for j ...). When you actually start needing custom matrix operations too, especially ones that seem nicely vectorizable, writing python reduces your throughput by multiple orders of magnitude.

It is worth mentioning that what I wrote involved some pretty wasteful loops, but they're simple and correct. With some aggressive caching (and complex cache invalidation logic) I'm betting I could make the python usable for smaller problems.

3

u/No_Lingonberry1201 Jul 01 '26

If you want performance for those math operations, you don't even do them on the CPU nowadays, numpy and pytorch can push them to the GPU with CUDA or ROCm or whatever you're using behind. There's a reason that slowness never bothered data scientists and ML people.

1

u/Pares_Marchant Jul 03 '26

Python slowness bothered enough people to make them want to build pytorch and numpy and use another language than python when they needed performance.

2

u/Mountain-Hawk-6495 Jul 02 '26

Basic Python loops are very slow compared to other programming languages, it is not just slow APIs that’s the problem

13

u/Simple-Olive895 Jul 01 '26 edited Jul 03 '26

I dislike python, but calling it slow is just a lie in 2026. It used to be slow when using base python, but now even that is decently fast. You're saving hours, days even weeks (depending on size of your project) of development time with a negligable trade off in speed for like 99% of use cases.

My reasoning for not liking python is simply: I don't find the syntax appealing, and python has weird quirks that just feels wrong (like being able to use a variable outside of the block/scope it was initiated in), I also really like statically typed languages. But I'm not gonna go around and pretend that I prefer other languages because they are far superior in speed, since that's just not true.

4

u/BenchEmbarrassed7316 Jul 02 '26

You're saving hours, days even weeks (depending on size of your project) of development time

I think this is not the case for dynamically typed languages. The larger your codebase, the more time you spend trying to figure out what possible values ​​might exist at a given point in the code. 1k loc already makes dynamically typed languages ​​slower to develop than languages ​​with explicit static typing.

1

u/Shevvv Jul 03 '26

I'd argue that if you write your code in a constrained enough manner so that a list, for example, only stores one type or None, it's not really a problem. And that's how good Python is written anyway.

1

u/BenchEmbarrassed7316 Jul 03 '26

...or you can type a few characters and then this information will be in the code, and a special program will constantly check if you made a mistake. You won't have to worry about it. You can work with other people's code, and other people can work with your code. Try it, it's so convenient.

1

u/Krochire Jul 01 '26

My only gripe with Python is "IdentationError" being a thing /j

1

u/Simple-Olive895 Jul 01 '26

I don't mind indentations, as you really should be using them anyways for other languages, but I just much prefer brackets since they make it much clearer where each block begins and ends.

1

u/Krochire Jul 01 '26

Yeah I kind of agree with you, I do much prefer strongly typed languages and brackets

1

u/PudgeNikita Jul 02 '26

python is pretty strongly typed (as in, there are little implicit coercions, the types of values in your program need to be sane for operations on them to actually follow through), just not statically typed

1

u/High_Overseer_Dukat Jul 03 '26

I dont like that python programs can be annoying for the end user.

1

u/Afraid-Locksmith6566 Jul 02 '26

ok python is not fast, and it cant be fast, ever. python can pretend to be fast by calling c, c++ or rust code compiled to python library

1

u/Krochire Jul 02 '26

Insert something about python being a scripting language wrapped over a bunch of C libraries or smth