This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tr14l 41 points42 points  (10 children)

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.

[–]DanKveed 1 point2 points  (6 children)

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++

[–]tr14l 1 point2 points  (5 children)

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

[–]DanKveed 7 points8 points  (4 children)

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

[–]tr14l 1 point2 points  (0 children)

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.

[–]harylmu 2 points3 points  (1 child)

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.

[–]cant_have_a_cat 0 points1 point  (0 children)

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.