Live data from Hacker News

Python performance myths and fairy tales

lwn.net

191–200 of 221 posts

Re: Python performance myths and fairy tales

#191
post #82

Earlier quoted context omitted.

And slow code, yes it has cross my mind. Usually they also call Python to libraries that are 95% C code.

The hypocrisy gets even worse: the C code then gets compiled to assembly!

Except C developers actually acknowledge that, they don't call libraries written in Assembly, C code.

Re: Python performance myths and fairy tales

#192
post #22

Earlier quoted context omitted.

Because many never used Smalltalk, Common Lisp, Self, Dylan,... so they think CPython is the only way there is, plus they already have their computer resources wasted by tons of Electron apps anyway, that they hardly question CPython's performance, or lack thereof.

Has it ever crossed your mind that they just like Python?

I use Python 90% of my day and I can't say I like it or hate it or care about it at all. I use it because it has all the libraries I need, and LLMs seem to know it pretty well too. It's a great language for people that don't actually care about programming languages and just want to get stuff done.

Re: Python performance myths and fairy tales

#193
post #144

> His "sad truth" conclusion is that "Python cannot be super-fast" without breaking compatibility. A decent case of Python 4.0? > So, maybe, "a JIT compiler can solve all of your problems"; they can go a long way toward making Python, or any dynamic language, faster, Cuni said. But that leads to "a more subtle problem". He put up a slide with a trilemma triangle: a dynamic language, speed, or a simple implementation.…

If Julia fixes it package manager problems (does it still take a while to load imports?), I think it could become popular.

I think you're referring to the TTFP (time to first plot) issue (the package manager is top notch). TTFP has been drastically improved with a bunch of optimisations, and then you can pre-compile your project to keep it fast e.g. between running your script with different params.

Re: Python performance myths and fairy tales

#194
post #191

Earlier quoted context omitted.

The hypocrisy gets even worse: the C code then gets compiled to assembly!

Except C developers actually acknowledge that, they don't call libraries written in Assembly, C code.

Sure they do.

https://github.com/OpenMathLib/OpenBLAS https://github.com/FFmpeg/FFmpeg

Plenty of assembly in those projects but no mention of it in the README. Most C projects don't acknowledge the assembly they use.

Re: Python performance myths and fairy tales

#195
post #134

Earlier quoted context omitted.

I've been hearing promises about "better than C" performance from Python for over 25 years. I remember them on comp.lang.python, back on that Usenet thing most people reading this have only heard about. At this point, you just shouldn't be making that promise. Decent chance that promise is already older than you are. Just let the performance be what it is, and if you need better performance today, be aware that there…

I maintain a program written in Python that is faster than the program written in C that it replaces. The C version can do a lot more operations, but it amounts to enumerating 2^N alternatives when you could enumerate N alternatives instead. Certainly my version would be even faster if I implemented it in C, but the gains of going from exponential to linear completely dominate the language difference.

Yeah let's just compare apple to oranges

Re: Python performance myths and fairy tales

#196
post #134

Earlier quoted context omitted.

I've been hearing promises about "better than C" performance from Python for over 25 years. I remember them on comp.lang.python, back on that Usenet thing most people reading this have only heard about. At this point, you just shouldn't be making that promise. Decent chance that promise is already older than you are. Just let the performance be what it is, and if you need better performance today, be aware that there…

I maintain a program written in Python that is faster than the program written in C that it replaces. The C version can do a lot more operations, but it amounts to enumerating 2^N alternatives when you could enumerate N alternatives instead. Certainly my version would be even faster if I implemented it in C, but the gains of going from exponential to linear completely dominate the language difference.

So you're saying two different programs implementing two different algorithms perform differently and that lets you draw a conclusion about how the underlying language/compliers/interpreters behave?

Have you ever heard of a controlled variable?

Re: Python performance myths and fairy tales

#197
post #49

The primary focus here is good and something I hadn't considered: python memory being so dynamic leads to poor cache locality. Makes sense. I will leave that to others to dig into. That aside, I was expecting some level of a pedantic argument, and wasn't disappointed by this one: "A compiler for C/C++/Rust could turn that kind of expression into three operations: load the value of x, multiply it by two, and then stor…

> They are pure overhead, for no value in this situation. Iow, if Python had a sufficiently intelligent compiler/JIT, these things could be optimized away (in this use case, but certainly not all).

Hence, Numba.

Re: Python performance myths and fairy tales

#198
post #87

The most interesting part of this article is the link to SPy. Attempts to find a subset of python that could be made performant.

Honestly that seems Sisyphean to me. The market doesn't want a "performant subset". The market is very well served by performant languages. The market wants Python's expressivity. The market wants duck typing and runtime-inspectable type hierarchies and mutable syntax and decorators. It loves it. It's why Python is successful. My feeling is that numba has exactly the right tactic here. Don't try to subset python from…

The market can have that in plenty of dynamic languages with JIT compilers, including Python, if there was more PyPy love from the community.

Re: Python performance myths and fairy tales

#199
post #85

Python and other high-level languages may actually decrease in popularity with better LLMs. If you are not the one programming it, might as well do it in a more performant language from the start.

LLMs will make most languages irrelevant indeed, just like most developers have no idea about the Assembly/machine code that the JIT/AOT compilers of their favourite programming language happen to generate.

Eventually LLMs might even generate executables directly.

Re: Python performance myths and fairy tales

#200

Again and again, the most important question is "why?" not "how?". Python isn't made to be fast. If you wanted a language that can go fast, you needed to build it into the language from the start: give developers tools to manage memory layout, give developers tools to manage execution flow, hint the compiler about situations that present potential for optimization, restrict dispatch and polymorphism, restrict semanti…

The frustrating thing is that the math and AI support in the python ecosystem is arguably the best. These happen to also be topics where performance is critical and where you want things to be tight. c++ has great support too but often isn't usable in communities involving researchers and juniors because it's too hard for them. Startup costs are also much higher. Ans so you're often stuck with python. We desperately…

It is kind of ironic that this is now the Zeitgeist, while in the 1990's my university used to teach C++ to first year students, and I learned it as high school student with Turbo C++ 1.0 for MS-DOS, about a year after it was made commercially available, later acquiring Turbo C++ 1.5 for Windows 3.1 with student discount.
Post reply on HN