Hacker News new | ask | show | jobs
by shadowmint 2602 days ago
Lovely theory, but in practice it works more like this:

1) write everything in python because its easy and quick to do so.

2) its slow as.

3) abandon software and write it in something else, or, live on with slow ass software and blame python for being slow and rubbish forever more.

re-writing python in c is a hideously painful process, and its proven to be very unsuccessful practically.

Writing new code in c/c++/whatever and exposing a python api is where successful projects like numpy and tensorflow live.

python is very good at what it is, but no one is ever going to go and rewrite your python code in c to make it faster; its just going to be slow forever.

2 comments

No, in practice is works something like this:

1) write everything in python

2) yeah, the performance here is good enough so ship it

3) there is no 3

There are very few situations where performance is going to be an issue for you where there is not an existing C module solution that will solve the problem for you. The tired old 'python is slow' trope is getting more and more irrelevant every day. There are other aspects of the language that may make it a mediocre solution to the problem at hand, but out in the real world most people are simply getting the job done with python.

I spent 4 years as a professional python developer.

We certainly shipped (using django) and it was certainly slow, and remains a painfully slow very successful enterprise app.

I’m not arguing that the slowness is deal breaking, but it is slow, and it does, routinely, break the SLAs its supposed to meet.

So... unusably slow? no.

...but slow? yes, it really is.

imo. your milage may vary. /shrug

Unless you are careful, the Django ORM will generate a lot more database accesses than needed. I'd almost bet that most of the time the user spends waiting for the app, the app is waiting for the database.
I'd emphasize that for each tasks that's likely to be a performance bottleneck there are, usually, existing high performance extensions: someone has had the same needs before you.

If there are performance issues, rewriting part of a Python application in C is much less likely than refactoring it, without using other languages, to use an existing high performance library.

Application-specific Python extensions are usually intended to allow scripting of the application, with little concern for Python performance (which is the same as doing the same thing without scripting).

New foreign language Python extensions are usually found in new Python libraries, to make existing proven C or C++ libraries available to Python applications or to improve on existing Python libraries.

Reddit disagrees. And they weren't using 3, which is even slower.
By using Python they were able to ship, which is why you have heard of Reddit and they were able to grow enough to have a concurrency problem (something Python still sucks at); the number of sites of any significance that started by using Java for page delivery is probably somewhere around 0.
Oh cmon, LinkedIn started with Java.
And even after this long it doesn't work quite right.

It's a miracle they shipped it at all.

They would be able to ship in any language, that is what software engineering is all about.
True, but would they be able to ship within the window they could become relevant? Would they be able to add the required features?

You can ship your own clone of Reddit next week, with blazingly fast code, running on two tiny VMs and supporting more load than Reddit, but would it be successful?

Probably, depending on the sales/marketing teams.
Reddit was written in lisp, they switched to python only after having initial success.
Pretty sure Python 3 has had better performance since 3.5 or so?
I still see benchmarks from bilingual projects which show py2 being faster, such as http://falconframework.org/#sectionBenchmarks
YMMV. The benchmark you mentioned used 3.6.

https://hackernoon.com/which-is-the-fastest-version-of-pytho... has a benchmark that includes 3.7.

Nope: Cython + Numba always sufficed so far