28

From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done?

dda
  • 6,030
  • 2
  • 25
  • 34
Jason Christa
  • 12,150
  • 14
  • 58
  • 85
  • 1
    FWIW you can already use c-extensions on CPython without the GIL. It is normal Python code (when running with threads) that really suffers from the GIL. – fuzzyman Mar 06 '09 at 18:02

4 Answers4

38

PyPy is really two projects:

  • An interpreter compiler toolchain allowing you to write interpreters in RPython (a static subset of Python) and have cross-platform interpreters compiled standalone, for the JVM, for .NET (etc)
  • An implementation of Python in RPython

These two projects allow for many things.

  • Maintaining Python in Python is much easier than maintaining it in C
  • From a single codebase you can generate Python interpreters that run on the JVM, .NET and standalone - rather than having multiple slightly incompatible implementations
  • Part of the compiler toolchain includes an experimental JIT generator (now in its fifth incarnation and starting to work really well) - the goal is for a JITed PyPy to run much faster than CPython
  • It is much easier to experiment with fundamental language features - like removing the GIL, better garbage collection, integrating stackless and so on

So there are really a lot of reasons for PyPy to be exciting, and it is finally starting to live up to all its promises.

fuzzyman
  • 8,271
  • 2
  • 30
  • 32
  • I'd add one to this great list: no need to get new versions of your Python libraries (i.e. C extensions) every time you move up to a new .X version. What a huge win that will be. – Brandon Mar 06 '09 at 17:37
  • 4
    How will PyPy improve the situation with C extensions? In fact C extensions are one of the (currently) major drawbacks with PyPy - they don't work at all unless they are specifically ported. – fuzzyman Mar 09 '09 at 23:35
  • 2
    With the additional speed from the PyPy JIT (particularly if they can apply it effectively to `ctypes` code), there should be significantly fewer C extensions in the mix in the first place. – ncoghlan Apr 07 '11 at 15:13
4

The most important feature is of course the JIT compiler. In CPython files are compiled to bytecode (.pyc) or optimized bytecode (.pyo) and then interpreted. With PyPy they will be compiled to native code. PyPy also includes Stackless Python patches, including it's impressive features (tasklet serialization, light threads etc.)

vartec
  • 131,205
  • 36
  • 218
  • 244
  • 2
    Hmmm... and no, PyPy doesn't compile Python programs to native executables, that's incorrect. – fuzzyman Mar 18 '09 at 09:59
  • To claim that the most important feature of PyPy is the JIT compiler seems to me like saying that execution speed is the most important part of a programming language. If it were, why are we using Python at all? I am fairly confident the main motivation behind PyPy is for an implementation of Python that allows much more possibilities. Where JIT is just one of those possibilities. – porgarmingduod Mar 16 '11 at 01:04
  • how is this any different than what the JVM has been doing for over a decade? I'm not sure i'm following why pypy JIT is better than Java JIT – Arash Sharif Feb 09 '16 at 06:44
0

In case that Python gets a real JIT I think it's going to be as fast as any other implementation.

The advantage is that it's much easier to implement new features. One can see this today by observing the library. Often modules are written in Python first and then translated into C.

Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
0

cross-platform compatibility

Yes

OscarRyz
  • 196,001
  • 113
  • 385
  • 569