Jump to content

PyPy: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 27: Line 27:
}}
}}


'''PyPy''' is an alternative implementation of the [[Python (programming language)|Python]] programming language which often runs faster than the standard implementation of Python, [[CPython]]. The reason PyPy is faster is because it's a [[Just-in-time compilation|just-in-time compiler]] while CPython is an [[interpreter (computing)|interpreter]]. Most Python code runs well on PyPy, except for code that relies on C extensions, which either doesn't work or incurs some overhead when run in PyPy. PyPy is interesting architecturally because it is the product of a technique called [[meta-tracing]] which transforms an interpreter into a [[Tracing just-in-time compilation|tracing just-in-time compiler]]. Since interpreters are usually easier to write than compilers, but are slower, this technique can make it easier to produce efficient implementations of programming languages. PyPy's meta-tracing toolchain is called [[RPython]].
'''PyPy''' is an alternative implementation of the [[Python (programming language)|Python]] programming language which often runs faster than the standard implementation of Python, [[CPython]]. The reason PyPy is faster is because it's a [[Just-in-time compilation|just-in-time compiler]] while CPython is an [[interpreter (computing)|interpreter]]. Most Python code runs well on PyPy, except for code that relies on CPython extensions, which either doesn't work or incurs some overhead when run in PyPy. PyPy is interesting architecturally because it is the product of a technique called [[meta-tracing]] which transforms an interpreter into a [[Tracing just-in-time compilation|tracing just-in-time compiler]]. Since interpreters are usually easier to write than compilers, but run slower than compilers, this technique can make it easier to produce efficient implementations of programming languages. PyPy's meta-tracing toolchain is called [[RPython]].


==Details and motivation==
==Details and motivation==

Revision as of 01:20, 28 December 2017

Template:Distinguish2

Initial releasemid 2007; 17 years ago (2007)
Stable release
5.10 / 25 December 2017; 6 years ago (2017-12-25)[1]
Repository
Written inRPython
Operating systemCross-platform
TypePython interpreter and compiler toolchain
LicenseMIT
Websitepypy.org

PyPy is an alternative implementation of the Python programming language which often runs faster than the standard implementation of Python, CPython. The reason PyPy is faster is because it's a just-in-time compiler while CPython is an interpreter. Most Python code runs well on PyPy, except for code that relies on CPython extensions, which either doesn't work or incurs some overhead when run in PyPy. PyPy is interesting architecturally because it is the product of a technique called meta-tracing which transforms an interpreter into a tracing just-in-time compiler. Since interpreters are usually easier to write than compilers, but run slower than compilers, this technique can make it easier to produce efficient implementations of programming languages. PyPy's meta-tracing toolchain is called RPython.

Details and motivation

PyPy was conceived to be an implementation of Python written in a programming language that is similar to Python. This makes it easy to identify areas where it can be improved and makes PyPy more flexible and easier to experiment with than CPython.[citation needed]

PyPy aims to provide a common translation and support framework for producing implementations of dynamic languages, emphasizing a clean separation between language specification and implementation aspects. It also aims to provide a compliant, flexible and fast implementation of the Python programming language using the above framework to enable new advanced features without having to encode low level details into it.[2][3]

RPython

The PyPy interpreter itself is written in a restricted subset of Python, called RPython (Restricted Python).[4] RPython puts some constraints on the Python language such that a variable's type can be inferred at compile time.[5]

The PyPy project has developed a toolchain that analyzes RPython code and translates it into C code, which is then compiled to produce a native interpreter. It also allows for pluggable garbage collectors as well as optionally enabling Stackless Python features. Finally, it includes a just-in-time (JIT) generator which builds a just-in-time compiler into the interpreter, given a few annotations in the interpreter source code. The generated JIT compiler is a tracing JIT.[6]

RPython is now also used to write non-Python language implementation such as Pixie.[7]

Project status

PyPy is CPython 2.7.10 compatible.[8] PyPy3, released starting with version 2.3.1, is CPython 3.2.5 compatible.[9] Both versions have JIT compilation support on 32-bit/64-bit x86 and ARM processors.[10] It is tested nightly on Windows, Linux, OpenBSD and Mac OS X. PyPy is able to run pure Python software that does not rely on implementation-specific features.[11]

There is a compatibility layer for CPython C API extensions called CPyExt, but it is incomplete and experimental. The preferred way of interfacing with C shared libraries is through the built-in CFFI or ctypes libraries.

History

PyPy is a followup to the Psyco project, a just-in-time specializing compiler for Python, developed by Armin Rigo between 2002 and 2010. PyPy's aim is to have a just-in-time specializing compiler with scope, which was not available for Psyco.[clarification needed] Initially, the RPython could also be compiled into Java bytecode, CIL and JavaScript, but these backends were removed due to lack of interest.

PyPy was initially a research and development-oriented project. Reaching a mature state of development and an official 1.0 release in mid-2007, its next focus was on releasing a production-ready version with more CPython compatibility. Many of PyPy's changes have been made during coding sprints.

  • In August 2008, PyPy was able to run some popular Python libraries like Pylons,[12] Pyglet,[13] Nevow[14] and Django.[15]
  • On 12 March 2010, PyPy 1.2 was released, focusing on speed. It included a working, though not yet stable, just-in-time compiler.[16]
  • On 30 April 2011, PyPy version 1.5 was released, which reached compatibility with CPython 2.7.[17]
  • On 9 May 2013, PyPy 2.0 was released, which introduced alpha-quality support for JIT compilation on ARMv6 and ARMv7 JIT, and included CFFI in the standard library.[10][18]
  • On 20 June 2014, PyPy3 was declared stable[9] and introduced compatibility with the more modern Python 3. It was released alongside PyPy 2.3.1 and bears the same version number.
  • On 21 March 2017, the PyPy project release version 5.7 of both PyPy and PyPy3, with the latter introducing beta-quality support for Python 3.5.[19]

Funding

PyPy was funded by the European Union being a Specific Targeted Research Project[20] between December 2004 and March 2007. In June 2008, PyPy announced funding being part of the Google Open Source programs, and has agreed to focus on making PyPy more compatible with CPython. In 2009 Eurostars, a European Union funding agency specially focused on SMEs,[21] accepted a proposal from PyPy project members entitled: "PYJIT – a fast and flexible toolkit for dynamic programming languages based on PyPy". Eurostars funding lasted until August 2011.[22] At PyCon US 2011, the Python Software Foundation provided a $10,000 grant for PyPy to continue work on performance and compatibility with newer versions of the language.[23] The port to ARM architecture was sponsored in part by the Raspberry Pi Foundation.[10]

The PyPy project also accepts donations through its status blog pages.[24] There are three funding projects currently in progress: Python 3 version compatibility, built-in optimized NumPy support for numerical calculations and software transactional memory support to allow better parallelism.[10]

See also

Notes

  1. ^ "PyPy Status Blog". Retrieved 26 December 2017 – via BlogSpot.
  2. ^ Samuele Pedroni (March 2007). "PyPy – Goals and Architecture Overview".
  3. ^ "PyPy – Goals and Architecture Overview – Mission Statement". Retrieved 11 October 2013.
  4. ^ Our runtime interpreter is “RPython”, Coding Guide – PyPy documentation
  5. ^ "It is a proper subset of Python, restricted in a way that enables easy analysis and efficient code generation", Ancona et al., 2007.
  6. ^ Bolz, Carl; Cuni, Antonio; Fijalkowski, Maciej; Rigo, Armin. Tracing the Meta-Level: PyPy’s Tracing JIT Compiler. ICOOOLPS '09. doi:10.1145/1565824.1565827.
  7. ^ Timothy Balridge interview
  8. ^ "PyPy – Python compatibility". pypy.org. Retrieved 2016-04-21.
  9. ^ a b the PyPy team (20 June 2014). "PyPy3 2.3.1 – Fulcrum". PyPy blog.
  10. ^ a b c d Jake Edge (15 May 2013). "A look at the PyPy 2.0 release". LWN.net.
  11. ^ "PyPy – Python compatibility".
  12. ^ "Running pylons on top of PyPy".
  13. ^ "Running Pyglet on top of PyPy".
  14. ^ "Running Nevow on top of PyPy".
  15. ^ "PyPy runs unmodified django 1.0 beta".
  16. ^ "Introducing the PyPy 1.2 release".
  17. ^ "PyPy 1.5 Released: Catching Up".
  18. ^ "PyPy 2.0 – Einstein Sandwich".
  19. ^ "PyPy2.7 and PyPy3.5 v5.7 – two in one release".
  20. ^ "EU Community Research and Development Information Service Entry".
  21. ^ "Eurostars – Aim Higher".
  22. ^ "Project Page on Eureka Network".
  23. ^ "A thank you to the PSF".
  24. ^ "PyPy Status Blog: Oh, and btw: PyPy gets funding through "Eurostars"".

References