4 ms·
You only need to know C to get fast Python code for a tiny minority of situations. For one, most interesting C wrappers have already been written and second, t
by calpaterson 13y ago
You only need to know C to get fast Python code for a tiny minority of situations. For one, most interesting C wrappers have already been written and second, the majority of C code you will use in normal business software contexts isn't used by FFI.
For a normal web application the request flow goes something like: nginx (WSGI) -> uwsgi -> web application code -> psycopg2 driver -> postgres. Only the web application part is written in Python, so for practical purposes you actually have a C stack that uses Python for business logic. Loads of libraries, from json parsers to templating libraries include optional C code for speedups.
- stefantalpalaru 13y agoGuess where the bottleneck is when you need to generate a dynamic page for each and every request.
- calpaterson 13y agoIn the database? About 90% of bottlenecks boil down to something along the lines of "this query is slow" or "there are a lot of queries here". This has been true since the dotcom boom
- stefantalpalaru 13y agoGuess again. All these benchmarks use the same database: http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=query http://www.techempower.com/benchmarks/#section=data-r8&hw=i7...
- calpaterson 13y agoThose are fairly uselss synthetic benchmarks. How many apps do you have in production that are purely key value stores with a random access profile? And if you really have these performance characteristics (hint: it's unlikely), maybe it's time to get a edge caching CDN? Cutting 400ms of latency as you cross from Amsterdam to California is going to be the easiest performance boost you ever got
- tethis 13y agoThe point of these benchmarks is that, given the same database and the same queries, languages have different performance profiles. If I build an application in Java and Python, with the same database backend, running the exact same set of SQL queries, the Java application should perform better.
- BugBrother 13y agoThe point is that with a db which hits the disk, the different execution times will generally look like rounding errors.
- tethis 13y agoIf you look at those benchmarks, for the same db queries on the same db backend, throughput and latency can differ by an order of magnitude. We're talking the difference between 200 or 2000 requests per second, or 50ms vs 500ms latency. That's not a rounding error.
- BugBrother 13y agoMy (and others') point is this obvious thumbs rule: If you hit the disk, that I/O will dominate the latencies. Even while using a scripting language. E.g. a DB that fits in RAM is different, of course. It is hence easy to create benchmarks that generates every possible result. So is your comment relevant to my point? Is there something about that benchmark which contradict the previous thumbs rule? (And yes... With lots of calculations, scripting languages aren't a good idea either in many cases. Also obvious.)
- reitzensteinm 13y agoThe real answer is "it depends". The whole rise of memcached and NoSQL should pretty clearly indicate that many developers are finding their database to be the bottleneck. There's much less of a push for high performance languages, even though there are many that are also quite nice to work with (eg, Clojure). Since this is a Python discussion, searching for "Django PyPy" and "Django NoSQL" should be instructive. You're combining a false dichotomy with snark, which really shouldn't have a place here on HN.
- calpaterson 13y agoWell, at least some of the NoSQL movement was some people preferred to model data as documents or dictionaries or graph, etc instead of relations
- BugBrother 13y agoIn general -- the bottleneck for web servers are databases. That is why scripting languages (Perl, PHP, Python, Ruby, etc) are used for web pages. If processing speed is needed... well, note that databases are seldom written in scripting languages.