Pyston v2.2: faster and open source
blog.pyston.org
blog.pyston.org
> Pyston is a fork of CPython with additional optimizations for performance. It is targeted at large real-world applications such as web serving, delivering up to a 30% speedup with no development work required.
I did not really found any information on what type of additional optimizations are done. Is there some documentation which goes into that?
https://www.pythonpodcast.com/pyston-fast-python-interpreter...
Last year (I think it was last year, but can't tell if that was 2020 or 2019) they released it on their own, thinking of a commercial model. Now they have switched to OSS+services, which is interesting because it'llopen up more people using Pyston.
I tihnk this is interesting in its own right, but yesterday we got Facebook announcing Cinder[1] -- which is unsupported to outsiders, but significantly faster than Pyston. According to Facebook, they intend for parts of Cinder to be upstreamed (and have already upstreamed a few, apparently) to CPython. So again, and sorry for using such a vague word, it'll be interesting to see how all these things play out in time.
> Note GPL-compatible doesn’t mean that we’re distributing Python under the GPL. All Python licenses, unlike the GPL, let you distribute a modified version without making your changes open source. The GPL-compatible licenses make it possible to combine Python with other software that is released under the GPL; the others don’t.
- A very-low-overhead JIT using DynASM
- Quickening
- Aggressive attribute caching
- General CPython optimizations
- Build process improvements
I'm sure at this level of tech they are well aware of the prior art.
Edit: Also yesterday's HN discussion on Cinder https://news.ycombinator.com/item?id=27043217
Wouldn't it be better to have two companies working on it instead of just one? Or are the implementation details too far apart?
Also unless you have a very trivial app / use only your own code, Lua web environment isn't really comparable to what exists in the python ecosystem. Not yet anyway.
I say this because v4 would be a good time to look at putting some of these speed improvements into the mainline code - something that would be largely backward compatible, but make those breaking changes that give big speedups (such as putting limits on the C interfaces and other big building blocks).
My gut (and really, it's just a half-assed guess) tells me that Python could easily see a 2x speedup in exchange for some of those incompatibilities, and an even bigger gain depending on how deep the changes went. [0]
If that's anywhere near correct, then doing a v3/v4 in parallel (like v2/v3 was) would probably be the only way to go, so that people would know there is a migration path. [1] [2]
[0] - There are really only two ways to do this - keep breaking things and introducing incompatibilities along the way, or make a bigger break for the sake of performance. Of course, doing nothing is also an answer, but probably one that we wouldn't really be happy with. There is also a variant of versioning where we do 4/5/6/... in relatively rapid succession, such as 2-3 year intervals, and make a fewer big breaks for each release, and that might even work better.
[1] - I suffered through the v2/v3 issues also, (as an end user more than a dev though), and it wasn't fun. But I'd do it all again if it meant a big jump in speed.
[2] - I know the perl team mucked this up (hindsight being 20/20), so having a working V4 on first release (not counting alphas & betas) would be key. Scoping that out well beforehand would probably be needed, but I think the team is broad and deep enough to do that.
I absolutely agree that for some people, it will be too much, and frankly, I don't think that problem is solvable.
That seems silly. It's not like other languages don't have their own major version migration pains.
It would take probably decades for libraries to catch up, and maybe kill the language, but if it survived, Python would be so much more attractive for many kinds of projects.
Conversely, Python has a lot of niches, and works well for them. Incremental improvements are probably fine, even with the dreaded GIL.
HPy is in the process of creating a new C extension API that doesn't expose CPython internals and is easier for alternative Python implementations to support with high performance.
If we had to endure another large python migration, we would just migrate to a different language with better perf.
What’s the compatibility story like? Is there a list somewhere of unsupported features?
Pyston 2.1 Is Blowing Past Python 3.8/3.9 Performance - https://news.ycombinator.com/item?id=25895346 - Jan 2021 (12 comments)
Pyston v2: Faster Python - https://news.ycombinator.com/item?id=24921790 - Oct 2020 (206 comments)
Personal thoughts about Pyston's outcome - https://news.ycombinator.com/item?id=13680580 - Feb 2017 (67 comments)
Pyston 0.6.1 released, and future plans - https://news.ycombinator.com/item?id=13534992 - Jan 2017 (23 comments)
Baseline JIT and inline caches - https://news.ycombinator.com/item?id=12010244 - June 2016 (12 comments)
Pyston Python JIT Talk - https://news.ycombinator.com/item?id=11528159 - April 2016 (11 comments)
Caching object code - https://news.ycombinator.com/item?id=9887756 - July 2015 (5 comments)
Pyston 0.3: Self-hosting Sufficiency - https://news.ycombinator.com/item?id=9103596 - Feb 2015 (54 comments)
An open-source Python implementation using JIT techniques - https://news.ycombinator.com/item?id=7529862 - April 2014 (27 comments)
Announcing Pyston: an upcoming, JIT-based Python implementation - https://news.ycombinator.com/item?id=7524712 - April 2014 (41 comments)
I think the obsession with monocultures is unhealthy.
Python is a great language. It is reasonably easy to learn, somewhat readable if you dont yet. It is one of the most popular programming languages on the planet. But it was not created to produce the fastest code possible.
There are other programming languages that are focused on speed.
Perhaps for the most critical parts use one of them. Python can integrate pretty well with C with some magic i hear- (Never tried it myself).
One programming language will never cover all use cases and they should not have to.
Every programing langue is not made to be "functional" but they can be tortured into it.
Every programming language is not object oriented, but they can be tortured into it.
Every programming langue is not focused on being the fastest on execution but they can be tortured into it.
There is a reason carpenters have more than one tool to build something.
For the longest time I programmed in C with some C++ mixed into it. It is a great language. There are many problem domains I would not recommend using C.
I think it was delightful ot pickup Python many years ago.
It is great. I can be very productive in Python in contexts were Python is great.
It is not C, it should not want to be.
Now I am picking up Elixir, I am learning a lot. It is neither Python or C and I am happy with that.
use proper tool for the job at hand
e to https://github.com/facebookincubator/cinder reply
So what do you do? Rewrite everything in C++? Well you can start but you have so much software it's hard to do. Maybe you can save a few percent of compute cycles across all of your code? Reduce the 100k/month to 80k/month.
Obviously this number is fall smaller than it would be in reality.
Rewriting everything for performance reasons is silly. If you decide to rewrite everything, it would be for other reasons (e.g. maintainability, long-term viability, etc.)
I'd assume most performance-sensitive projects will have compiled their hotspot modules with Cython. So how does Pyston work alongside Cython?
See e.g. https://github.com/thomasahle/fast_pq/blob/main/_fast_pq.pyx... for how much fast Cython code can look like C.
https://stackoverflow.com/questions/3033329/why-are-python-p...
I'm curious to understand, why is it so hard to write a JIT runtime for python?
The most well known is PyPy
Pyston appears to be another with a different approach
This sounds like the only reasonable explanation to me. JIT with C interoperability is hard, but it's not that hard.
First, the CPython reference implementation is supposed to be kept simple. Second, it exposes interpreter implementation details to extension writers, meaning alternative implementations with a radically different architecture might be unable to use some parts of the ecosystem or have to implement costly workarounds (see eg the PyPy FAQ [1]).
[1] https://doc.pypy.org/en/latest/faq.html#do-c-extension-modul...
You'd need to look at the CPython project (main Python project) why they don't want to include anything like that. I hope there will be steps taken.
For example, all the numerical/scientific stack (numpy etc) is extremely fast by being written C, Fortran, etc with a Python interface. If you break this in a JIT then the plain python might be faster but actual useful code will be much slower.
Additionally, one of the reasons C-extensions are so fast is because the CPython implementation is very clean which has made it easier to write stable and performant extensions.
Someone from python community should write a blogpost about features, merits and limitations of CPython, PyPy, Cinder, GraalVM and Pyston
Cinder and Python are pretty new, it would be premature to say too much, we don't have enough background information about them.
GraalVM is between the 2: it's been there for some time, but it's still not much known. I don't know anyone using it in prod. I would be curious about a writing on this one.
> At this point, the Python runtime is made available for experimentation and curious end-users. (https://github.com/oracle/graalpython/tree/master/docs/user)
> Does module/package XYZ work on GraalVM's Python runtime? - It depends, but is currently unlikely. (https://github.com/oracle/graalpython/blob/master/docs/user/...)
Jython 3 has a roadmap with 3.8 has a target: https://www.jython.org/jython-3-mvp.html
Not ready, but not cancelled.
(E.g. hhvm at Facebook vs everyone else who tried to use it after it was first publicly released)
Edit: It's Python v3.8.8, thanks to https://news.ycombinator.com/item?id=27059804
They should totally upstream this back to python/cpython.
It's really quite close, and https://github.com/hpyproject/hpy is intended to make them even closer.
There's not really a way around that, since they have to interact with refcounting now vs a more abstract mechanism (eg. hpy's handles) that shield from the underlying GC mechanism.
My fear here is that this will be a cool project a few projects really looking for cross-interpreter python support leverage, but will otherwise be a non-issue.
It doesn't need to show performance improvement on PyPy or Pyston as much as <=0 performance degradation of CPython, which will stay everyone's primary target.
I guess when it shows to be mature, it'll just be a question for each library of whether the work is worth supporting alternative interpreters for their user-base or personal lives or job.
So yes, it should be.