Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e01517

Browse files
committed
Small updates and grammatical adjustments.
Remove comment about this manual being out of date from the abstract.
1 parent dce019e commit 8e01517

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

Doc/ext/ext.tex

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,17 @@ \chapter*{Front Matter\label{front}}
5151
the language its wide application range.
5252

5353
For a detailed description of the whole Python/C API, see the separate
54-
\emph{Python/C API Reference Manual}. \strong{Note:} While that
55-
manual is still in a state of flux, it is safe to say that it is much
56-
more up to date than the manual you're reading currently (which has
57-
been in need for an upgrade for some time now).
54+
\emph{Python/C API Reference Manual}.
5855

5956

6057
\end{abstract}
6158

6259
\tableofcontents
6360

6461

65-
\chapter{Extending Python with C or \Cpp{} code}
62+
\chapter{Extending Python with C or \Cpp{} \label{intro}}
6663

6764

68-
%\section{Introduction}
69-
\label{intro}
70-
7165
It is quite easy to add new built-in modules to Python, if you know
7266
how to program in C. Such \dfn{extension modules} can do two things
7367
that can't be done directly in Python: they can implement new built-in
@@ -753,9 +747,7 @@ \section{Format Strings for \cfunction{PyArg_ParseTuple()}
753747
long k, l;
754748
char *s;
755749
int size;
756-
\end{verbatim}
757750
758-
\begin{verbatim}
759751
ok = PyArg_ParseTuple(args, ""); /* No arguments */
760752
/* Python call: f() */
761753
\end{verbatim}
@@ -1016,11 +1008,10 @@ \section{The \cfunction{Py_BuildValue()} Function
10161008
1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))
10171009
\end{verbatim}
10181010

1011+
10191012
\section{Reference Counts
10201013
\label{refcounts}}
10211014

1022-
%\subsection{Introduction}
1023-
10241015
In languages like C or \Cpp{}, the programmer is responsible for
10251016
dynamic allocation and deallocation of memory on the heap. In C,
10261017
this is done using the functions \cfunction{malloc()} and
@@ -1129,6 +1120,7 @@ \subsection{Reference Counting in Python
11291120
and gives full owner responsibilities (i.e., the new owner must
11301121
dispose of the reference properly, as well as the previous owner).
11311122

1123+
11321124
\subsection{Ownership Rules
11331125
\label{ownershipRules}}
11341126

@@ -1179,6 +1171,7 @@ \subsection{Ownership Rules
11791171
Python must be an owned reference --- ownership is tranferred from the
11801172
function to its caller.
11811173

1174+
11821175
\subsection{Thin Ice
11831176
\label{thinIce}}
11841177

@@ -1261,6 +1254,7 @@ \subsection{Thin Ice
12611254
}
12621255
\end{verbatim}
12631256

1257+
12641258
\subsection{NULL Pointers
12651259
\label{nullPointers}}
12661260

@@ -1413,10 +1407,13 @@ \section{Providing a C API for an Extension Module
14131407
\end{verbatim}
14141408

14151409
In the beginning of the module, right after the line
1410+
14161411
\begin{verbatim}
14171412
#include "Python.h"
14181413
\end{verbatim}
1414+
14191415
two more lines must be added:
1416+
14201417
\begin{verbatim}
14211418
#define SPAM_MODULE
14221419
#include "spammodule.h"
@@ -1426,6 +1423,7 @@ \section{Providing a C API for an Extension Module
14261423
included in the exporting module, not a client module. Finally,
14271424
the module's initialization function must take care of initializing
14281425
the C API pointer array:
1426+
14291427
\begin{verbatim}
14301428
void
14311429
initspam()
@@ -1580,15 +1578,16 @@ \chapter{Building C and \Cpp{} Extensions on \UNIX{}
15801578
\end{verbatim}
15811579

15821580
This is the simplest form of a module definition line. It defines a
1583-
dule, \module{ExtensionClass}, which has a single source file,
1581+
module, \module{ExtensionClass}, which has a single source file,
15841582
\file{ExtensionClass.c}.
15851583

1586-
Here is a slightly more complex example that uses an \strong{-I}
1587-
option to specify an include directory:
1584+
This slightly more complex example uses an \strong{-I} option to
1585+
specify an include directory:
15881586

15891587
\begin{verbatim}
1588+
EC=/projects/ExtensionClass
15901589
cPersistence cPersistence.c -I$(EC)
1591-
\end{verbatim}
1590+
\end{verbatim} % $ <-- bow to font lock
15921591

15931592
This example also illustrates the format for variable references.
15941593

@@ -1614,7 +1613,7 @@ \chapter{Building C and \Cpp{} Extensions on \UNIX{}
16141613
# include file.
16151614
EC=/projects/ExtensionClass
16161615
cPersistence cPersistence.c -I$(EC)
1617-
\end{verbatim}
1616+
\end{verbatim} % $ <-- bow to font lock
16181617

16191618
After the \file{Setup} file has been created, \file{Makefile.pre.in}
16201619
is run with the \samp{boot} target to create a make file:
@@ -1634,7 +1633,8 @@ \chapter{Building C and \Cpp{} Extensions on \UNIX{}
16341633
\file{Setup} file is changed. The make file automatically rebuilds
16351634
itself if the \file{Setup} file changes.
16361635

1637-
\section{Building Custom Interpreters}
1636+
1637+
\section{Building Custom Interpreters \label{custom-interps}}
16381638

16391639
The make file built by \file{Makefile.pre.in} can be run with the
16401640
\samp{static} target to build an interpreter:
@@ -1648,7 +1648,8 @@ \section{Building Custom Interpreters}
16481648
\samp{*shared*} line is omitted from the Setup file when a custom
16491649
interpreter is desired.
16501650

1651-
\section{Module Definition Options}
1651+
1652+
\section{Module Definition Options \label{module-defn-options}}
16521653

16531654
Several compiler options are supported:
16541655

@@ -1666,13 +1667,13 @@ \section{Module Definition Options}
16661667
in variable variables.
16671668

16681669
Source files can include files with \file{.c}, \file{.C}, \file{.cc},
1669-
and \file{.c++} extensions.
1670+
\file{.cpp}, \file{.cxx}, and \file{.c++} extensions.
16701671

1671-
Other input files include files with \file{.o} or \file{.a}
1672-
extensions.
1672+
Other input files include files with \file{.a}, \file{.o}, \file{.sl},
1673+
and \file{.so} extensions.
16731674

16741675

1675-
\section{Example}
1676+
\section{Example \label{module-defn-example}}
16761677

16771678
Here is a more complicated example from \file{Modules/Setup.in}:
16781679

@@ -1703,7 +1704,9 @@ \section{Distributing your extension modules
17031704
people who do not have a source distribution of Python.
17041705

17051706
Do not distribute a make file. People building your modules
1706-
should use \file{Makefile.pre.in} to build their own make file.
1707+
should use \file{Makefile.pre.in} to build their own make file. A
1708+
\file{README} file included in the package should provide simple
1709+
instructions to perform the build.
17071710

17081711
Work is being done to make building and installing Python extensions
17091712
easier for all platforms; this work in likely to supplant the current
@@ -1724,6 +1727,7 @@ \chapter{Building C and \Cpp{} Extensions on Windows
17241727
Python extensions and the \UNIX{} programming interested in producing
17251728
software which can be successfully built on both \UNIX{} and Windows.
17261729

1730+
17271731
\section{A Cookbook Approach \label{win-cookbook}}
17281732

17291733
\sectionauthor{Neil Schemenauer}{[email protected]}

0 commit comments

Comments
 (0)