Author: Antonio Cuni <anto.c...@gmail.com> Branch: extradoc Changeset: r5895:d0dc59e05080 Date: 2018-09-04 01:36 +0200 http://bitbucket.org/pypy/extradoc/changeset/d0dc59e05080/
Log: small tweaks diff --git a/blog/draft/2018-09-cpyext/cpyext.rst b/blog/draft/2018-09-cpyext/cpyext.rst --- a/blog/draft/2018-09-cpyext/cpyext.rst +++ b/blog/draft/2018-09-cpyext/cpyext.rst @@ -3,7 +3,7 @@ cpyext is PyPy's subsistem which is responsible to provide a compatibility layer to compile and run CPython C extensions inside PyPy. Often people asks -why a particular extension doesn't work or it is very slow on PyPy, but +why it this particular extension doesn't work or it is very slow on PyPy, but usually it is hard to answer without going into technical details: the goal of this blog post is to explain some of these technical details, so that we can simply link here instead of explaing again and again :). @@ -27,11 +27,11 @@ C API Overview --------------- -At the C level, Python objects are represented as ``PyObject *``, +In CPython, at the C level, Python objects are represented as ``PyObject *``, i.e. (mostly) opaque pointers to some common "base struct". CPython uses a very simple memory management scheme: when you create an -object, you allocate a block of memory of the appropriate size on the heap: +object, you allocate a block of memory of the appropriate size on the heap; depending on the details you might end up calling different allocators, but for the sake of simplicity, you can think that this ends up being a call to ``malloc()``. The resulting block of memory is initialized and casted to to @@ -50,9 +50,9 @@ .. _decrement: https://docs.python.org/2/c-api/refcounting.html#c.Py_DECREF Generally speaking, the only way to operate on ``PyObject *`` is to call the -appropriate API functions. For example, to convert a given object as a C -integer, you can use _`PyInt_AsLong()`; to add to objects together, you can -call _`PyNumber_Add()` +appropriate API functions. For example, to convert a given ``PyObject *`` to a C +integer, you can use _`PyInt_AsLong()`; to add two objects together, you can +call _`PyNumber_Add()`. .. _`PyInt_AsLong()`: https://docs.python.org/2/c-api/int.html?highlight=pyint_check#c.PyInt_AsLong .. _`PyNumber_Add()`: https://docs.python.org/2/c-api/number.html#c.PyNumber_Add @@ -76,7 +76,7 @@ Actually, the code above is not too far from the actual -implementation. However, there are tons of gory details which makes it much +implementation. However, there are tons of gory details which make it much harder than what it looks, and much slower unless you pay a lot of attention to performance. _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit