Skip to content

Commit 638d2a0

Browse files
committed
Address more review
1 parent a17458a commit 638d2a0

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

Doc/extending/extending.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Extracting Parameters in Extension Functions
372372
The :ref:`tutorial <first-extension-module>` uses a ":c:data:`METH_O`"
373373
function, which is limited to a single Python argument.
374374
If you want more, you can use :c:data:`METH_VARARGS` instead.
375-
With this flag, the C function will receive a *tuple* of arguments
375+
With this flag, the C function will receive a :py:class:`tuple` of arguments
376376
instead of a single object.
377377

378378
For unpacking the tuple, CPython provides the :c:func:`PyArg_ParseTuple`
@@ -478,11 +478,11 @@ Some example calls::
478478
Keyword Parameters for Extension Functions
479479
==========================================
480480

481-
If you also want your function to accept *keyword* arguments,
482-
use the :c:data:`METH_KEYWORDS` flag in combination with
483-
:c:data:`METH_VARARGS`.
484-
(It can also be used with other flags; see its documentation for the allowed
485-
combinations.)
481+
If you also want your function to accept
482+
:term:`keyword arguments <keyword argument>`, use the :c:data:`METH_KEYWORDS`
483+
flag in combination with :c:data:`METH_VARARGS`.
484+
(:c:data:`!METH_KEYWORDS` can also be used with other flags; see its
485+
documentation for the allowed combinations.)
486486

487487
In this case, the C function should accept a third ``PyObject *`` parameter
488488
which will be a dictionary of keywords.

Doc/extending/first-extension-module.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ You need to have suitable C compiler and Python development headers installed.
3737
On Linux, headers are often in a package like ``python3-dev``
3838
or ``python3-devel``.
3939

40+
You need to be able to install Python packages.
41+
This tutorial uses `pip <https://pip.pypa.io/>`__ (``pip install``), but you
42+
can substitute any tool that can build and install ``pyproject.toml``-based
43+
projects, like `uv <https://docs.astral.sh/uv/>`_ (``uv pip install``).
44+
Preferably, have a :ref:`virtual environment <venv-def>` activated.
45+
4046

4147
.. note::
4248

4349
This tutorial uses APIs that were added in CPython 3.15.
4450
To create an extension that's compatible with earlier versions of CPython,
4551
please follow an earlier version of this documentation.
4652

47-
This tutorial uses some syntax added in C11 and C++20.
53+
This tutorial uses C syntax added in C11 and C++20.
4854
If your extension needs to be compatible with earlier standards,
4955
please follow tutorials in documentation for Python 3.14 or below.
5056

@@ -113,7 +119,7 @@ Running your build tool
113119
=======================
114120

115121
With only the includes in place, your extension won't do anything.
116-
Still, it's a good time to try compiling and importing it.
122+
Still, it's a good time to compile it and try to import it.
117123
This will ensure that your build tool works, so that you can make
118124
and test incremental changes as you follow the rest of the text.
119125

@@ -170,10 +176,9 @@ Now, build install the *project in the current directory* (``.``) via ``pip``:
170176
.. tip::
171177

172178
If you don't have ``pip`` installed, run ``python -m ensurepip``,
173-
preferably in a :mod:`virtual environment <venv>`.
174-
You can also use another tool that can build and install
175-
``pyproject.toml``-based projects, like
176-
`uv <https://docs.astral.sh/uv/>`_ (``uv pip install .``).
179+
preferably in a :ref:`virtual environment <venv-def>`.
180+
(Or, if you prefer another tool that can build and install
181+
``pyproject.toml``-based projects, use that.)
177182

178183
.. _meson-python: https://mesonbuild.com/meson-python/
179184
.. _virtual environment: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments
@@ -263,8 +268,8 @@ Define this array just before your export hook:
263268
{0, NULL}
264269
};
265270
266-
For both name and docstring, the values are C strings -- that is,
267-
NUL-terminated UTF-8 encoded byte arrays.
271+
For both :c:data:`Py_mod_name` and :c:data:`Py_mod_doc`, the values are C
272+
strings -- that is, NUL-terminated UTF-8 encoded byte arrays.
268273

269274
Note the zero-filled sentinel entry at the end.
270275
If you forget it, you'll trigger undefined behavior.
@@ -595,7 +600,7 @@ add the following function to your module for now:
595600
596601
This is a shim for an old-style :ref:`initialization function <extension-export-hook>`,
597602
which was required in extension modules for CPython 3.14 and below.
598-
Current CPython will not call it, but some build tools may still assume that
603+
Current CPython does not need it, but some build tools may still assume that
599604
all extension modules need to define it.
600605

601606
If you use this workaround, you will get the exception

0 commit comments

Comments
 (0)