annotate Include/abstract.h @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents cd8d3c2d3bce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #ifndef Py_ABSTRACTOBJECT_H
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 #define Py_ABSTRACTOBJECT_H
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 #ifdef __cplusplus
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 extern "C" {
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #endif
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
37702
9b22d8b7bcaa Make Py_BuildValue, PyObject_CallFunction and
Martin v. Löwis <martin@v.loewis.de>
parents: 36882
diff changeset
7 #ifdef PY_SSIZE_T_CLEAN
9b22d8b7bcaa Make Py_BuildValue, PyObject_CallFunction and
Martin v. Löwis <martin@v.loewis.de>
parents: 36882
diff changeset
8 #define PyObject_CallFunction _PyObject_CallFunction_SizeT
9b22d8b7bcaa Make Py_BuildValue, PyObject_CallFunction and
Martin v. Löwis <martin@v.loewis.de>
parents: 36882
diff changeset
9 #define PyObject_CallMethod _PyObject_CallMethod_SizeT
9b22d8b7bcaa Make Py_BuildValue, PyObject_CallFunction and
Martin v. Löwis <martin@v.loewis.de>
parents: 36882
diff changeset
10 #endif
9b22d8b7bcaa Make Py_BuildValue, PyObject_CallFunction and
Martin v. Löwis <martin@v.loewis.de>
parents: 36882
diff changeset
11
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 /* Abstract Object Interface (many thanks to Jim Fulton) */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 /*
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 PROPOSAL: A Generic Python Object Interface for Python C Modules
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 Problem
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 Python modules written in C that must access Python objects must do
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 so through routines whose interfaces are described by a set of
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 include files. Unfortunately, these routines vary according to the
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 object accessed. To use these routines, the C programmer must check
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 the type of the object being used and must call a routine based on
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 the object type. For example, to access an element of a sequence,
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 the programmer must determine whether the sequence is a list or a
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 tuple:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 if(is_tupleobject(o))
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 e=gettupleitem(o,i)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 else if(is_listitem(o))
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 e=getlistitem(o,i)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 If the programmer wants to get an item from another type of object
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 that provides sequence behavior, there is no clear way to do it
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
35 correctly.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 The persistent programmer may peruse object.h and find that the
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 _typeobject structure provides a means of invoking up to (currently
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 about) 41 special operators. So, for example, a routine can get an
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 item from any object that provides sequence behavior. However, to
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 use this mechanism, the programmer must make their code dependent on
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 the current Python implementation.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 Also, certain semantics, especially memory management semantics, may
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 differ by the type of object being used. Unfortunately, these
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 semantics are not clearly described in the current include files.
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
47 An abstract interface providing more consistent semantics is needed.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 Proposal
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 I propose the creation of a standard interface (with an associated
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 library of routines and/or macros) for generically obtaining the
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 services of Python objects. This proposal can be viewed as one
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 components of a Python C interface consisting of several components.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
28102
f4e72a1a9f13 Fix spelling and grammar.
Raymond Hettinger <python@rcn.com>
parents: 26400
diff changeset
56 From the viewpoint of C access to Python services, we have (as
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 suggested by Guido in off-line discussions):
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 - "Very high level layer": two or three functions that let you exec or
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 eval arbitrary Python code given as a string in a module whose name is
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 given, passing C values in and getting C values out using
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 mkvalue/getargs style format strings. This does not require the user
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 to declare any variables of type "PyObject *". This should be enough
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 to write a simple application that gets Python code from the user,
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 execs it, and returns the output or errors. (Error handling must also
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 be part of this API.)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
67
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 - "Abstract objects layer": which is the subject of this proposal.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 It has many functions operating on objects, and lest you do many
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 things from C that you can also write in Python, without going
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 through the Python parser.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 - "Concrete objects layer": This is the public type-dependent
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 interface provided by the standard built-in types, such as floats,
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 strings, and lists. This interface exists and is currently
28102
f4e72a1a9f13 Fix spelling and grammar.
Raymond Hettinger <python@rcn.com>
parents: 26400
diff changeset
76 documented by the collection of include files provided with the
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 Python distributions.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
78
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 From the point of view of Python accessing services provided by C
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
80 modules:
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
81
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 - "Python module interface": this interface consist of the basic
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 routines used to define modules and their members. Most of the
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 current extensions-writing guide deals with this interface.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 - "Built-in object interface": this is the interface that a new
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 built-in type must provide and the mechanisms and rules that a
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 developer of a new built-in type must use and follow.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 This proposal is a "first-cut" that is intended to spur
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 discussion. See especially the lists of notes.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 The Python C object interface will provide four protocols: object,
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 numeric, sequence, and mapping. Each protocol consists of a
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 collection of related operations. If an operation that is not
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 provided by a particular type is invoked, then a standard exception,
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 NotImplementedError is raised with a operation name as an argument.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 In addition, for convenience this interface defines a set of
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 constructors for building objects of built-in types. This is needed
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 so new objects can be returned from C functions that otherwise treat
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 objects generically.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 Memory Management
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 For all of the functions described in this proposal, if a function
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 retains a reference to a Python object passed as an argument, then the
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 function will increase the reference count of the object. It is
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 unnecessary for the caller to increase the reference count of an
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 argument in anticipation of the object's retention.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
110
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 All Python objects returned from functions should be treated as new
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 objects. Functions that return objects assume that the caller will
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 retain a reference and the reference count of the object has already
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 been incremented to account for this fact. A caller that does not
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 retain a reference to an object that is returned from a function
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 must decrement the reference count of the object (using
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 DECREF(object)) to prevent memory leaks.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
118
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 Note that the behavior mentioned here is different from the current
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 behavior for some objects (e.g. lists and tuples) when certain
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 type-specific routines are called directly (e.g. setlistitem). The
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 proposed abstraction layer will provide a consistent memory
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 management interface, correcting for inconsistent behavior for some
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 built-in types.
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
125
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 Protocols
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
127
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
129
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 /* Object Protocol: */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
131
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 int PyObject_Print(PyObject *o, FILE *fp, int flags);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
135
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
136 Print an object, o, on file, fp. Returns -1 on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
137 error. The flags argument is used to enable certain printing
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
138 options. The only option currently supported is Py_Print_RAW.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
140 (What should be said about Py_Print_RAW?)
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
143
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
145
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 int PyObject_HasAttrString(PyObject *o, char *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
147
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
148 Returns 1 if o has the attribute attr_name, and 0 otherwise.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
149 This is equivalent to the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
150 hasattr(o,attr_name).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
151
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
152 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
153
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
155
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
157
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
160 Retrieve an attributed named attr_name form object o.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
161 Returns the attribute value on success, or NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
162 This is the equivalent of the Python expression: o.attr_name.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
163
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
165
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
167
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
169
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
170 Returns 1 if o has the attribute attr_name, and 0 otherwise.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
171 This is equivalent to the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
172 hasattr(o,attr_name).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
173
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
174 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
175
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
177
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
178 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
179
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
182 Retrieve an attributed named attr_name form object o.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
183 Returns the attribute value on success, or NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
184 This is the equivalent of the Python expression: o.attr_name.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
185
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
187
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
188
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
189 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
190
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
191 int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
192
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
193 Set the value of the attribute named attr_name, for object o,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
194 to the value, v. Returns -1 on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
195 the equivalent of the Python statement: o.attr_name=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
196
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
197 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
198
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
199 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
200
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
202
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
203 Set the value of the attribute named attr_name, for object o,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
204 to the value, v. Returns -1 on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
205 the equivalent of the Python statement: o.attr_name=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
206
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
208
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 /* implemented as a macro:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
210
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 int PyObject_DelAttrString(PyObject *o, char *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
212
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
213 Delete attribute named attr_name, for object o. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
214 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
215 statement: del o.attr_name.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
216
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 #define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
219
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
220 /* implemented as a macro:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
221
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
222 int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
223
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
224 Delete attribute named attr_name, for object o. Returns -1
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
225 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
226 statement: del o.attr_name.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
227
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
228 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
229 #define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
230
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
231 PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
232
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
233 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
234 Compare the values of o1 and o2 using a routine provided by
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
235 o1, if one exists, otherwise with a routine provided by o2.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
236 The result of the comparison is returned in result. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
237 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
238 statement: result=cmp(o1,o2).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
239
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
240 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
241
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
242 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
243
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
244 int PyObject_Compare(PyObject *o1, PyObject *o2);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
245
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
246 Compare the values of o1 and o2 using a routine provided by
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
247 o1, if one exists, otherwise with a routine provided by o2.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
248 Returns the result of the comparison on success. On error,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
249 the value returned is undefined. This is equivalent to the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
250 Python expression: cmp(o1,o2).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
251
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
252 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
253
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
254 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
255
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
256 PyObject *PyObject_Repr(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
257
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
258 Compute the string representation of object, o. Returns the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
259 string representation on success, NULL on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
260 the equivalent of the Python expression: repr(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
261
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
262 Called by the repr() built-in function and by reverse quotes.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
263
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
264 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
265
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
266 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
267
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
268 PyObject *PyObject_Str(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
269
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
270 Compute the string representation of object, o. Returns the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
271 string representation on success, NULL on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
272 the equivalent of the Python expression: str(o).)
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
273
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
274 Called by the str() built-in function and by the print
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
275 statement.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
276
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
277 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
278
15952
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
279 /* Implemented elsewhere:
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
280
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
281 PyObject *PyObject_Unicode(PyObject *o);
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
282
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
283 Compute the unicode representation of object, o. Returns the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
284 unicode representation on success, NULL on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
285 the equivalent of the Python expression: unistr(o).)
15952
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
286
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
287 Called by the unistr() built-in function.
15952
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
288
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
289 */
1f92d63b20f0 This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents: 14162
diff changeset
290
40160
384ef87fcc25 Patch #1580872: Remove duplicate declaration of PyCallable_Check.
Martin v. Löwis <martin@v.loewis.de>
parents: 39463
diff changeset
291 /* Declared elsewhere
384ef87fcc25 Patch #1580872: Remove duplicate declaration of PyCallable_Check.
Martin v. Löwis <martin@v.loewis.de>
parents: 39463
diff changeset
292
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
293 PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
294
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
295 Determine if the object, o, is callable. Return 1 if the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
296 object is callable and 0 otherwise.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
297
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
298 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
299
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
300 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
301
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
302
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17692
diff changeset
303
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
304 PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
305 PyObject *args, PyObject *kw);
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17692
diff changeset
306
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17692
diff changeset
307 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
308 Call a callable Python object, callable_object, with
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
309 arguments and keywords arguments. The 'args' argument can not be
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
310 NULL, but the 'kw' argument can be NULL.
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17692
diff changeset
311
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents: 17692
diff changeset
312 */
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
313
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
314 PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
315 PyObject *args);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
316
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
317 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
318 Call a callable Python object, callable_object, with
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
319 arguments given by the tuple, args. If no arguments are
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
320 needed, then args may be NULL. Returns the result of the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
321 call on success, or NULL on failure. This is the equivalent
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
322 of the Python expression: apply(o,args).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
323
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
324 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
325
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
326 PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
327 char *format, ...);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
328
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
329 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
330 Call a callable Python object, callable_object, with a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
331 variable number of C arguments. The C arguments are described
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
332 using a mkvalue-style format string. The format may be NULL,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
333 indicating that no arguments are provided. Returns the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
334 result of the call on success, or NULL on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
335 the equivalent of the Python expression: apply(o,args).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
336
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
337 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
338
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
339
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
340 PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
341 char *format, ...);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
342
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
343 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
344 Call the method named m of object o with a variable number of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
345 C arguments. The C arguments are described by a mkvalue
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
346 format string. The format may be NULL, indicating that no
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
347 arguments are provided. Returns the result of the call on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
348 success, or NULL on failure. This is the equivalent of the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
349 Python expression: o.method(args).
20694
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
350 */
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
351
37813
85695de6049e C++ compilation cleanup: Migrate declaration of
Skip Montanaro <skip@pobox.com>
parents: 37702
diff changeset
352 PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
353 char *format, ...);
37813
85695de6049e C++ compilation cleanup: Migrate declaration of
Skip Montanaro <skip@pobox.com>
parents: 37702
diff changeset
354 PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
355 char *name,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
356 char *format, ...);
20694
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
357
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
358 PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
20729
cd600039a123 PyObject_CallFunctionObArgs() ---> PyObject_CallFunctionObjArgs()
Fred Drake <fdrake@acm.org>
parents: 20694
diff changeset
359 ...);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
360
20694
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
361 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
362 Call a callable Python object, callable_object, with a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
363 variable number of C arguments. The C arguments are provided
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
364 as PyObject * values, terminated by a NULL. Returns the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
365 result of the call on success, or NULL on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
366 the equivalent of the Python expression: apply(o,args).
20694
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
367 */
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
368
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
369
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
370 PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o,
20729
cd600039a123 PyObject_CallFunctionObArgs() ---> PyObject_CallFunctionObjArgs()
Fred Drake <fdrake@acm.org>
parents: 20694
diff changeset
371 PyObject *m, ...);
20694
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
372
d02068d163cf Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents: 20683
diff changeset
373 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
374 Call the method named m of object o with a variable number of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
375 C arguments. The C arguments are provided as PyObject *
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
376 values, terminated by NULL. Returns the result of the call
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
377 on success, or NULL on failure. This is the equivalent of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
378 the Python expression: o.method(args).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
379 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
380
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
381
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
382 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
383
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
384 long PyObject_Hash(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
385
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
386 Compute and return the hash, hash_value, of an object, o. On
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
387 failure, return -1. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
388 expression: hash(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
389
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
390 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
391
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
392
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
393 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
394
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
395 int PyObject_IsTrue(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
396
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
397 Returns 1 if the object, o, is considered to be true, 0 if o is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
398 considered to be false and -1 on failure. This is equivalent to the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
399 Python expression: not not o
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
400
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
401 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
402
7935
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
403 /* Implemented elsewhere:
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
404
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
405 int PyObject_Not(PyObject *o);
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
406
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
407 Returns 0 if the object, o, is considered to be true, 1 if o is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
408 considered to be false and -1 on failure. This is equivalent to the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
409 Python expression: not o
7935
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
410
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
411 */
aa7d69d67c81 Add PyObject_Not().
Guido van Rossum <guido@python.org>
parents: 5167
diff changeset
412
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
413 PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
414
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
415 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
416 On success, returns a type object corresponding to the object
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
417 type of object o. On failure, returns NULL. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
418 equivalent to the Python expression: type(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
419 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
420
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
421 PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
13575
7c119f050290 change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13444
diff changeset
422
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
424 Return the size of object o. If the object, o, provides
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
425 both sequence and mapping protocols, the sequence size is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
426 returned. On error, -1 is returned. This is the equivalent
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
427 to the Python expression: len(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
428
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
429 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
430
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
431 /* For DLL compatibility */
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
432 #undef PyObject_Length
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
433 PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
434 #define PyObject_Length PyObject_Size
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
435
44193
44c090c74202 Fix Issue 1045.
Raymond Hettinger <python@rcn.com>
parents: 42333
diff changeset
436 PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
35636
e22334b1da67 Convert iterator __len__() methods to a private API.
Raymond Hettinger <python@rcn.com>
parents: 31650
diff changeset
437
e22334b1da67 Convert iterator __len__() methods to a private API.
Raymond Hettinger <python@rcn.com>
parents: 31650
diff changeset
438 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
439 Guess the size of object o using len(o) or o.__length_hint__().
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
440 If neither of those return a non-negative value, then return the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
441 default value. If one of the calls fails, this function returns -1.
35636
e22334b1da67 Convert iterator __len__() methods to a private API.
Raymond Hettinger <python@rcn.com>
parents: 31650
diff changeset
442 */
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
443
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
444 PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
445
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
446 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
447 Return element of o corresponding to the object, key, or NULL
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
448 on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
449 o[key].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
450
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
451 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
452
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
453 PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
454
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
455 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
456 Map the object, key, to the value, v. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
457 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
458 statement: o[key]=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
459 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
460
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
461 PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key);
21644
3c0bd2f37a78 Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents: 21069
diff changeset
462
3c0bd2f37a78 Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents: 21069
diff changeset
463 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
464 Remove the mapping for object, key, from the object *o.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
465 Returns -1 on failure. This is equivalent to
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
466 the Python statement: del o[key].
21644
3c0bd2f37a78 Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents: 21069
diff changeset
467 */
3c0bd2f37a78 Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents: 21069
diff changeset
468
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
469 PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
470
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
471 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
472 Delete the mapping for key from *o. Returns -1 on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
473 This is the equivalent of the Python statement: del o[key].
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
474 */
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
475
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
476 PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
477 const char **buffer,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
478 Py_ssize_t *buffer_len);
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
479
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
480 /*
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
481 Takes an arbitrary object which must support the (character,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
482 single segment) buffer interface and returns a pointer to a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
483 read-only memory location useable as character based input
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
484 for subsequent processing.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
485
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
486 0 is returned on success. buffer and buffer_len are only
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
487 set in case no error occurs. Otherwise, -1 is returned and
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
488 an exception set.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
489
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
490 */
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
491
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
492 PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
20946
ef12c9ddefa7 Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20729
diff changeset
493
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
494 /*
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
495 Checks whether an arbitrary object supports the (character,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
496 single segment) buffer interface. Returns 1 on success, 0
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
497 on failure.
20946
ef12c9ddefa7 Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20729
diff changeset
498
ef12c9ddefa7 Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20729
diff changeset
499 */
ef12c9ddefa7 Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20729
diff changeset
500
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
501 PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
502 const void **buffer,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
503 Py_ssize_t *buffer_len);
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
504
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
505 /*
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
506 Same as PyObject_AsCharBuffer() except that this API expects
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
507 (readable, single segment) buffer interface and returns a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
508 pointer to a read-only memory location which can contain
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
509 arbitrary data.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
510
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
511 0 is returned on success. buffer and buffer_len are only
68588
cd8d3c2d3bce #11565: Fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 68256
diff changeset
512 set in case no error occurs. Otherwise, -1 is returned and
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
513 an exception set.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
514
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
515 */
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
516
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
517 PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
518 void **buffer,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
519 Py_ssize_t *buffer_len);
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
520
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
521 /*
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
522 Takes an arbitrary object which must support the (writeable,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
523 single segment) buffer interface and returns a pointer to a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
524 writeable memory location in buffer of size buffer_len.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
525
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
526 0 is returned on success. buffer and buffer_len are only
68588
cd8d3c2d3bce #11565: Fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 68256
diff changeset
527 set in case no error occurs. Otherwise, -1 is returned and
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
528 an exception set.
11965
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
529
9f261e94b2b2 Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents: 10412
diff changeset
530 */
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
531
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
532 /* new buffer API */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
533
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
534 #define PyObject_CheckBuffer(obj) \
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
535 (((obj)->ob_type->tp_as_buffer != NULL) && \
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
536 (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
537 ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
538
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
539 /* Return 1 if the getbuffer function is available, otherwise
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
540 return 0 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
541
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
542 PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
543 int flags);
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
544
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
545 /* This is a C-API version of the getbuffer function call. It checks
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
546 to make sure object has the required function pointer and issues the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
547 call. Returns -1 and raises an error on failure and returns 0 on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
548 success
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
549 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
550
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
551
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
552 PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
553
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
554 /* Get the memory area pointed to by the indices for the buffer given.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
555 Note that view->ndim is the assumed size of indices
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
556 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
557
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
558 PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *);
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
559
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
560 /* Return the implied itemsize of the data-format area from a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
561 struct-style description */
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
562
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
563
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
564
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
565 PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
566 Py_ssize_t len, char fort);
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
567
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
568 PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
569 Py_ssize_t len, char fort);
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
570
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
571
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
572 /* Copy len bytes of data from the contiguous chunk of memory
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
573 pointed to by buf into the buffer exported by obj. Return
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
574 0 on success and return -1 and raise a PyBuffer_Error on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
575 error (i.e. the object does not have a buffer interface or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
576 it is not working).
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
577
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
578 If fort is 'F' and the object is multi-dimensional,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
579 then the data will be copied into the array in
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
580 Fortran-style (first dimension varies the fastest). If
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
581 fort is 'C', then the data will be copied into the array
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
582 in C-style (last dimension varies the fastest). If fort
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
583 is 'A', then it does not matter and the copy will be made
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
584 in whatever way is more efficient.
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
585
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
586 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
587
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
588 PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
589
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
590 /* Copy the data from the src buffer to the buffer of destination
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
591 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
592
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
593 PyAPI_FUNC(int) PyBuffer_IsContiguous(Py_buffer *view, char fort);
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
594
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
595
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
596 PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
597 Py_ssize_t *shape,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
598 Py_ssize_t *strides,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
599 int itemsize,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
600 char fort);
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
601
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
602 /* Fill the strides array with byte-strides of a contiguous
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
603 (Fortran-style if fort is 'F' or C-style otherwise)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
604 array of the given shape with the given number of bytes
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
605 per element.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
606 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
607
48221
b8c4bf393794 Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents: 45832
diff changeset
608 PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
609 Py_ssize_t len, int readonly,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
610 int flags);
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
611
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
612 /* Fills in a buffer-info structure correctly for an exporter
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
613 that can only share a contiguous chunk of memory of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
614 "unsigned bytes" of the given length. Returns 0 on success
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
615 and -1 (with raising an error) on error.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
616 */
45793
f11c00246fb5 Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents: 45381
diff changeset
617
48221
b8c4bf393794 Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents: 45832
diff changeset
618 PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
b8c4bf393794 Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents: 45832
diff changeset
619
b8c4bf393794 Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents: 45832
diff changeset
620 /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*.
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
621 */
48221
b8c4bf393794 Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents: 45832
diff changeset
622
45381
b7231bf6bfb7 Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents: 45267
diff changeset
623 PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
624 PyObject *format_spec);
45381
b7231bf6bfb7 Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents: 45267
diff changeset
625 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
626 Takes an arbitrary object and returns the result of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
627 calling obj.__format__(format_spec).
45381
b7231bf6bfb7 Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents: 45267
diff changeset
628 */
b7231bf6bfb7 Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents: 45267
diff changeset
629
17617
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
630 /* Iterators */
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
631
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
632 PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
17597
32e7d0898eab Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents: 17111
diff changeset
633 /* Takes an object and returns an iterator for it.
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
634 This is typically a new iterator but if the argument
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
635 is an iterator, this returns itself. */
17597
32e7d0898eab Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents: 17111
diff changeset
636
17617
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
637 #define PyIter_Check(obj) \
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
638 (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \
50754
e9748db47635 #3720: Interpreter crashes when an evil iterator removes its own next function.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 48876
diff changeset
639 (obj)->ob_type->tp_iternext != NULL && \
e9748db47635 #3720: Interpreter crashes when an evil iterator removes its own next function.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 48876
diff changeset
640 (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
17617
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
641
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
642 PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
17617
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
643 /* Takes an iterator object and calls its tp_iternext slot,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
644 returning the next value. If the iterator is exhausted,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
645 this returns NULL without setting an exception.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
646 NULL with an exception means an error occurred. */
17617
aac65f50df6f Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents: 17597
diff changeset
647
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
648 /* Number Protocol:*/
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
649
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
650 PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
651
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
652 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
653 Returns 1 if the object, o, provides numeric protocols, and
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
654 false otherwise.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
655
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
656 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
657
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
658 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
659
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
660 PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
661
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
662 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
663 Returns the result of adding o1 and o2, or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
664 This is the equivalent of the Python expression: o1+o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
665
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
666
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
667 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
668
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
669 PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
670
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
671 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
672 Returns the result of subtracting o2 from o1, or null on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
673 failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
674 o1-o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
675
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
676 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
677
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
678 PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
679
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
680 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
681 Returns the result of multiplying o1 and o2, or null on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
682 failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
683 o1*o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
684
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
685
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
686 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
687
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
688 PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
689
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
690 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
691 Returns the result of dividing o1 by o2, or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
692 This is the equivalent of the Python expression: o1/o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
693
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
694
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
695 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
696
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
697 PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
698
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
699 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
700 Returns the result of dividing o1 by o2 giving an integral result,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
701 or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
702 This is the equivalent of the Python expression: o1//o2.
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
703
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
704
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
705 */
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
706
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
707 PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
708
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
709 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
710 Returns the result of dividing o1 by o2 giving a float result,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
711 or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
712 This is the equivalent of the Python expression: o1/o2.
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
713
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
714
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
715 */
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
716
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
717 PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
718
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
719 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
720 Returns the remainder of dividing o1 by o2, or null on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
721 failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
722 o1%o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
723
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
724
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
725 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
726
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
727 PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
728
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
729 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
730 See the built-in function divmod. Returns NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
731 This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
732 divmod(o1,o2).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
733
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
734
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
735 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
736
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
737 PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
738 PyObject *o3);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
739
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
740 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
741 See the built-in function pow. Returns NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
742 This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
743 pow(o1,o2,o3), where o3 is optional.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
744
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
745 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
746
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
747 PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
748
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
749 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
750 Returns the negation of o on success, or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
751 This is the equivalent of the Python expression: -o.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
752
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
753 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
754
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
755 PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
756
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
757 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
758 Returns the (what?) of o on success, or NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
759 This is the equivalent of the Python expression: +o.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
760
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
761 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
762
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
763 PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
764
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
765 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
766 Returns the absolute value of o, or null on failure. This is
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
767 the equivalent of the Python expression: abs(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
768
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
769 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
770
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
771 PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
772
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
773 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
774 Returns the bitwise negation of o on success, or NULL on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
775 failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
776 ~o.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
777
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
778
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
779 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
780
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
781 PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
782
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
783 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
784 Returns the result of left shifting o1 by o2 on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
785 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
786 expression: o1 << o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
787
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
788
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
789 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
790
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
791 PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
792
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
793 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
794 Returns the result of right shifting o1 by o2 on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
795 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
796 expression: o1 >> o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
797
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
798 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
799
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
800 PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
801
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
802 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
803 Returns the result of bitwise and of o1 and o2 on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
804 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
805 expression: o1&o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
806
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
807
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
808 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
809
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
810 PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
811
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
812 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
813 Returns the bitwise exclusive or of o1 by o2 on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
814 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
815 expression: o1^o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
816
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
817
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
818 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
819
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
820 PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
821
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
822 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
823 Returns the result of bitwise or on o1 and o2 on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
824 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
825 expression: o1|o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
826
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
827 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
828
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 /* Implemented elsewhere:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
830
4217
c6679b1c6cfc Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents: 4090
diff changeset
831 int PyNumber_Coerce(PyObject **p1, PyObject **p2);
c6679b1c6cfc Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents: 4090
diff changeset
832
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
833 This function takes the addresses of two variables of type
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
834 PyObject*.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
835
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
836 If the objects pointed to by *p1 and *p2 have the same type,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
837 increment their reference count and return 0 (success).
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
838 If the objects can be converted to a common numeric type,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
839 replace *p1 and *p2 by their converted value (with 'new'
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
840 reference counts), and return 0.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
841 If no conversion is possible, or if some other error occurs,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
842 return -1 (failure) and don't increment the reference counts.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
843 The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
844 statement o1, o2 = coerce(o1, o2).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
845
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
846 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
847
39463
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
848 #define PyIndex_Check(obj) \
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
849 ((obj)->ob_type->tp_as_number != NULL && \
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
850 PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
851 (obj)->ob_type->tp_as_number->nb_index != NULL)
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
852
39463
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
853 PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
36882
6a9c7165b17b Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents: 36834
diff changeset
854
6a9c7165b17b Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents: 36834
diff changeset
855 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
856 Returns the object converted to a Python long or int
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
857 or NULL with an error raised on failure.
36882
6a9c7165b17b Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents: 36834
diff changeset
858 */
6a9c7165b17b Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents: 36834
diff changeset
859
39463
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
860 PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
861
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
862 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
863 Returns the Integral instance converted to an int. The
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
864 instance is expected to be int or long or have an __int__
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
865 method. Steals integral's reference. error_format will be
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
866 used to create the TypeError if integral isn't actually an
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
867 Integral instance. error_format should be a format string
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
868 that can accept a char* naming integral's type.
45142
f03955faffb4 Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 44350
diff changeset
869 */
f03955faffb4 Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 44350
diff changeset
870
f03955faffb4 Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 44350
diff changeset
871 PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
872 PyObject *integral,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
873 const char* error_format);
45142
f03955faffb4 Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 44350
diff changeset
874
f03955faffb4 Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 44350
diff changeset
875 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
876 Returns the object converted to Py_ssize_t by going through
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
877 PyNumber_Index first. If an overflow error occurs while
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
878 converting the int-or-long to Py_ssize_t, then the second argument
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
879 is the error-type to return. If it is NULL, then the overflow error
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
880 is cleared and the value is clipped.
39463
6cafdc81cfde Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents: 37813
diff changeset
881 */
36882
6a9c7165b17b Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents: 36834
diff changeset
882
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
883 PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
884
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
885 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
886 Returns the o converted to an integer object on success, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
887 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
888 expression: int(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
889
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
890 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
891
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
892 PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
893
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
894 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
895 Returns the o converted to a long integer object on success,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
896 or NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
897 expression: long(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
898
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
899 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
900
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
901 PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
902
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
903 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
904 Returns the o converted to a float object on success, or NULL
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
905 on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
906 float(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
907 */
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
908
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
909 /* In-place variants of (some of) the above number protocol functions */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
910
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
911 PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
912
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
913 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
914 Returns the result of adding o2 to o1, possibly in-place, or null
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
915 on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
916 o1 += o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
917
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
918 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
919
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
920 PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
921
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
922 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
923 Returns the result of subtracting o2 from o1, possibly in-place or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
924 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
925 o1 -= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
926
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
927 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
928
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
929 PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
930
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
931 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
932 Returns the result of multiplying o1 by o2, possibly in-place, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
933 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
934 o1 *= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
935
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
936 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
937
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
938 PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
939
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
940 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
941 Returns the result of dividing o1 by o2, possibly in-place, or null
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
942 on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
943 o1 /= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
944
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
945 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
946
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
947 PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
948 PyObject *o2);
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
949
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
950 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
951 Returns the result of dividing o1 by o2 giving an integral result,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
952 possibly in-place, or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
953 This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
954 o1 /= o2.
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
955
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
956 */
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
957
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
958 PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
959 PyObject *o2);
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
960
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
961 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
962 Returns the result of dividing o1 by o2 giving a float result,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
963 possibly in-place, or null on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
964 This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
965 o1 /= o2.
19051
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
966
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
967 */
f20727cc3d0f Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
968
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
969 PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
970
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
971 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
972 Returns the remainder of dividing o1 by o2, possibly in-place, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
973 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
974 o1 %= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
975
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
976 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
977
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
978 PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
979 PyObject *o3);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
980
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
981 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
982 Returns the result of raising o1 to the power of o2, possibly
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
983 in-place, or null on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
984 expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
985
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
986 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
987
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
988 PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
989
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
990 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
991 Returns the result of left shifting o1 by o2, possibly in-place, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
992 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
993 o1 <<= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
994
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
995 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
996
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
997 PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
998
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
999 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1000 Returns the result of right shifting o1 by o2, possibly in-place or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1001 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1002 o1 >>= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1003
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1004 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1005
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1006 PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1007
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1008 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1009 Returns the result of bitwise and of o1 and o2, possibly in-place,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1010 or null on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1011 expression: o1 &= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1012
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1013 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1014
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1015 PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1016
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1017 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1018 Returns the bitwise exclusive or of o1 by o2, possibly in-place, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1019 null on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1020 o1 ^= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1021
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1022 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1023
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1024 PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1025
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1026 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1027 Returns the result of bitwise or of o1 and o2, possibly in-place,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1028 or null on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1029 expression: o1 |= o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1030
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1031 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1032
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1033
45267
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1034 PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1035
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1036 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1037 Returns the integer n converted to a string with a base, with a base
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1038 marker of 0b, 0o or 0x prefixed if applicable.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1039 If n is not an int object, it is converted with PyNumber_Index first.
45267
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1040 */
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1041
6ebe89328b5e Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents: 45142
diff changeset
1042
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1043 /* Sequence protocol:*/
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1044
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1045 PyAPI_FUNC(int) PySequence_Check(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1046
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1047 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1048 Return 1 if the object provides sequence protocol, and zero
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1049 otherwise.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1050
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1051 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1052
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1053 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1054
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1055 PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
13575
7c119f050290 change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13444
diff changeset
1056
3762
c57b38e40b2d Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents: 3098
diff changeset
1057 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1058 Return the size of sequence object o, or -1 on failure.
3762
c57b38e40b2d Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents: 3098
diff changeset
1059
c57b38e40b2d Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents: 3098
diff changeset
1060 */
c57b38e40b2d Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents: 3098
diff changeset
1061
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1062 /* For DLL compatibility */
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1063 #undef PySequence_Length
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1064 PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1065 #define PySequence_Length PySequence_Size
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1066
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1067
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1068 PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1069
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1070 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1071 Return the concatenation of o1 and o2 on success, and NULL on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1072 failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1073 expression: o1+o2.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1074
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1075 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1076
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1077 PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1078
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1079 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1080 Return the result of repeating sequence object o count times,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1081 or NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1082 expression: o1*count.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1083
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1084 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1085
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1086 PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1087
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1088 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1089 Return the ith element of o, or NULL on failure. This is the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1090 equivalent of the Python expression: o[i].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1091 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1092
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1093 PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1094
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1095 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1096 Return the slice of sequence object o between i1 and i2, or
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1097 NULL on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1098 expression: o[i1:i2].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1099
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1100 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1101
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1102 PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1103
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1104 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1105 Assign object v to the ith element of o. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1106 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1107 statement: o[i]=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1108
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1109 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1110
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1111 PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1112
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1113 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1114 Delete the ith element of object v. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1115 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1116 statement: del o[i].
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1117 */
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1118
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1119 PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1120 PyObject *v);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1121
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1122 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1123 Assign the sequence object, v, to the slice in sequence
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1124 object, o, from i1 to i2. Returns -1 on failure. This is the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1125 equivalent of the Python statement: o[i1:i2]=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1126 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1127
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1128 PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1129
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1130 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1131 Delete the slice in sequence object, o, from i1 to i2.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1132 Returns -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1133 statement: del o[i1:i2].
4090
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1134 */
0b40c8d5b21d Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents: 3959
diff changeset
1135
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1136 PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1137
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1138 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1139 Returns the sequence, o, as a tuple on success, and NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1140 This is equivalent to the Python expression: tuple(o)
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1141 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1142
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1143
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1144 PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
4581
c837f25c7e47 Added missing for PySequence_List.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
1145 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1146 Returns the sequence, o, as a list on success, and NULL on failure.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1147 This is equivalent to the Python expression: list(o)
4581
c837f25c7e47 Added missing for PySequence_List.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
1148 */
5167
61f89beba1aa A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents: 5116
diff changeset
1149
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1150 PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1151 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1152 Returns the sequence, o, as a tuple, unless it's already a
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1153 tuple or list. Use PySequence_Fast_GET_ITEM to access the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1154 members of this list, and PySequence_Fast_GET_SIZE to get its length.
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1155
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1156 Returns NULL on failure. If the object does not support iteration,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1157 raises a TypeError exception with m as the message text.
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1158 */
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1159
20683
505dd34e0eeb Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents: 19808
diff changeset
1160 #define PySequence_Fast_GET_SIZE(o) \
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1161 (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
20683
505dd34e0eeb Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents: 19808
diff changeset
1162 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1163 Return the size of o, assuming that o was returned by
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1164 PySequence_Fast and is not NULL.
20683
505dd34e0eeb Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents: 19808
diff changeset
1165 */
505dd34e0eeb Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents: 19808
diff changeset
1166
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1167 #define PySequence_Fast_GET_ITEM(o, i)\
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1168 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1169 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1170 Return the ith element of o, assuming that o was returned by
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1171 PySequence_Fast, and that i is within bounds.
12952
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1172 */
51949de76365 Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 11965
diff changeset
1173
23397
0d8740094bec Patch #552433: Special-case tuples. Avoid sub-type checking for lists.
Martin v. Löwis <martin@v.loewis.de>
parents: 21644
diff changeset
1174 #define PySequence_ITEM(o, i)\
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1175 ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
23397
0d8740094bec Patch #552433: Special-case tuples. Avoid sub-type checking for lists.
Martin v. Löwis <martin@v.loewis.de>
parents: 21644
diff changeset
1176 /* Assume tp_as_sequence and sq_item exist and that i does not
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1177 need to be corrected for a negative index
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1178 */
23397
0d8740094bec Patch #552433: Special-case tuples. Avoid sub-type checking for lists.
Martin v. Löwis <martin@v.loewis.de>
parents: 21644
diff changeset
1179
31650
be782d07c518 Make PySequence_Fast_ITEMS public. (Thanks Skip.)
Raymond Hettinger <python@rcn.com>
parents: 31645
diff changeset
1180 #define PySequence_Fast_ITEMS(sf) \
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1181 (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1182 : ((PyTupleObject *)(sf))->ob_item)
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1183 /* Return a pointer to the underlying item array for
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1184 an object retured by PySequence_Fast */
31645
5760b4dd3a22 Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents: 30723
diff changeset
1185
36834
0b7809660456 Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36501
diff changeset
1186 PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1187
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1188 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1189 Return the number of occurrences on value on o, that is,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1190 return the number of keys for which o[key]==value. On
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1191 failure, return -1. This is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1192 expression: o.count(value).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1193 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1194
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1195 PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
17692
1812476b7fe4 Reimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters <tim.peters@gmail.com>
parents: 17684
diff changeset
1196 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1197 Return -1 if error; 1 if ob in seq; 0 if ob not in seq.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1198 Use __contains__ if possible, else _PySequence_IterSearch().
17692
1812476b7fe4 Reimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters <tim.peters@gmail.com>
parents: 17684
diff changeset
1199 */
1812476b7fe4 Reimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters <tim.peters@gmail.com>
parents: 17684
diff changeset
1200
19808
0584c9132525 Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents: 19051
diff changeset
1201 #define PY_ITERSEARCH_COUNT 1
0584c9132525 Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents: 19051
diff changeset
1202 #define PY_ITERSEARCH_INDEX 2
0584c9132525 Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents: 19051
diff changeset
1203 #define PY_ITERSEARCH_CONTAINS 3
36834
0b7809660456 Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36501
diff changeset
1204 PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1205 PyObject *obj, int operation);
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1206 /*
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1207 Iterate over seq. Result depends on the operation:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1208 PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1209 error.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1210 PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1211 obj in seq; set ValueError and return -1 if none found;
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1212 also return -1 on error.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1213 PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1214 error.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1215 */
10412
e9e69b02d0f0 Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
1216
e9e69b02d0f0 Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
1217 /* For DLL-level backwards compatibility */
e9e69b02d0f0 Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
1218 #undef PySequence_In
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1219 PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
10412
e9e69b02d0f0 Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
1220
e9e69b02d0f0 Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
1221 /* For source-level backwards compatibility */
9031
d2722a4cbd9c Move an indented #define to column 1.
Guido van Rossum <guido@python.org>
parents: 8401
diff changeset
1222 #define PySequence_In PySequence_Contains
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1223
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1224 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1225 Determine if o contains value. If an item in o is equal to
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1226 X, return 1, otherwise return 0. On error, return -1. This
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1227 is equivalent to the Python expression: value in o.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1228 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1229
36834
0b7809660456 Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36501
diff changeset
1230 PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1231
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1232 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1233 Return the first index for which o[i]=value. On error,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1234 return -1. This is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1235 expression: o.index(value).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1236 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1237
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1238 /* In-place versions of some of the above Sequence functions. */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1239
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1240 PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1241
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1242 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1243 Append o2 to o1, in-place when possible. Return the resulting
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1244 object, which could be o1, or NULL on failure. This is the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1245 equivalent of the Python expression: o1 += o2.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1246
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1247 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1248
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1249 PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1250
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1251 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1252 Repeat o1 by count, in-place when possible. Return the resulting
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1253 object, which could be o1, or NULL on failure. This is the
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1254 equivalent of the Python expression: o1 *= count.
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1255
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1256 */
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13830
diff changeset
1257
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1258 /* Mapping protocol:*/
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1259
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1260 PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1261
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1262 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1263 Return 1 if the object provides mapping protocol, and zero
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1264 otherwise.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1265
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1266 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1267 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1268
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1269 PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
13575
7c119f050290 change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13444
diff changeset
1270
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1271 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1272 Returns the number of keys in object o on success, and -1 on
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1273 failure. For objects that do not provide sequence protocol,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1274 this is equivalent to the Python expression: len(o).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1275 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1276
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1277 /* For DLL compatibility */
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1278 #undef PyMapping_Length
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 36484
diff changeset
1279 PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
13634
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1280 #define PyMapping_Length PyMapping_Size
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1281
6f0d96e6b5a5 Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents: 13620
diff changeset
1282
4218
9e0e8417a98a PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents: 4217
diff changeset
1283 /* implemented as a macro:
9e0e8417a98a PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents: 4217
diff changeset
1284
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1285 int PyMapping_DelItemString(PyObject *o, char *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1286
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1287 Remove the mapping for object, key, from the object *o.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1288 Returns -1 on failure. This is equivalent to
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1289 the Python statement: del o[key].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1290 */
21069
7d3a211ef233 Fix SF bug [ #476852 ] Some bad macros in abstract.h
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20946
diff changeset
1291 #define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
4218
9e0e8417a98a PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents: 4217
diff changeset
1292
9e0e8417a98a PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents: 4217
diff changeset
1293 /* implemented as a macro:
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1294
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1295 int PyMapping_DelItem(PyObject *o, PyObject *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1296
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1297 Remove the mapping for object, key, from the object *o.
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1298 Returns -1 on failure. This is equivalent to
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1299 the Python statement: del o[key].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1300 */
21069
7d3a211ef233 Fix SF bug [ #476852 ] Some bad macros in abstract.h
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 20946
diff changeset
1301 #define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1302
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1303 PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1304
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1305 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1306 On success, return 1 if the mapping object has the key, key,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1307 and 0 otherwise. This is equivalent to the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1308 o.has_key(key).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1309
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1310 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1311 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1312
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1313 PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1314
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1315 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1316 Return 1 if the mapping object has the key, key,
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1317 and 0 otherwise. This is equivalent to the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1318 o.has_key(key).
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1319
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1320 This function always succeeds.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1321
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1322 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1323
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1324 /* Implemented as macro:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1325
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1326 PyObject *PyMapping_Keys(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1327
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1328 On success, return a list of the keys in object o. On
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1329 failure, return NULL. This is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1330 expression: o.keys().
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1331 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1332 #define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1333
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1334 /* Implemented as macro:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1335
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1336 PyObject *PyMapping_Values(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1337
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1338 On success, return a list of the values in object o. On
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1339 failure, return NULL. This is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1340 expression: o.values().
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1341 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1342 #define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1343
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1344 /* Implemented as macro:
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1345
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1346 PyObject *PyMapping_Items(PyObject *o);
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1347
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1348 On success, return a list of the items in object o, where
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1349 each item is a tuple containing a key-value pair. On
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1350 failure, return NULL. This is equivalent to the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1351 expression: o.items().
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1352
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1353 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1354 #define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1355
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1356 PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1357
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1358 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1359 Return element of o corresponding to the object, key, or NULL
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1360 on failure. This is the equivalent of the Python expression:
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1361 o[key].
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1362 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1363
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1364 PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
1365 PyObject *value);
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1366
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1367 /*
61465
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1368 Map the object, key, to the value, v. Returns
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1369 -1 on failure. This is the equivalent of the Python
e38335d4df91 Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 51282
diff changeset
1370 statement: o[key]=v.
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1371 */
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1372
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1373
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1374 PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
17111
bf678a11c21a Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents: 15952
diff changeset
1375 /* isinstance(object, typeorclass) */
bf678a11c21a Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents: 15952
diff changeset
1376
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 23397
diff changeset
1377 PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
17111
bf678a11c21a Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents: 15952
diff changeset
1378 /* issubclass(object, typeorclass) */
bf678a11c21a Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents: 15952
diff changeset
1379
bf678a11c21a Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents: 15952
diff changeset
1380
48876
d01c1d768841 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents: 48221
diff changeset
1381 PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
d01c1d768841 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents: 48221
diff changeset
1382
d01c1d768841 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents: 48221
diff changeset
1383 PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
d01c1d768841 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents: 48221
diff changeset
1384
d01c1d768841 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents: 48221
diff changeset
1385
64345
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1386 /* For internal use by buffer API functions */
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1387 PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1388 const Py_ssize_t *shape);
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1389 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1390 const Py_ssize_t *shape);
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1391
da19d02aaaaa Merged revisions 84391 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 61463
diff changeset
1392
3098
4c83f569b434 use Py_PROTO macro
Guido van Rossum <guido@python.org>
parents: 2838
diff changeset
1393 #ifdef __cplusplus
4c83f569b434 use Py_PROTO macro
Guido van Rossum <guido@python.org>
parents: 2838
diff changeset
1394 }
4c83f569b434 use Py_PROTO macro
Guido van Rossum <guido@python.org>
parents: 2838
diff changeset
1395 #endif
2838
9b1a326727df Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff changeset
1396 #endif /* Py_ABSTRACTOBJECT_H */