Skip to content

Commit d12d649

Browse files
committed
add headings to compat page
1 parent bdbb1d8 commit d12d649

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

pages/compat.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
.. link:
77
.. description:
88
9+
The goal of this page is to point out some of the differences between running
10+
python with PyPy and with CPython
11+
12+
TL;DR
13+
-----
14+
915
Pure python code works, but there are a few differences with object lifetime
1016
management. Modules that use the `CPython C API`_ will probably work, but will
1117
not achieve a speedup via the JIT. We encourage library authors to use `CFFI`_
@@ -15,11 +21,16 @@ If you are looking for how to use PyPy with the scientific python ecosystem,
1521
we encourage you to use `conda`_, since they repackage common libraries like
1622
scikit-learn and SciPy for PyPy.
1723

24+
Refcounting, ``__del__``, and resource use
25+
------------------------------------------
26+
1827
The main difference in pure-python code that is not going to be fixed is that
1928
PyPy does
20-
not support refcounting semantics. The following code won't fill the
29+
not support refcounting semantics for "automatically" releasing state when
30+
an object's ``__del__`` is called. The following code won't fill the
2131
file immediately, but only after a certain period of time, when the GC
22-
does a collection and flushes the output:
32+
does a collection and flushes the output, since the file is only closed when
33+
the ``__del__`` method is called:
2334

2435
.. code-block:: python
2536
@@ -71,8 +82,11 @@ as on CPython: they run "some time later" in PyPy (or not at all if
7182
the program finishes running in the meantime). See `more details
7283
here`_.
7384

74-
Note that PyPy returns unused memory to the operating system if there
75-
is a madvise() system call (at least Linux, OS X, BSD) or on Windows. It is
85+
Why is memory usage so high?
86+
----------------------------
87+
88+
Note that PyPy returns unused memory to the operating system only after
89+
a madvise() system call (at least Linux, OS X, BSD) or on Windows. It is
7690
important to realize that you may not see this in ``top``. The unused
7791
pages are marked with ``MADV_FREE``, which tells the system "if you
7892
need more memory at some point, grab this page". As long as memory is
@@ -81,6 +95,9 @@ this rule are systems with no ``MADV_FREE``, where we use
8195
``MADV_DONTNEED``, which forcefully lowers the ``RES``. This includes
8296
Linux <= 4.4.)
8397

98+
More info
99+
---------
100+
84101
A more complete list of known differences is available at `our dev site`_.
85102

86103
.. _`CPython C API`: http://docs.python.org/c-api/

0 commit comments

Comments
 (0)