CINXE.COM
PyPy - Features | PyPy
<!DOCTYPE html> <html prefix=" og: http://ogp.me/ns# article: http://ogp.me/ns/article# " vocab="http://ogp.me/ns" lang="en"> <head> <meta charset="utf-8"> <meta name="description" content="What is PyPy and what are its features"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>PyPy - Features | PyPy</title> <link href="assets/css/rst_base.css" rel="stylesheet" type="text/css"> <link href="assets/css/nikola_rst.css" rel="stylesheet" type="text/css"> <link href="assets/css/code.css" rel="stylesheet" type="text/css"> <link href="assets/css/theme.css" rel="stylesheet" type="text/css"> <link href="assets/css/styles.css" rel="stylesheet" type="text/css"> <meta name="theme-color" content="#5670d4"> <meta name="generator" content="Nikola (getnikola.com)"> <link rel="alternate" type="application/rss+xml" title="RSS" hreflang="en" href="rss.xml"> <link rel="canonical" href="https://www.pypy.org/features.html"> <link rel="icon" href="favicon2.ico" sizes="16x16"> <link rel="icon" href="favicon32x32.ico" sizes="32x32"> <!--[if lt IE 9]><script src="assets/js/html5shiv-printshiv.min.js"></script><![endif]--><link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="assets/css/tipuesearch.css"> <meta name="author" content="The PyPy Team"> <meta property="og:site_name" content="PyPy"> <meta property="og:title" content="PyPy - Features"> <meta property="og:url" content="https://www.pypy.org/features.html"> <meta property="og:description" content="What is PyPy and what are its features"> <meta property="og:type" content="article"> <meta property="article:published_time" content="2019-12-28T16:14:02Z"> </head> <body> <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a> <div id="container"> <header id="header"><!-- Adapted from https://www.taniarascia.com/responsive-dropdown-navigation-bar --><section class="navigation"><div class="nav-container"> <div class="brand"> <a href="index.html"> <image id="toplogo" src="images/pypy-logo.svg" width="75px;" alt="PyPy/"></image></a> </div> <nav><ul class="nav-list"> <li> <a href="#!">Features</a> <ul class="nav-dropdown"> <li> <a href="#">What is PyPy?</a> </li> <li> <a href="compat.html">Compatibility</a> </li> <li> <a href="performance.html">Performance</a> </li> </ul> </li> <li> <a href="download.html">Download</a> </li> <li> <a href="http://doc.pypy.org">Dev Docs</a> </li> <li> <a href="#!">Blog</a> <ul class="nav-dropdown"> <li> <a href="blog/">Index</a> </li> <li> <a href="categories/">Tags</a> </li> <li> <a href="archive.html">Archive by year</a> </li> <li> <a href="rss.xml">RSS feed</a> </li> <li> <a href="https://morepypy.blogspot.com/">Old site</a> </li> </ul> </li> <li> <a href="#!">About</a> <ul class="nav-dropdown"> <li> <a href="https://bsky.app/profile/pypyproject.bsky.social">Bluesky</a> </li> <li> <a href="https://libera.irclog.whitequark.org/pypy">IRC logs</a> </li> <li> <a href="https://www.youtube.com/playlist?list=PLADqad94yVqDRQXuqxKrPS5QnVqbDLlRt">YouTube</a> </li> <li> <a href="https://www.twitch.tv/pypyproject">Twitch</a> </li> <li> <a href="pypy-sponsors.html">Sponsors</a> </li> <li> <a href="howtohelp.html">How To Help?</a> </li> <li> <a href="contact.html">Contact</a> </li> </ul> </li> </ul></nav><div class="nav-mobile"> <a id="nav-toggle" href="#!"> <span></span></a> </div> </div> </section><div class="searchform" role="search"> <form class="navbar-form navbar-left" action="search.html" role="search"> <div class="form-group"> <input type="text" class="form-control" id="tipue_search_input" name="q" placeholder="Search…" autocomplete="off"> </div> <input type="submit" value="Local Search" style="visibility: hidden;"> </form> </div> </header><main id="content"><article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h1 class="p-name entry-title" itemprop="headline name"><a href="#" class="u-url">PyPy - Features</a></h1> </header><div class="e-content entry-content" itemprop="articleBody text"> <p><strong>PyPy</strong> is a replacement for CPython. It is built using the RPython language that was co-developed with it. The main reason to use it instead of CPython is speed: it runs generally faster (see next section).</p> <p><strong>PyPy</strong> implements <strong>Python 2.7.18 and 3.11.11</strong>. It supports all of the core language. It supports most of the commonly used Python standard library modules. For known differences with CPython, see our <a class="reference external" href="compat.html">compatibility</a> page.</p> <p>The following CPU architectures are supported and maintained:</p> <ul class="simple"> <li><p><a class="reference external" href="http://en.wikipedia.org/wiki/IA-32">x86 (IA-32)</a> and <a class="reference external" href="http://en.wikipedia.org/wiki/X86_64">x86_64</a></p></li> <li><p><a class="reference external" href="http://en.wikipedia.org/wiki/ARM">ARM</a> platforms (ARMv6 or ARMv7, with VFPv3, and Apple Silicon arm64)</p></li> <li><p><a class="reference external" href="http://en.wikipedia.org/wiki/AArch64">AArch64</a></p></li> <li><p><cite>RISCV</cite></p></li> <li><p><a class="reference external" href="https://en.wikipedia.org/wiki/PowerPC">PowerPC</a> 64bit both little and big endian</p></li> <li><p><a class="reference external" href="https://en.wikipedia.org/wiki/IBM_System/390">System Z (s390x)</a></p></li> </ul> <p>PyPy's x86 version runs on several operating systems, such as Linux (32/64 bits), MacOS (64 bits), Windows (32 bits), OpenBSD, FreeBSD. Non-x86 versions are supported on Linux, and ARM64 is supported on MacOS.</p> <p>If you are interested in helping, see our <a class="reference external" href="howtohelp.html">howtohelp</a> page.</p> <section id="the-main-features-of-pypy"><h2>The main features of PyPy:<a href="#the-main-features-of-pypy" class="headerlink" title="Permalink to this heading">¶</a></h2> <section id="speed"><h3>Speed<a href="#speed" class="headerlink" title="Permalink to this heading">¶</a></h3> <p>Our <a class="reference external" href="download.html#with-a-jit-compiler">main executable</a> comes with a Just-in-Time compiler. It is <a class="reference external" href="http://speed.pypy.org/">really fast</a> in running most benchmarks—including very large and complicated Python applications, not just 10-liners.</p> <p>There are two cases that you should be aware where PyPy will <em>not</em> be able to speed up your code:</p> <ul class="simple"> <li><p>Short-running processes: if it doesn't run for at least a few seconds, then the JIT compiler won't have enough time to warm up.</p></li> <li><p>If all the time is spent in run-time libraries (i.e. in C functions), and not actually running Python code, the JIT compiler will not help.</p></li> </ul> <p>So the case where PyPy works best is when executing long-running programs where a significant fraction of the time is spent executing Python code. This is the case covered by the majority of <a class="reference external" href="http://speed.pypy.org/">our benchmarks</a>, but not all of them --- the goal of PyPy is to get speed but still support (ideally) any Python program.</p> </section><section id="memory-usage"><h3>Memory usage<a href="#memory-usage" class="headerlink" title="Permalink to this heading">¶</a></h3> <p>Memory-hungry Python programs (several hundreds of MBs or more) might end up taking less space than they do in CPython. It is not always the case, though, as it depends on a lot of details. Also note that the baseline is higher than CPython's.</p> </section><section id="stackless"><h3>Stackless<a href="#stackless" class="headerlink" title="Permalink to this heading">¶</a></h3> <p>Support for <a class="reference external" href="http://www.stackless.com/">Stackless</a> and greenlets are now integrated in the normal PyPy. More detailed information is available <a class="reference external" href="http://doc.pypy.org/en/latest/stackless.html">here</a>.</p> </section><section id="other-features"><h3>Other features<a href="#other-features" class="headerlink" title="Permalink to this heading">¶</a></h3> <p>PyPy has many secondary features and semi-independent projects. We will mention here:</p> <ul> <li> <p><strong>Other languages:</strong> we also implemented other languages that makes use of our RPython toolchain: <a class="reference external" href="https://github.com/cosmoharrigan/pyrolog">Prolog</a> (almost complete), as well as <a class="reference external" href="https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-smalltalk.html">Smalltalk</a>, <a class="reference external" href="https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-js.html">JavaScript</a>, <a class="reference external" href="https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-io.html">Io</a>, <a class="reference external" href="https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-scheme.html">Scheme</a> and <a class="reference external" href="https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-gameboy.html">Gameboy</a>.</p> <p>There is also a Ruby implementation called <a class="reference external" href="https://github.com/topazproject/topaz">Topaz</a> and a PHP implementation called <a class="reference external" href="http://www.hippyvm.com/">HippyVM</a>.</p> </li> <li><p><strong>Emulators:</strong> PyPy really shines as a platform to model hardware. The <a class="reference external" href="https://docs.pydrofoil.org">Pydrofoil</a> emulator for RISC-V and ARM64 ISA models written in <a class="reference external" href="https://github.com/rems-project/sail">Sail</a> is very performant, usually an order of magnitude faster than other emulators generated by Sail</p></li> </ul></section><section id="sandboxing"><h3>Sandboxing<a href="#sandboxing" class="headerlink" title="Permalink to this heading">¶</a></h3> <p>PyPy's <em>sandboxing</em> is a working prototype for the idea of running untrusted user programs. Unlike other sandboxing approaches for Python, PyPy's does not try to limit language features considered "unsafe". Instead we replace all calls to external libraries (C or platform) with a stub that communicates with an external process handling the policy.</p> <aside class="admonition note"><p class="admonition-title">Note</p> <p><strong>Please be aware that it is a prototype only.</strong> It needs work to become more complete, and you are welcome to help. In particular, almost none of the extension modules work (not even <code class="docutils literal">time</code> ), and <code class="docutils literal">pypy_interact</code> is merely a demo. Also, a more complete system would include a way to do the same as <code class="docutils literal">pypy_interact</code> from other languages than Python, to embed a sandboxed interpreter inside programs written in other languages.</p> </aside><p>To run the sandboxed process, you need to get the full sources and build <code class="docutils literal"><span class="pre">pypy-sandbox</span></code> from it (see <a class="reference external" href="download.html#building-from-source">Building from source</a>). These instructions give you a <code class="docutils literal"><span class="pre">pypy-c</span></code> that you should rename to <code class="docutils literal"><span class="pre">pypy-sandbox</span></code> to avoid future confusion. Then run:</p> <div class="code"><pre class="code bash"><a id="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-1" name="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-1" href="features.html#rest_code_5b13aa18937c4a599655a1b6f7d3edd5-1"></a><span class="nb">cd</span><span class="w"> </span>pypy/sandbox <a id="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-2" name="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-2" href="features.html#rest_code_5b13aa18937c4a599655a1b6f7d3edd5-2"></a>pypy_interact.py<span class="w"> </span>path/to/pypy-sandbox <a id="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-3" name="rest_code_5b13aa18937c4a599655a1b6f7d3edd5-3" href="features.html#rest_code_5b13aa18937c4a599655a1b6f7d3edd5-3"></a><span class="c1"># don't confuse it with pypy/goal/pyinteractive.py!</span> </pre></div> <p>You get a fully sandboxed interpreter, in its own filesystem hierarchy (try <code class="docutils literal"><span class="pre">os.listdir('/')</span></code>). For example, you would run an untrusted script as follows:</p> <div class="code"><pre class="code bash"><a id="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-1" name="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-1" href="features.html#rest_code_1798b8afb8e34394b3b70c0ea0f2c647-1"></a>mkdir<span class="w"> </span>virtualtmp <a id="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-2" name="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-2" href="features.html#rest_code_1798b8afb8e34394b3b70c0ea0f2c647-2"></a>cp<span class="w"> </span>untrusted.py<span class="w"> </span>virtualtmp/ <a id="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-3" name="rest_code_1798b8afb8e34394b3b70c0ea0f2c647-3" href="features.html#rest_code_1798b8afb8e34394b3b70c0ea0f2c647-3"></a>pypy_interact.py<span class="w"> </span>--tmp<span class="o">=</span>virtualtmp<span class="w"> </span>pypy-sandbox<span class="w"> </span>/tmp/untrusted.py </pre></div> <p>Note that the path <code class="docutils literal">/tmp/untrusted.py</code> is a path inside the sandboxed filesystem. You don't have to put <code class="docutils literal">untrusted.py</code> in the real <code class="docutils literal">/tmp</code> directory at all.</p> <p>To read more about its features, try <code class="docutils literal">pypy_interact.py <span class="pre">--help</span></code> or go to <a class="reference external" href="http://pypy.readthedocs.org/en/latest/sandbox.html">our documentation site</a>.</p> </section></section> </div> </article></main><footer id="footer"><p> </p> <div class="myfooter"> <div class="logotext"> © 2025 <a href="mailto:pypy-dev@pypy.org">The PyPy Team</a> Built with <a href="https://getnikola.com" rel="nofollow">Nikola</a> Last built 2025-02-26T12:28 </div> <div style="margin-left: auto"> <a href="rss.xml">RSS feed</a> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" crossorigin="anonymous"></script><script src="assets/js/styles.js"></script></footer> </div> </body> </html>