blob: 75485c6290297843865c4f3853fce683af8fb4ae [file] [log] [blame]
Guido van Rossum0011d931996-08-22 23:18:55 +00001% cfuncdesc should be called as an \begin{cfuncdesc} ... \end{cfuncdesc}
2\newcommand{\cfuncline}[3]{\item[\code{#1 #2(\varvars{#3})}]\ttindex{#2}}
3\newcommand{\cfuncdesc}[3]{\fulllineitems\cfuncline{#1}{#2}{#3}}
4\let\endcfuncdesc\endfulllineitems
Guido van Rossum267e80d1996-08-09 21:01:07 +00005
Guido van Rossum0011d931996-08-22 23:18:55 +00006\newcommand{\NULL}{\code{NULL}}
7
8\chapter{Extension Reference}
Guido van Rossum267e80d1996-08-09 21:01:07 +00009
10From the viewpoint of of C access to Python services, we have:
11
12\begin{enumerate}
13 \item "Very high level layer": two or three functions that let you exec or
14 eval arbitrary Python code given as a string in a module whose name is
15 given, passing C values in and getting C values out using
16 mkvalue/getargs style format strings. This does not require the user
17 to declare any variables of type "PyObject *". This should be enough
18 to write a simple application that gets Python code from the user,
19 execs it, and returns the output or errors.
20
21 \item "Abstract objects layer": which is the subject of this proposal.
22 It has many functions operating on objects, and lest you do many
23 things from C that you can also write in Python, without going
24 through the Python parser.
25
26 \item "Concrete objects layer": This is the public type-dependent
27 interface provided by the standard built-in types, such as floats,
28 strings, and lists. This interface exists and is currently
29 documented by the collection of include files provides with the
30 Python distributions.
31
32 From the point of view of Python accessing services provided by C
33 modules:
34
35 \item "Python module interface": this interface consist of the basic
36 routines used to define modules and their members. Most of the
37 current extensions-writing guide deals with this interface.
38
39 \item "Built-in object interface": this is the interface that a new
40 built-in type must provide and the mechanisms and rules that a
41 developer of a new built-in type must use and follow.
42\end{enumerate}
43
44 The Python C object interface provides four protocols: object,
45 numeric, sequence, and mapping. Each protocol consists of a
46 collection of related operations. If an operation that is not
47 provided by a particular type is invoked, then a standard exception,
48 NotImplementedError is raised with a operation name as an argument.
49 In addition, for convenience this interface defines a set of
50 constructors for building objects of built-in types. This is needed
51 so new objects can be returned from C functions that otherwise treat
52 objects generically.
53
Guido van Rossum0011d931996-08-22 23:18:55 +000054\section{Object Protocol}
55
56 \begin{cfuncdesc}{int}{PyObject_Print}{PyObject *o, FILE *fp, int flags}
Guido van Rossum267e80d1996-08-09 21:01:07 +000057 Print an object \code{o}, on file \code{fp}. Returns -1 on error
58 The flags argument is used to enable certain printing
59 options. The only option currently supported is \code{Py_Print_RAW}.
Guido van Rossum0011d931996-08-22 23:18:55 +000060 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000061
Guido van Rossum0011d931996-08-22 23:18:55 +000062 \begin{cfuncdesc}{int}{PyObject_HasAttrString}{PyObject *o, char *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +000063 Returns 1 if o has the attribute attr_name, and 0 otherwise.
Guido van Rossum0011d931996-08-22 23:18:55 +000064 This is equivalent to the Python expression:
Guido van Rossum267e80d1996-08-09 21:01:07 +000065 \code{hasattr(o,attr_name)}.
66 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +000067 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000068
Guido van Rossum0011d931996-08-22 23:18:55 +000069 \begin{cfuncdesc}{PyObject*}{PyObject_AttrString}{PyObject *o, char *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +000070 Retrieve an attributed named attr_name form object o.
Guido van Rossum0011d931996-08-22 23:18:55 +000071 Returns the attribute value on success, or {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +000072 This is the equivalent of the Python expression: \code{o.attr_name}.
Guido van Rossum0011d931996-08-22 23:18:55 +000073 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000074
75
Guido van Rossum0011d931996-08-22 23:18:55 +000076 \begin{cfuncdesc}{int}{PyObject_HasAttr}{PyObject *o, PyObject *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +000077 Returns 1 if o has the attribute attr_name, and 0 otherwise.
78 This is equivalent to the Python expression:
79 \code{hasattr(o,attr_name)}.
80 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +000081 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000082
83
Guido van Rossum0011d931996-08-22 23:18:55 +000084 \begin{cfuncdesc}{PyObject*}{PyObject_GetAttr}{PyObject *o, PyObject *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +000085 Retrieve an attributed named attr_name form object o.
Guido van Rossum0011d931996-08-22 23:18:55 +000086 Returns the attribute value on success, or {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +000087 This is the equivalent of the Python expression: o.attr_name.
Guido van Rossum0011d931996-08-22 23:18:55 +000088 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000089
90
Guido van Rossum0011d931996-08-22 23:18:55 +000091 \begin{cfuncdesc}{int}{PyObject_SetAttrString}{PyObject *o, char *attr_name, PyObject *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +000092 Set the value of the attribute named \code{attr_name}, for object \code{o},
93 to the value \code{v}. Returns -1 on failure. This is
94 the equivalent of the Python statement: \code{o.attr_name=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +000095 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +000096
97
Guido van Rossum0011d931996-08-22 23:18:55 +000098 \begin{cfuncdesc}{int}{PyObject_SetAttr}{PyObject *o, PyObject *attr_name, PyObject *v}
99 Set the value of the attribute named \code{attr_name}, for
100 object \code{o},
Guido van Rossum267e80d1996-08-09 21:01:07 +0000101 to the value \code{v}. Returns -1 on failure. This is
102 the equivalent of the Python statement: \code{o.attr_name=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000103 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000104
105
Guido van Rossum0011d931996-08-22 23:18:55 +0000106 \begin{cfuncdesc}{int}{PyObject_DelAttrString}{PyObject *o, char *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000107 Delete attribute named \code{attr_name}, for object \code{o}. Returns -1 on
108 failure. This is the equivalent of the Python
109 statement: \code{del o.attr_name}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000110 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000111
112
Guido van Rossum0011d931996-08-22 23:18:55 +0000113 \begin{cfuncdesc}{int}{PyObject_DelAttr}{PyObject *o, PyObject *attr_name}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000114 Delete attribute named \code{attr_name}, for object \code{o}. Returns -1 on
115 failure. This is the equivalent of the Python
116 statement: \code{del o.attr_name}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000117 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000118
119
Guido van Rossum0011d931996-08-22 23:18:55 +0000120 \begin{cfuncdesc}{int}{PyObject_Cmp}{PyObject *o1, PyObject *o2, int *result}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000121 Compare the values of \code{o1} and \code{o2} using a routine provided by
122 \code{o1}, if one exists, otherwise with a routine provided by \code{o2}.
123 The result of the comparison is returned in \code{result}. Returns
124 -1 on failure. This is the equivalent of the Python
125 statement: \code{result=cmp(o1,o2)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000126 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000127
128
Guido van Rossum0011d931996-08-22 23:18:55 +0000129 \begin{cfuncdesc}{int}{PyObject_Compare}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000130 Compare the values of \code{o1} and \code{o2} using a routine provided by
131 \code{o1}, if one exists, otherwise with a routine provided by \code{o2}.
132 Returns the result of the comparison on success. On error,
133 the value returned is undefined. This is equivalent to the
134 Python expression: \code{cmp(o1,o2)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000135 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000136
137
Guido van Rossum0011d931996-08-22 23:18:55 +0000138 \begin{cfuncdesc}{PyObject*}{PyObject_Repr}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000139 Compute the string representation of object, \code{o}. Returns the
Guido van Rossum0011d931996-08-22 23:18:55 +0000140 string representation on success, {\NULL} on failure. This is
Guido van Rossum267e80d1996-08-09 21:01:07 +0000141 the equivalent of the Python expression: \code{repr(o)}.
142 Called by the \code{repr()} built-in function and by reverse quotes.
Guido van Rossum0011d931996-08-22 23:18:55 +0000143 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000144
145
Guido van Rossum0011d931996-08-22 23:18:55 +0000146 \begin{cfuncdesc}{PyObject*}{PyObject_Str}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000147 Compute the string representation of object, \code{o}. Returns the
Guido van Rossum0011d931996-08-22 23:18:55 +0000148 string representation on success, {\NULL} on failure. This is
Guido van Rossum267e80d1996-08-09 21:01:07 +0000149 the equivalent of the Python expression: \code{str(o)}.
150 Called by the \code{str()} built-in function and by the \code{print}
151 statement.
Guido van Rossum0011d931996-08-22 23:18:55 +0000152 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000153
154
Guido van Rossum0011d931996-08-22 23:18:55 +0000155 \begin{cfuncdesc}{int}{PyCallable_Check}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000156 Determine if the object \code{o}, is callable. Return 1 if the
157 object is callable and 0 otherwise.
158 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000159 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000160
161
Guido van Rossum0011d931996-08-22 23:18:55 +0000162 \begin{cfuncdesc}{PyObject*}{PyObject_CallObject}{PyObject *callable_object, PyObject *args}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000163 Call a callable Python object \code{callable_object}, with
164 arguments given by the tuple \code{args}. If no arguments are
Guido van Rossum0011d931996-08-22 23:18:55 +0000165 needed, then args may be {\NULL}. Returns the result of the
166 call on success, or {\NULL} on failure. This is the equivalent
167 of the Python expression: \code{apply(o, args)}.
168 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000169
Guido van Rossum0011d931996-08-22 23:18:55 +0000170 \begin{cfuncdesc}{PyObject*}{PyObject_CallFunction}{PyObject *callable_object, char *format, ...}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000171 Call a callable Python object \code{callable_object}, with a
172 variable number of C arguments. The C arguments are described
Guido van Rossum0011d931996-08-22 23:18:55 +0000173 using a mkvalue-style format string. The format may be {\NULL},
Guido van Rossum267e80d1996-08-09 21:01:07 +0000174 indicating that no arguments are provided. Returns the
Guido van Rossum0011d931996-08-22 23:18:55 +0000175 result of the call on success, or {\NULL} on failure. This is
Guido van Rossum267e80d1996-08-09 21:01:07 +0000176 the equivalent of the Python expression: \code{apply(o,args)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000177 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000178
179
Guido van Rossum0011d931996-08-22 23:18:55 +0000180 \begin{cfuncdesc}{PyObject*}{PyObject_CallMethod}{PyObject *o, char *m, char *format, ...}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000181 Call the method named \code{m} of object \code{o} with a variable number of
182 C arguments. The C arguments are described by a mkvalue
Guido van Rossum0011d931996-08-22 23:18:55 +0000183 format string. The format may be {\NULL}, indicating that no
Guido van Rossum267e80d1996-08-09 21:01:07 +0000184 arguments are provided. Returns the result of the call on
Guido van Rossum0011d931996-08-22 23:18:55 +0000185 success, or {\NULL} on failure. This is the equivalent of the
Guido van Rossum267e80d1996-08-09 21:01:07 +0000186 Python expression: \code{o.method(args)}.
187 Note that Special method names, such as "\code{__add__}",
188 "\code{__getitem__}", and so on are not supported. The specific
189 abstract-object routines for these must be used.
Guido van Rossum0011d931996-08-22 23:18:55 +0000190 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000191
192
Guido van Rossum0011d931996-08-22 23:18:55 +0000193 \begin{cfuncdesc}{int}{PyObject_Hash}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000194 Compute and return the hash value of an object \code{o}. On
195 failure, return -1. This is the equivalent of the Python
196 expression: \code{hash(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000197 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000198
199
Guido van Rossum0011d931996-08-22 23:18:55 +0000200 \begin{cfuncdesc}{int}{PyObject_IsTrue}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000201 Returns 1 if the object \code{o} is considered to be true, and
202 0 otherwise. This is equivalent to the Python expression:
203 \code{not not o}.
204 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000205 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000206
207
Guido van Rossum0011d931996-08-22 23:18:55 +0000208 \begin{cfuncdesc}{PyObject*}{PyObject_Type}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000209 On success, returns a type object corresponding to the object
Guido van Rossum0011d931996-08-22 23:18:55 +0000210 type of object \code{o}. On failure, returns {\NULL}. This is
Guido van Rossum267e80d1996-08-09 21:01:07 +0000211 equivalent to the Python expression: \code{type(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000212 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000213
Guido van Rossum0011d931996-08-22 23:18:55 +0000214 \begin{cfuncdesc}{int}{PyObject_Length}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000215 Return the length of object \code{o}. If the object \code{o} provides
216 both sequence and mapping protocols, the sequence length is
217 returned. On error, -1 is returned. This is the equivalent
218 to the Python expression: \code{len(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000219 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000220
221
Guido van Rossum0011d931996-08-22 23:18:55 +0000222 \begin{cfuncdesc}{PyObject*}{PyObject_GetItem}{PyObject *o, PyObject *key}
223 Return element of \code{o} corresponding to the object \code{key} or {\NULL}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000224 on failure. This is the equivalent of the Python expression:
225 \code{o[key]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000226 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000227
228
Guido van Rossum0011d931996-08-22 23:18:55 +0000229 \begin{cfuncdesc}{int}{PyObject_SetItem}{PyObject *o, PyObject *key, PyObject *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000230 Map the object \code{key} to the value \code{v}.
231 Returns -1 on failure. This is the equivalent
232 of the Python statement: \code{o[key]=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000233 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000234
235
Guido van Rossum0011d931996-08-22 23:18:55 +0000236 \begin{cfuncdesc}{int}{PyObject_DelItem}{PyObject *o, PyObject *key, PyObject *v}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000237 Delete the mapping for \code{key} from \code{*o}. Returns -1
238 on failure.
239 This is the equivalent of the Python statement: del o[key].
Guido van Rossum0011d931996-08-22 23:18:55 +0000240 \end{cfuncdesc}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000241
242
Guido van Rossum0011d931996-08-22 23:18:55 +0000243\section{Number Protocol}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000244
Guido van Rossum0011d931996-08-22 23:18:55 +0000245 \begin{cfuncdesc}{int}{PyNumber_Check}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000246 Returns 1 if the object \code{o} provides numeric protocols, and
247 false otherwise.
248 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000249 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000250
251
Guido van Rossum0011d931996-08-22 23:18:55 +0000252 \begin{cfuncdesc}{PyObject*}{PyNumber_Add}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000253 Returns the result of adding \code{o1} and \code{o2}, or null on failure.
254 This is the equivalent of the Python expression: \code{o1+o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000255 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000256
257
Guido van Rossum0011d931996-08-22 23:18:55 +0000258 \begin{cfuncdesc}{PyObject*}{PyNumber_Subtract}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000259 Returns the result of subtracting \code{o2} from \code{o1}, or null on
260 failure. This is the equivalent of the Python expression:
261 \code{o1-o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000262 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000263
264
Guido van Rossum0011d931996-08-22 23:18:55 +0000265 \begin{cfuncdesc}{PyObject*}{PyNumber_Multiply}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000266 Returns the result of multiplying \code{o1} and \code{o2}, or null on
267 failure. This is the equivalent of the Python expression:
268 \code{o1*o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000269 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000270
271
Guido van Rossum0011d931996-08-22 23:18:55 +0000272 \begin{cfuncdesc}{PyObject*}{PyNumber_Divide}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000273 Returns the result of dividing \code{o1} by \code{o2}, or null on failure.
274 This is the equivalent of the Python expression: \code{o1/o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000275 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000276
277
Guido van Rossum0011d931996-08-22 23:18:55 +0000278 \begin{cfuncdesc}{PyObject*}{PyNumber_Remainder}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000279 Returns the remainder of dividing \code{o1} by \code{o2}, or null on
280 failure. This is the equivalent of the Python expression:
281 \code{o1\%o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000282 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000283
284
Guido van Rossum0011d931996-08-22 23:18:55 +0000285 \begin{cfuncdesc}{PyObject*}{PyNumber_Divmod}{PyObject *o1, PyObject *o2}
286 See the built-in function divmod. Returns {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +0000287 This is the equivalent of the Python expression:
288 \code{divmod(o1,o2)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000289 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000290
291
Guido van Rossum0011d931996-08-22 23:18:55 +0000292 \begin{cfuncdesc}{PyObject*}{PyNumber_Power}{PyObject *o1, PyObject *o2, PyObject *o3}
293 See the built-in function pow. Returns {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +0000294 This is the equivalent of the Python expression:
295 \code{pow(o1,o2,o3)}, where \code{o3} is optional.
Guido van Rossum0011d931996-08-22 23:18:55 +0000296 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000297
298
Guido van Rossum0011d931996-08-22 23:18:55 +0000299 \begin{cfuncdesc}{PyObject*}{PyNumber_Negative}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000300 Returns the negation of \code{o} on success, or null on failure.
301 This is the equivalent of the Python expression: \code{-o}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000302 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000303
304
Guido van Rossum0011d931996-08-22 23:18:55 +0000305 \begin{cfuncdesc}{PyObject*}{PyNumber_Positive}{PyObject *o}
306 Returns \code{o} on success, or {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +0000307 This is the equivalent of the Python expression: \code{+o}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000308 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000309
310
Guido van Rossum0011d931996-08-22 23:18:55 +0000311 \begin{cfuncdesc}{PyObject*}{PyNumber_Absolute}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000312 Returns the absolute value of \code{o}, or null on failure. This is
313 the equivalent of the Python expression: \code{abs(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000314 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000315
316
Guido van Rossum0011d931996-08-22 23:18:55 +0000317 \begin{cfuncdesc}{PyObject*}{PyNumber_Invert}{PyObject *o}
318 Returns the bitwise negation of \code{o} on success, or {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000319 failure. This is the equivalent of the Python expression:
320 \code{~o}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000321 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000322
323
Guido van Rossum0011d931996-08-22 23:18:55 +0000324 \begin{cfuncdesc}{PyObject*}{PyNumber_Lshift}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000325 Returns the result of left shifting \code{o1} by \code{o2} on success, or
Guido van Rossum0011d931996-08-22 23:18:55 +0000326 {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000327 expression: \code{o1 << o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000328 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000329
330
Guido van Rossum0011d931996-08-22 23:18:55 +0000331 \begin{cfuncdesc}{PyObject*}{PyNumber_Rshift}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000332 Returns the result of right shifting \code{o1} by \code{o2} on success, or
Guido van Rossum0011d931996-08-22 23:18:55 +0000333 {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000334 expression: \code{o1 >> o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000335 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000336
337
Guido van Rossum0011d931996-08-22 23:18:55 +0000338 \begin{cfuncdesc}{PyObject*}{PyNumber_And}{PyObject *o1, PyObject *o2}
339 Returns the result of "anding" \code{o2} and \code{o2} on success and {\NULL}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000340 on failure. This is the equivalent of the Python
341 expression: \code{o1 and o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000342 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000343
344
Guido van Rossum0011d931996-08-22 23:18:55 +0000345 \begin{cfuncdesc}{PyObject*}{PyNumber_Xor}{PyObject *o1, PyObject *o2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000346 Returns the bitwise exclusive or of \code{o1} by \code{o2} on success, or
Guido van Rossum0011d931996-08-22 23:18:55 +0000347 {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000348 expression: \code{o1\^{ }o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000349 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000350
Guido van Rossum0011d931996-08-22 23:18:55 +0000351 \begin{cfuncdesc}{PyObject*}{PyNumber_Or}{PyObject *o1, PyObject *o2}
352 Returns the result or \code{o1} and \code{o2} on success, or {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000353 failure. This is the equivalent of the Python expression:
354 \code{o1 or o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000355 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000356
357
Guido van Rossum0011d931996-08-22 23:18:55 +0000358 \begin{cfuncdesc}{PyObject*}{PyNumber_Coerce}{PyObject *o1, PyObject *o2}
Guido van Rossumc05797d1996-09-10 17:36:17 +0000359 This function takes the addresses of two variables of type
360 \code{PyObject*}.
361
362 If the objects pointed to by \code{*p1} and \code{*p2} have the same type,
363 increment their reference count and return 0 (success).
364 If the objects can be converted to a common numeric type,
365 replace \code{*p1} and \code{*p2} by their converted value (with 'new'
366 reference counts), and return 0.
367 If no conversion is possible, or if some other error occurs,
368 return -1 (failure) and don't increment the reference counts.
369 The call \code{PyNumber_Coerce(&o1, &o2)} is equivalent to the Python
370 statement \code{o1, o2 = coerce(o1, o2)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000371 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000372
373
Guido van Rossum0011d931996-08-22 23:18:55 +0000374 \begin{cfuncdesc}{PyObject*}{PyNumber_Int}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000375 Returns the \code{o} converted to an integer object on success, or
Guido van Rossum0011d931996-08-22 23:18:55 +0000376 {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000377 expression: \code{int(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000378 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000379
380
Guido van Rossum0011d931996-08-22 23:18:55 +0000381 \begin{cfuncdesc}{PyObject*}{PyNumber_Long}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000382 Returns the \code{o} converted to a long integer object on success,
Guido van Rossum0011d931996-08-22 23:18:55 +0000383 or {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000384 expression: \code{long(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000385 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000386
387
Guido van Rossum0011d931996-08-22 23:18:55 +0000388 \begin{cfuncdesc}{PyObject*}{PyNumber_Float}{PyObject *o}
389 Returns the \code{o} converted to a float object on success, or {\NULL}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000390 on failure. This is the equivalent of the Python expression:
391 \code{float(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000392 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000393
394
Guido van Rossum0011d931996-08-22 23:18:55 +0000395\section{Sequence protocol}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000396
Guido van Rossum0011d931996-08-22 23:18:55 +0000397 \begin{cfuncdesc}{int}{PySequence_Check}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000398 Return 1 if the object provides sequence protocol, and 0
399 otherwise.
400 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000401 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000402
403
Guido van Rossum0011d931996-08-22 23:18:55 +0000404 \begin{cfuncdesc}{PyObject*}{PySequence_Concat}{PyObject *o1, PyObject *o2}
405 Return the concatination of \code{o1} and \code{o2} on success, and {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000406 failure. This is the equivalent of the Python
407 expression: \code{o1+o2}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000408 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000409
410
Guido van Rossum0011d931996-08-22 23:18:55 +0000411 \begin{cfuncdesc}{PyObject*}{PySequence_Repeat}{PyObject *o, int count}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000412 Return the result of repeating sequence object \code{o} count times,
Guido van Rossum0011d931996-08-22 23:18:55 +0000413 or {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000414 expression: \code{o*count}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000415 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000416
417
Guido van Rossum0011d931996-08-22 23:18:55 +0000418 \begin{cfuncdesc}{PyObject*}{PySequence_GetItem}{PyObject *o, int i}
419 Return the ith element of \code{o}, or {\NULL} on failure. This is the
Guido van Rossum267e80d1996-08-09 21:01:07 +0000420 equivalent of the Python expression: \code{o[i]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000421 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000422
423
Guido van Rossum0011d931996-08-22 23:18:55 +0000424 \begin{cfuncdesc}{PyObject*}{PySequence_GetSlice}{PyObject *o, int i1, int i2}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000425 Return the slice of sequence object \code{o} between \code{i1} and \code{i2}, or
Guido van Rossum0011d931996-08-22 23:18:55 +0000426 {\NULL} on failure. This is the equivalent of the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000427 expression, \code{o[i1:i2]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000428 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000429
430
Guido van Rossum0011d931996-08-22 23:18:55 +0000431 \begin{cfuncdesc}{int}{PySequence_SetItem}{PyObject *o, int i, PyObject *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000432 Assign object \code{v} to the \code{i}th element of \code{o}.
433Returns -1 on failure. This is the equivalent of the Python
434 statement, \code{o[i]=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000435 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000436
Guido van Rossum0011d931996-08-22 23:18:55 +0000437 \begin{cfuncdesc}{int}{PySequence_DelItem}{PyObject *o, int i}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000438 Delete the \code{i}th element of object \code{v}. Returns
439 -1 on failure. This is the equivalent of the Python
440 statement: \code{del o[i]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000441 \end{cfuncdesc}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000442
Guido van Rossum0011d931996-08-22 23:18:55 +0000443 \begin{cfuncdesc}{int}{PySequence_SetSlice}{PyObject *o, int i1, int i2, PyObject *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000444 Assign the sequence object \code{v} to the slice in sequence
445 object \code{o} from \code{i1} to \code{i2}. This is the equivalent of the Python
446 statement, \code{o[i1:i2]=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000447 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000448
Guido van Rossum0011d931996-08-22 23:18:55 +0000449 \begin{cfuncdesc}{int}{PySequence_DelSlice}{PyObject *o, int i1, int i2}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000450 Delete the slice in sequence object, \code{o}, from \code{i1} to \code{i2}.
451 Returns -1 on failure. This is the equivalent of the Python
452 statement: \code{del o[i1:i2]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000453 \end{cfuncdesc}
Guido van Rossumd0f11de1996-08-21 19:08:12 +0000454
Guido van Rossum0011d931996-08-22 23:18:55 +0000455 \begin{cfuncdesc}{PyObject*}{PySequence_Tuple}{PyObject *o}
456 Returns the \code{o} as a tuple on success, and {\NULL} on failure.
Guido van Rossum267e80d1996-08-09 21:01:07 +0000457 This is equivalent to the Python expression: \code{tuple(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000458 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000459
Guido van Rossum0011d931996-08-22 23:18:55 +0000460 \begin{cfuncdesc}{int}{PySequence_Count}{PyObject *o, PyObject *value}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000461 Return the number of occurrences of \code{value} on \code{o}, that is,
462 return the number of keys for which \code{o[key]==value}. On
463 failure, return -1. This is equivalent to the Python
464 expression: \code{o.count(value)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000465 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000466
Guido van Rossum0011d931996-08-22 23:18:55 +0000467 \begin{cfuncdesc}{int}{PySequence_In}{PyObject *o, PyObject *value}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000468 Determine if \code{o} contains \code{value}. If an item in \code{o} is equal to
469 \code{value}, return 1, otherwise return 0. On error, return -1. This
470 is equivalent to the Python expression: \code{value in o}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000471 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000472
Guido van Rossum0011d931996-08-22 23:18:55 +0000473 \begin{cfuncdesc}{int}{PySequence_Index}{PyObject *o, PyObject *value}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000474 Return the first index for which \code{o[i]=value}. On error,
475 return -1. This is equivalent to the Python
476 expression: \code{o.index(value)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000477 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000478
Guido van Rossum0011d931996-08-22 23:18:55 +0000479\section{Mapping protocol}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000480
Guido van Rossum0011d931996-08-22 23:18:55 +0000481 \begin{cfuncdesc}{int}{PyMapping_Check}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000482 Return 1 if the object provides mapping protocol, and 0
483 otherwise.
484 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000485 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000486
487
Guido van Rossum0011d931996-08-22 23:18:55 +0000488 \begin{cfuncdesc}{int}{PyMapping_Length}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000489 Returns the number of keys in object \code{o} on success, and -1 on
490 failure. For objects that do not provide sequence protocol,
491 this is equivalent to the Python expression: \code{len(o)}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000492 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000493
494
Guido van Rossum0011d931996-08-22 23:18:55 +0000495 \begin{cfuncdesc}{int}{PyMapping_DelItemString}{PyObject *o, char *key}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000496 Remove the mapping for object \code{key} from the object \code{o}.
497 Return -1 on failure. This is equivalent to
498 the Python statement: \code{del o[key]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000499 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000500
501
Guido van Rossum0011d931996-08-22 23:18:55 +0000502 \begin{cfuncdesc}{int}{PyMapping_DelItem}{PyObject *o, PyObject *key}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000503 Remove the mapping for object \code{key} from the object \code{o}.
504 Return -1 on failure. This is equivalent to
505 the Python statement: \code{del o[key]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000506 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000507
508
Guido van Rossum0011d931996-08-22 23:18:55 +0000509 \begin{cfuncdesc}{int}{PyMapping_HasKeyString}{PyObject *o, char *key}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000510 On success, return 1 if the mapping object has the key \code{key}
511 and 0 otherwise. This is equivalent to the Python expression:
512 \code{o.has_key(key)}.
513 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000514 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000515
516
Guido van Rossum0011d931996-08-22 23:18:55 +0000517 \begin{cfuncdesc}{int}{PyMapping_HasKey}{PyObject *o, PyObject *key}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000518 Return 1 if the mapping object has the key \code{key}
519 and 0 otherwise. This is equivalent to the Python expression:
520 \code{o.has_key(key)}.
521 This function always succeeds.
Guido van Rossum0011d931996-08-22 23:18:55 +0000522 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000523
524
Guido van Rossum0011d931996-08-22 23:18:55 +0000525 \begin{cfuncdesc}{PyObject*}{PyMapping_Keys}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000526 On success, return a list of the keys in object \code{o}. On
Guido van Rossum0011d931996-08-22 23:18:55 +0000527 failure, return {\NULL}. This is equivalent to the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000528 expression: \code{o.keys()}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000529 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000530
531
Guido van Rossum0011d931996-08-22 23:18:55 +0000532 \begin{cfuncdesc}{PyObject*}{PyMapping_Values}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000533 On success, return a list of the values in object \code{o}. On
Guido van Rossum0011d931996-08-22 23:18:55 +0000534 failure, return {\NULL}. This is equivalent to the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000535 expression: \code{o.values()}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000536 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000537
538
Guido van Rossum0011d931996-08-22 23:18:55 +0000539 \begin{cfuncdesc}{PyObject*}{PyMapping_Items}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000540 On success, return a list of the items in object \code{o}, where
541 each item is a tuple containing a key-value pair. On
Guido van Rossum0011d931996-08-22 23:18:55 +0000542 failure, return {\NULL}. This is equivalent to the Python
Guido van Rossum267e80d1996-08-09 21:01:07 +0000543 expression: \code{o.items()}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000544 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000545
Guido van Rossum0011d931996-08-22 23:18:55 +0000546 \begin{cfuncdesc}{int}{PyMapping_Clear}{PyObject *o}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000547 Make object \code{o} empty. Returns 1 on success and 0 on failure.
548 This is equivalent to the Python statement:
549 \code{for key in o.keys(): del o[key]}
Guido van Rossum0011d931996-08-22 23:18:55 +0000550 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000551
552
Guido van Rossum0011d931996-08-22 23:18:55 +0000553 \begin{cfuncdesc}{PyObject*}{PyMapping_GetItemString}{PyObject *o, char *key}
554 Return element of \code{o} corresponding to the object \code{key} or {\NULL}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000555 on failure. This is the equivalent of the Python expression:
556 \code{o[key]}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000557 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000558
Guido van Rossum0011d931996-08-22 23:18:55 +0000559 \begin{cfuncdesc}{PyObject*}{PyMapping_SetItemString}{PyObject *o, char *key, PyObject *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000560 Map the object \code{key} to the value \code{v} in object \code{o}. Returns
561 -1 on failure. This is the equivalent of the Python
562 statement: \code{o[key]=v}.
Guido van Rossum0011d931996-08-22 23:18:55 +0000563 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000564
565
Guido van Rossum0011d931996-08-22 23:18:55 +0000566\section{Constructors}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000567
Guido van Rossum0011d931996-08-22 23:18:55 +0000568 \begin{cfuncdesc}{PyObject*}{PyFile_FromString}{char *file_name, char *mode}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000569 On success, returns a new file object that is opened on the
570 file given by \code{file_name}, with a file mode given by \code{mode},
571 where \code{mode} has the same semantics as the standard C routine,
572 fopen. On failure, return -1.
Guido van Rossum0011d931996-08-22 23:18:55 +0000573 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000574
Guido van Rossum0011d931996-08-22 23:18:55 +0000575 \begin{cfuncdesc}{PyObject*}{PyFile_FromFile}{FILE *fp, char *file_name, char *mode, int close_on_del}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000576 Return a new file object for an already opened standard C
577 file pointer, \code{fp}. A file name, \code{file_name}, and open mode,
578 \code{mode}, must be provided as well as a flag, \code{close_on_del}, that
579 indicates whether the file is to be closed when the file
580 object is destroyed. On failure, return -1.
Guido van Rossum0011d931996-08-22 23:18:55 +0000581 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000582
Guido van Rossum0011d931996-08-22 23:18:55 +0000583 \begin{cfuncdesc}{PyObject*}{PyFloat_FromDouble}{double v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000584 Returns a new float object with the value \code{v} on success, and
Guido van Rossum0011d931996-08-22 23:18:55 +0000585 {\NULL} on failure.
586 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000587
Guido van Rossum0011d931996-08-22 23:18:55 +0000588 \begin{cfuncdesc}{PyObject*}{PyInt_FromLong}{long v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000589 Returns a new int object with the value \code{v} on success, and
Guido van Rossum0011d931996-08-22 23:18:55 +0000590 {\NULL} on failure.
591 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000592
Guido van Rossum0011d931996-08-22 23:18:55 +0000593 \begin{cfuncdesc}{PyObject*}{PyList_New}{int l}
594 Returns a new list of length \code{l} on success, and {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000595 failure.
Guido van Rossum0011d931996-08-22 23:18:55 +0000596 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000597
Guido van Rossum0011d931996-08-22 23:18:55 +0000598 \begin{cfuncdesc}{PyObject*}{PyLong_FromLong}{long v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000599 Returns a new long object with the value \code{v} on success, and
Guido van Rossum0011d931996-08-22 23:18:55 +0000600 {\NULL} on failure.
601 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000602
Guido van Rossum0011d931996-08-22 23:18:55 +0000603 \begin{cfuncdesc}{PyObject*}{PyLong_FromDouble}{double v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000604 Returns a new long object with the value \code{v} on success, and
Guido van Rossum0011d931996-08-22 23:18:55 +0000605 {\NULL} on failure.
606 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000607
Guido van Rossum0011d931996-08-22 23:18:55 +0000608 \begin{cfuncdesc}{PyObject*}{PyDict_New}{}
609 Returns a new empty dictionary on success, and {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000610 failure.
Guido van Rossum0011d931996-08-22 23:18:55 +0000611 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000612
Guido van Rossum0011d931996-08-22 23:18:55 +0000613 \begin{cfuncdesc}{PyObject*}{PyString_FromString}{char *v}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000614 Returns a new string object with the value \code{v} on success, and
Guido van Rossum0011d931996-08-22 23:18:55 +0000615 {\NULL} on failure.
616 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000617
Guido van Rossum0011d931996-08-22 23:18:55 +0000618 \begin{cfuncdesc}{PyObject*}{PyString_FromStringAndSize}{char *v, int l}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000619 Returns a new string object with the value \code{v} and length \code{l}
Guido van Rossum0011d931996-08-22 23:18:55 +0000620 on success, and {\NULL} on failure.
621 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000622
Guido van Rossum0011d931996-08-22 23:18:55 +0000623 \begin{cfuncdesc}{PyObject*}{PyTuple_New}{int l}
624 Returns a new tuple of length \code{l} on success, and {\NULL} on
Guido van Rossum267e80d1996-08-09 21:01:07 +0000625 failure.
Guido van Rossum0011d931996-08-22 23:18:55 +0000626 \end{cfuncdesc}
Guido van Rossum267e80d1996-08-09 21:01:07 +0000627