5 ms·
> the performance available when using Python The honest thing would be to say "yes, Python is slow, but you can use some fast modules written in C". You can
by stefantalpalaru 13y ago
> the performance available when using Python
The honest thing would be to say "yes, Python is slow, but you can use some fast modules written in C".
You can even go farther and say that if you're going to use Python for non-trivial projects you better learn C (or some C generator like Cython).
- pekk 13y agoThe ubiquitous implementation of Python is written in C. So, for example, the list-sorting algorithm is written in C. If you want to eliminate C from the equation completely, I guess we now have to rewrite the C sort algorithm to be slower to show off "how slow Python really is" in isolation from C. But this is a benchmark of a fantasy world. That Python isn't the real Python we use. In the real world Python is not in isolation from C, by design, and this works well.
- stefantalpalaru 13y agoNo. The language in which the interpreter is written is not the point here. The point is the interpretation overhead of the best (or "only" if we're being pedantic since Python is de facto whatever CPython does) interpreter. That overhead is the price you pay for using Python so it's what matters when you compare languages for CPU bound projects.
- maxerickson 13y agoIt's a little strange to insist that CPython is the only Python interpreter and then reject all the C libraries that you can access for performance (because those C libraries are the big loss when shifting from CPython 2.7 to Pypy). I think interpreter overhead and language ecosystem performance are probably best looked at as separate questions.
- calpaterson 13y agoYou 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 ago
- deleted 13y ago[deleted]