r/Python • • Nov 13 '20

News Python swallows Java to become second-most popular programming language

https://www.theregister.com/2020/11/12/python_swallows_java_to_become/
2.3k Upvotes

205 comments sorted by

View all comments

Show parent comments

42

u/tr14l Nov 13 '20

You wrote bad Python. The difference is NOT 2000 vs 25 unless you did something terribly wrong. There will certainly be a difference, but that was your code running that slow, not Python itself.

2

u/DanKveed Nov 13 '20

It depends on use case too. A heavily multithreaded CPU intensive app can be way more than 2000vs 25 no matter how well you write it, especially when you compare it with rust/c++

2

u/tr14l Nov 13 '20

If you use a single thread running on a couple dozen cores, sure, no doubt. But why would you do that?

8

u/DanKveed Nov 13 '20

I am talking about multithreading. Python sucks ass at true CPU intensive tasks. That's why libraries like numpy are written in higher performance languages like c++. And why would you need that.... Well numpy for starts, anything control system related, AI, simulation, CAD, video editing, the use cases are Endless

2

u/tr14l Nov 13 '20

Yeah, that's an optimization for an interpreted language. I have made lots of multithreaded apps in compiled and python languages. I've never seen a 100x difference. Ever.

0

u/[deleted] Nov 13 '20

[deleted]

1

u/ShanSanear Nov 14 '20

I ran pypy on one of our inefficently written python projects (runtime of about 10hours). Pypy was 30-40% slower than python 3.8 using exactly the same code. Pypy isn't always the answer.

3

u/harylmu Nov 13 '20 edited Nov 13 '20

What it did was: decode request body with messagepack, get stuff from Cassandra, save stuff to Cassandra, get stuff from Consul, publish stuff to SNS, encrypt an object then upload it to S3. The request takes ~2 seconds to complete on both .NET and Python (.NET is a bit faster).

As you can see quite a few things waits for IO here. I wrote everything with asyncio-based libs (Cassandra, Consul, aioboto3). I don't know if I can optimize it better. Please let me know what are some concurrency-traps that I might have gone into.

Either way, even the possibility to write slow Python means something.

1

u/cant_have_a_cat Nov 23 '20

even the possibility to write slow Python means something.

oof - it's much easier to write slow low-level code than high-level code, so I have no idea what you mean by this.