News for hackers. Stuff that matters.
Re:Cinder: Meta's internal performance-oriented production v... by actionfromafar on Thursday September 22, 2022 @03:02AM (#32935584)
There isn't much inherent in the language design which dictates it must be very slow, though. It's mostly a result of the canonical implementation.
Re:Cinder: Meta's internal performance-oriented production v... by jakobnissen on Thursday September 22, 2022 @03:33AM (#32935797)
I disagree. Python is inherently slow:

* It uses an interpreter, which is slower than compiled code

* All objects carry a dict to contain arbitrary attributes - this creates huge overhead

* Even when the dict is suppressed with __slots__, all containers (all classes, even!) are untyped, so extracting any field causes dynamic dispatch

* Objects cannot be stored inline in containers

* Integers are variable-sized, and thus slower.

Of course, you might counter that one could simply make a version of Python which is compiled, where all classes have a well-defined typed layout, where some classes can be immutable for performance, containers are typed, integers are machine integers, etc. But then I'd argue you're talking about a completely different language (Julia fits this description perfectly)

Re:Cinder: Meta's internal performance-oriented production v... by lozenge on Thursday September 22, 2022 @04:18AM (#32936132)
Sounds like Cython.

PyPy did also fix some of those issues - specifically, lists of small integers are optimised, with a deopt path for when they overflow.

Re:Cinder: Meta's internal performance-oriented production v... by jakobnissen on Thursday September 22, 2022 @04:47AM (#32936324)
All my points above are about the language semantics of Python, not the implementation. Some of them may be optimized some of the time with a clever enough JIT - but only a few of these points. That's why PyPy is not as fast as C.
Re:Cinder: Meta's internal performance-oriented production v... by tekknolagi on Thursday September 22, 2022 @09:46AM (#32938671)
PyPy very much can handle all of the above cases! You should check out some of their recent papers about unboxing fields in objects. Some things are language semantics (__dict__, etc) but are often faked by proxy objects since most people don't actually care about the dict.
Re:Cinder: Meta's internal performance-oriented production v... by jakobnissen on Thursday September 22, 2022 @11:16AM (#32940042)
Can it autovectorize integer operations on lists? Can it remove branches from accessing fields? I doubt it.
Re:Cinder: Meta's internal performance-oriented production v... by tekknolagi on Wednesday September 28, 2022 @01:53AM (#33004663)
I am pretty sure it can remove branches from accessing fields, but I am not sure about vectorization.
Re:Cinder: Meta's internal performance-oriented production v... by itsoktocry on Thursday September 22, 2022 @09:45AM (#32938667)
And despite all of this, Python has generated billions (trillions?) of value, and continues to do so.

Perhaps it's you who is focussed on the wrong things? Maybe some of these issues can be improved over time? Maybe none of those things actually matter in the real world, outside of niche use cases?

Re:Cinder: Meta's internal performance-oriented production v... by jakobnissen on Thursday September 22, 2022 @11:14AM (#32940017)
Are you arguing about whether Python is a good language or whether it's a slow language? The former is a matter of taste, the latter is objectively true. And there are good reasons to believe it will remain true.

It's created billions of dollars in value, sure. So had JavaScript and PHP. Doesn't mean they're good languages. Mediocrity gets you far, if you're at the right place at the right time.

Re:Cinder: Meta's internal performance-oriented production v... by marcyb5st on Thursday September 22, 2022 @03:50AM (#32935932)
I disagree as well. I was working at YouTube during the rewrite from python to c++ and a lot of people at Google looked at the problem to avoid a full rewrite of a major product. We still ended up doing it regardless of the pain of using Swig to wrap C++ code. Not missing that at all.
Re:Cinder: Meta's internal performance-oriented production v... by pjmlp on Thursday September 22, 2022 @03:03AM (#32935596)
Indeed see Smalltalk, SELF, Common Lisp.
Re:Cinder: Meta's internal performance-oriented production v... by yegle on Thursday September 22, 2022 @10:45AM (#32939511)
To have different implementations we first need a "Python language specification" which doesn't exist. All other implementations have to be compatible with CPython to increase their chance of getting wider adoptions.
Re:Cinder: Meta's internal performance-oriented production v... by bakal on Thursday September 22, 2022 @03:11AM (#32935647)
Then how come that there have been so many forks focused on speed yet none has managed to get good enough?
Re:Cinder: Meta's internal performance-oriented production v... by anakaine on Thursday September 22, 2022 @03:50AM (#32935931)
Good enough in what way, specifically? Python is exceptionally popular not because of speed, but because of its wide compatibility, extensive list of maintained libraries, good learning paths, and most likely because its fast enough for most things.

Every iteration of Python for some time now has added a not insignificant speed boost. It's not as fast as C, and nor will it be given how it works, but it certainly is fast enough for a great many situations and tasks.

All of the above doesn't make it the right tool for every job. Sometimes you need to hit a nail, and you don't have a hammer but you do have a lump of hardwood. And in that situation, you make an assessment if in the long term you need to hit more nails regularly so you invest in a hammer, or just occasionally and you're ok with the lump of wood. It's subjective.

So is it good enough? Good enough for what?

Re:Cinder: Meta's internal performance-oriented production v... by thehappypm on Thursday September 22, 2022 @10:26AM (#32939209)
The speed of the programming language, in many applications, is a lot less relevant than the overall architecture. For example if you’re running a Web server and you’re serving a request through some hyper optimized C program, that is “fast”. But using a CDN in front of a slow Python server is almost always going to be faster for end users. Point is, the application is often just one part of a system. Python might let you develop quickly and avoid footguns, and having one slow link in the system doesn’t mean the system as a whole is gonna suck