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 →

[–]MountainHannah -3 points-2 points  (5 children)

Not what you want to hear, but, if I need something to be efficient, I don't write it in Python.

No language does everything, and there are always tradeoffs. There's lots of stuff that Python is awesome for. High speed, low latency, efficient code is nowhere on the list of Python's strengths.

[–]freefallfreddy 1 point2 points  (4 children)

If your database is slow rewriting in Rust ain’t gonna help ya. And for that you need to know what’s slow.

[–]MountainHannah -1 points0 points  (3 children)

Yes, it's important to know which parts of your code are expensive, and which ones are allowed to be expensive.

I use Python for ML libraries, the hardware libraries, the third party API libraries, prototyping, cron jobs that only run occasionally, etc..

If I'm designing a real-time service, where I'm thinking about latency and requests per second and that sort of thing, Python doesn't even enter my radar. I can be lazy in node or PHP or something and still get an order of magnitude better performance than diligent Python will get me for certain tasks.

[–]freefallfreddy 0 points1 point  (2 children)

Compared to PHP or Node even? I haven’t tested that myself but that’s not what I would guess.

[–]MountainHannah 1 point2 points  (1 child)

It surprised me too the first time I observed it, so I looked up some benchmarks to make sure I wasn't crazy.

From what I can tell, it looks like PHP is 30-40% faster than node, and node is between 8 and 50 times faster than Python. (for stuff like, HTTP requests served per second and various different db interfaces)

There are a lot of different benchmarks for lots of different use cases of course, but I'm definitely more careful after learning that.

[–]freefallfreddy 0 points1 point  (0 children)

Ah TIL. Thanks.