Mercurial > cpython-lru_cache-weakref
annotate Include/abstract.h @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | ca71a44d5432 |
| children | e38335d4df91 |
| 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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 correctly. |
|
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. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 An abstract interface providing more consistent semantics is needed. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 modules: |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 Print an object, o, on file, fp. Returns -1 on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 error. The flags argument is used to enable certain printing |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 options. The only option currently supported is Py_Print_RAW. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 (What should be said about Py_Print_RAW?) |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 Returns 1 if o has the attribute attr_name, and 0 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 hasattr(o,attr_name). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 This function always succeeds. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 Retrieve an attributed named attr_name form object o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 Returns the attribute value on success, or NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 This is the equivalent of the Python expression: o.attr_name. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 Returns 1 if o has the attribute attr_name, and 0 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 hasattr(o,attr_name). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 This function always succeeds. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 Retrieve an attributed named attr_name form object o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 Returns the attribute value on success, or NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 This is the equivalent of the Python expression: o.attr_name. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 Set the value of the attribute named attr_name, for object o, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 to the value, v. Returns -1 on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 the equivalent of the Python statement: o.attr_name=v. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 Set the value of the attribute named attr_name, for object o, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 to the value, v. Returns -1 on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 the equivalent of the Python statement: o.attr_name=v. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 Delete attribute named attr_name, for object o. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 statement: del o.attr_name. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 Delete attribute named attr_name, for object o. Returns -1 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 statement: del o.attr_name. |
|
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 Compare the values of o1 and o2 using a routine provided by |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 o1, if one exists, otherwise with a routine provided by o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 The result of the comparison is returned in result. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 statement: result=cmp(o1,o2). |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 Compare the values of o1 and o2 using a routine provided by |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 o1, if one exists, otherwise with a routine provided by o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 Returns the result of the comparison on success. On error, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 the value returned is undefined. This is equivalent to the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 Python expression: cmp(o1,o2). |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 Compute the string representation of object, o. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
259 string representation on success, NULL on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 the equivalent of the Python expression: repr(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 Called by the repr() built-in function and by reverse quotes. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 Compute the string representation of object, o. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 string representation on success, NULL on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 the equivalent of the Python expression: str(o).) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 Called by the str() built-in function and by the print |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 statement. |
|
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 |
|
1f92d63b20f0
This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents:
14162
diff
changeset
|
283 Compute the unicode representation of object, o. Returns the |
|
1f92d63b20f0
This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents:
14162
diff
changeset
|
284 unicode representation on success, NULL on failure. This is |
|
1f92d63b20f0
This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents:
14162
diff
changeset
|
285 the equivalent of the Python expression: unistr(o).) |
|
1f92d63b20f0
This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents:
14162
diff
changeset
|
286 |
|
1f92d63b20f0
This patch adds a new builtin unistr() which behaves like str()
Marc-André Lemburg <mal@egenix.com>
parents:
14162
diff
changeset
|
287 Called by the unistr() built-in function. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 Determine if the object, o, is callable. Return 1 if the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 object is callable and 0 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 This function always succeeds. |
|
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, |
|
18933
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17692
diff
changeset
|
305 PyObject *args, PyObject *kw); |
|
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 /* |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17692
diff
changeset
|
308 Call a callable Python object, callable_object, with |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17692
diff
changeset
|
309 arguments and keywords arguments. The 'args' argument can not be |
|
09df3254b49d
Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
17692
diff
changeset
|
310 NULL, but the 'kw' argument can be NULL. |
|
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 */ |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 Call a callable Python object, callable_object, with |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 arguments given by the tuple, args. If no arguments are |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 needed, then args may be NULL. Returns the result of the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 call on success, or NULL on failure. This is the equivalent |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 of the Python expression: apply(o,args). |
|
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 Call a callable Python object, callable_object, with a |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 variable number of C arguments. The C arguments are described |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 using a mkvalue-style format string. The format may be NULL, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 indicating that no arguments are provided. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 result of the call on success, or NULL on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 the equivalent of the Python expression: apply(o,args). |
|
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
344 Call the method named m of object o with a variable number of |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 C arguments. The C arguments are described by a mkvalue |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 format string. The format may be NULL, indicating that no |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 arguments are provided. Returns the result of the call on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 success, or NULL on failure. This is the equivalent of the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
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, |
|
85695de6049e
C++ compilation cleanup: Migrate declaration of
Skip Montanaro <skip@pobox.com>
parents:
37702
diff
changeset
|
353 char *format, ...); |
|
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, |
|
85695de6049e
C++ compilation cleanup: Migrate declaration of
Skip Montanaro <skip@pobox.com>
parents:
37702
diff
changeset
|
355 char *name, |
|
85695de6049e
C++ compilation cleanup: Migrate declaration of
Skip Montanaro <skip@pobox.com>
parents:
37702
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 /* |
|
d02068d163cf
Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents:
20683
diff
changeset
|
362 Call a callable Python object, callable_object, with a |
|
d02068d163cf
Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents:
20683
diff
changeset
|
363 variable number of C arguments. The C arguments are provided |
|
29089
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
diff
changeset
|
364 as PyObject * values, terminated by a NULL. Returns the |
|
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
diff
changeset
|
365 result of the call on success, or NULL on failure. This is |
|
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
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 /* |
|
d02068d163cf
Added two new functions to conveniently call functions/methods from C.
Fred Drake <fdrake@acm.org>
parents:
20683
diff
changeset
|
374 Call the method named m of object o with a variable number of |
|
29089
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
diff
changeset
|
375 C arguments. The C arguments are provided as PyObject * |
|
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
diff
changeset
|
376 values, terminated by NULL. Returns the result of the call |
|
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
diff
changeset
|
377 on success, or NULL on failure. This is the equivalent of |
|
a571a9d6257a
Fix broken API descriptions in comments.
Fred Drake <fdrake@acm.org>
parents:
28102
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 Compute and return the hash, hash_value, of an object, o. On |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 failure, return -1. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
388 expression: hash(o). |
|
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 |
|
26400
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
diff
changeset
|
397 Returns 1 if the object, o, is considered to be true, 0 if o is |
|
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
diff
changeset
|
398 considered to be false and -1 on failure. This is equivalent to the |
|
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
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 | 403 /* Implemented elsewhere: |
| 404 | |
| 405 int PyObject_Not(PyObject *o); | |
| 406 | |
|
26400
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
diff
changeset
|
407 Returns 0 if the object, o, is considered to be true, 1 if o is |
|
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
diff
changeset
|
408 considered to be false and -1 on failure. This is equivalent to the |
|
cc62854f636c
James Henstridge pointed out a misleading comment.
Michael W. Hudson <mwh@python.net>
parents:
24752
diff
changeset
|
409 Python expression: not o |
| 7935 | 410 |
| 411 */ | |
| 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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 On success, returns a type object corresponding to the object |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 type of object o. On failure, returns NULL. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 equivalent to the Python expression: type(o). |
|
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 /* |
|
13575
7c119f050290
change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13444
diff
changeset
|
424 Return the size of object o. If the object, o, provides |
|
7c119f050290
change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13444
diff
changeset
|
425 both sequence and mapping protocols, the sequence size is |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 returned. On error, -1 is returned. This is the equivalent |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 to the Python expression: len(o). |
|
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 | 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 /* |
| 44193 | 439 Guess the size of object o using len(o) or o.__length_hint__(). |
| 440 If neither of those return a non-negative value, then return the | |
|
51282
ca71a44d5432
Issue 1242657: list(obj) can swallow KeyboardInterrupt
Raymond Hettinger <python@rcn.com>
parents:
48876
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 Return element of o corresponding to the object, key, or NULL |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
449 o[key]. |
|
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 Map the object, key, to the value, v. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 statement: o[key]=v. |
|
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 /* |
|
3c0bd2f37a78
Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents:
21069
diff
changeset
|
464 Remove the mapping for object, key, from the object *o. |
|
3c0bd2f37a78
Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents:
21069
diff
changeset
|
465 Returns -1 on failure. This is equivalent to |
|
3c0bd2f37a78
Implement PyObject_DelItemString. Fixes #498915.
Martin v. Löwis <martin@v.loewis.de>
parents:
21069
diff
changeset
|
466 the Python statement: del o[key]. |
|
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 /* |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
472 Delete the mapping for key from *o. Returns -1 on failure. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
473 This is the equivalent of the Python statement: del o[key]. |
|
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, |
|
11965
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
477 const char **buffer, |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
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 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
480 /* |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
481 Takes an arbitrary object which must support the (character, |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
482 single segment) buffer interface and returns a pointer to a |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
483 read-only memory location useable as character based input |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
484 for subsequent processing. |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
485 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
486 0 is returned on success. buffer and buffer_len are only |
|
28102
f4e72a1a9f13
Fix spelling and grammar.
Raymond Hettinger <python@rcn.com>
parents:
26400
diff
changeset
|
487 set in case no error occurs. Otherwise, -1 is returned and |
|
11965
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
488 an exception set. |
|
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 |
|
ef12c9ddefa7
Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20729
diff
changeset
|
494 /* |
|
ef12c9ddefa7
Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20729
diff
changeset
|
495 Checks whether an arbitrary object supports the (character, |
|
ef12c9ddefa7
Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20729
diff
changeset
|
496 single segment) buffer interface. Returns 1 on success, 0 |
|
ef12c9ddefa7
Add PyObject_CheckReadBuffer(), which returns true if its argument
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20729
diff
changeset
|
497 on failure. |
|
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, |
|
11965
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
502 const void **buffer, |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
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 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
505 /* |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
506 Same as PyObject_AsCharBuffer() except that this API expects |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
507 (readable, single segment) buffer interface and returns a |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
508 pointer to a read-only memory location which can contain |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
509 arbitrary data. |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
510 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
511 0 is returned on success. buffer and buffer_len are only |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
512 set in case no error occurrs. Otherwise, -1 is returned and |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
513 an exception set. |
|
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, |
|
11965
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
518 void **buffer, |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
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 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
521 /* |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
522 Takes an arbitrary object which must support the (writeable, |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
523 single segment) buffer interface and returns a pointer to a |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
524 writeable memory location in buffer of size buffer_len. |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
525 |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
526 0 is returned on success. buffer and buffer_len are only |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
527 set in case no error occurrs. Otherwise, -1 is returned and |
|
9f261e94b2b2
Marc-Andre Lemburg: added declarations for PyObject_AsCharBuffer,
Guido van Rossum <guido@python.org>
parents:
10412
diff
changeset
|
528 an exception set. |
|
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 |
|
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
|
532 /* new buffer API */ |
|
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) \ |
|
45832
5c0b5cabeec9
Finish backporting new buffer API to Python 2.6. Left to do: memoryview object and structmodule. But, these need to be finished in Python 3.0 first. No objects support the new buffer API in Python 2.6 as of yet, and except for the memoryview object, I don't think they will.
Travis E. Oliphant <oliphant@enthought.com>
parents:
45793
diff
changeset
|
535 (((obj)->ob_type->tp_as_buffer != NULL) && \ |
|
5c0b5cabeec9
Finish backporting new buffer API to Python 2.6. Left to do: memoryview object and structmodule. But, these need to be finished in Python 3.0 first. No objects support the new buffer API in Python 2.6 as of yet, and except for the memoryview object, I don't think they will.
Travis E. Oliphant <oliphant@enthought.com>
parents:
45793
diff
changeset
|
536 (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \ |
|
5c0b5cabeec9
Finish backporting new buffer API to Python 2.6. Left to do: memoryview object and structmodule. But, these need to be finished in Python 3.0 first. No objects support the new buffer API in Python 2.6 as of yet, and except for the memoryview object, I don't think they will.
Travis E. Oliphant <oliphant@enthought.com>
parents:
45793
diff
changeset
|
537 ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL)) |
|
5c0b5cabeec9
Finish backporting new buffer API to Python 2.6. Left to do: memoryview object and structmodule. But, these need to be finished in Python 3.0 first. No objects support the new buffer API in Python 2.6 as of yet, and except for the memoryview object, I don't think they will.
Travis E. Oliphant <oliphant@enthought.com>
parents:
45793
diff
changeset
|
538 |
|
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
|
539 /* Return 1 if the getbuffer function is available, otherwise |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
540 return 0 */ |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
542 PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
543 int flags); |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
545 /* This is a C-API version of the getbuffer function call. It checks |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
546 to make sure object has the required function pointer and issues the |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
547 call. Returns -1 and raises an error on failure and returns 0 on |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
548 success |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
549 */ |
|
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); |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
553 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
554 /* Get the memory area pointed to by the indices for the buffer given. |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
555 Note that view->ndim is the assumed size of indices |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
556 */ |
|
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 *); |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
559 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
560 /* Return the implied itemsize of the data-format area from a |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
561 struct-style description */ |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
562 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
563 |
|
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, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
566 Py_ssize_t len, 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
|
567 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
568 PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
569 Py_ssize_t len, 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
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
572 /* Copy len bytes of data from the contiguous chunk of memory |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
573 pointed to by buf into the buffer exported by obj. Return |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
574 0 on success and return -1 and raise a PyBuffer_Error on |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
575 error (i.e. the object does not have a buffer interface or |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
576 it is not working). |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
578 If fort is 'F' and the object is multi-dimensional, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
579 then the data will be copied into the array in |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
580 Fortran-style (first dimension varies the fastest). If |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
581 fort is 'C', then the data will be copied into the array |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
582 in C-style (last dimension varies the fastest). If 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
|
583 is 'A', then it does not matter and the copy will be made |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
584 in whatever way is more efficient. |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
586 */ |
|
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); |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
589 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
590 /* Copy the data from the src buffer to the buffer of destination |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
591 */ |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
596 PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
597 Py_ssize_t *shape, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
598 Py_ssize_t *strides, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
599 int itemsize, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
600 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
|
601 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
602 /* Fill the strides array with byte-strides of a contiguous |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
603 (Fortran-style if fort is 'F' or C-style otherwise) |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
604 array of the given shape with the given number of bytes |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
605 per element. |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
606 */ |
|
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, |
|
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
|
609 Py_ssize_t len, int readonly, |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
610 int flags); |
|
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 |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
612 /* Fills in a buffer-info structure correctly for an exporter |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
613 that can only share a contiguous chunk of memory of |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
614 "unsigned bytes" of the given length. Returns 0 on success |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
615 and -1 (with raising an error) on error. |
|
f11c00246fb5
Add necessary headers to back-port new buffer protocol to Python 2.6
Travis E. Oliphant <oliphant@enthought.com>
parents:
45381
diff
changeset
|
616 */ |
|
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*. |
|
b8c4bf393794
Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
Martin v. Löwis <martin@v.loewis.de>
parents:
45832
diff
changeset
|
621 */ |
|
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, |
|
b7231bf6bfb7
Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents:
45267
diff
changeset
|
624 PyObject *format_spec); |
|
b7231bf6bfb7
Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents:
45267
diff
changeset
|
625 /* |
|
b7231bf6bfb7
Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents:
45267
diff
changeset
|
626 Takes an arbitrary object and returns the result of |
|
b7231bf6bfb7
Backport of PEP 3101, Advanced String Formatting, from py3k.
Eric Smith <eric@trueblade.com>
parents:
45267
diff
changeset
|
627 calling obj.__format__(format_spec). |
|
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. |
|
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17111
diff
changeset
|
634 This is typically a new iterator but if the argument |
|
32e7d0898eab
Iterators phase 1. This comprises:
Guido van Rossum <guido@python.org>
parents:
17111
diff
changeset
|
635 is an iterator, this returns itself. */ |
|
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) && \ |
|
aac65f50df6f
Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents:
17597
diff
changeset
|
639 (obj)->ob_type->tp_iternext != NULL) |
|
aac65f50df6f
Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents:
17597
diff
changeset
|
640 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
641 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
|
642 /* Takes an iterator object and calls its tp_iternext slot, |
|
aac65f50df6f
Mondo changes to the iterator stuff, without changing how Python code
Guido van Rossum <guido@python.org>
parents:
17597
diff
changeset
|
643 returning the next value. If the iterator is exhausted, |
|
17683
e9a4e27e8d4e
Make PyIter_Next() a little smarter (wrt its knowledge of iterator
Tim Peters <tim.peters@gmail.com>
parents:
17617
diff
changeset
|
644 this returns NULL without setting an exception. |
|
e9a4e27e8d4e
Make PyIter_Next() a little smarter (wrt its knowledge of iterator
Tim Peters <tim.peters@gmail.com>
parents:
17617
diff
changeset
|
645 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
|
646 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
647 /* Number Protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
648 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
649 PyAPI_FUNC(int) PyNumber_Check(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
650 |
|
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 Returns 1 if the object, o, provides numeric protocols, and |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
653 false otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
654 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
655 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
656 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
659 PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
660 |
|
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 Returns the result of adding o1 and o2, or null on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
663 This is the equivalent of the Python expression: o1+o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
664 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
668 PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
669 |
|
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 Returns the result of subtracting o2 from o1, or null on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
672 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
673 o1-o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
674 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
677 PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
678 |
|
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 Returns the result of multiplying o1 and o2, or null on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
681 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
682 o1*o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
683 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
687 PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
688 |
|
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 Returns the result of dividing o1 by o2, or null on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
691 This is the equivalent of the Python expression: o1/o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
692 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
696 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
|
697 |
|
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 Returns the result of dividing o1 by o2 giving an integral result, |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
700 or null on failure. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
701 This is the equivalent of the Python expression: o1//o2. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
702 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
706 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
|
707 |
|
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 Returns the result of dividing o1 by o2 giving a float result, |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
710 or null on failure. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
711 This is the equivalent of the Python expression: o1/o2. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
712 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
716 PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
717 |
|
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 Returns the remainder of dividing o1 by o2, or null on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
720 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
721 o1%o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
722 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
726 PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
727 |
|
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 See the built-in function divmod. Returns NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
730 This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
731 divmod(o1,o2). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
732 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
736 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
|
737 PyObject *o3); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
738 |
|
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 See the built-in function pow. Returns NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
741 This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
742 pow(o1,o2,o3), where o3 is optional. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
743 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
746 PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
747 |
|
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 Returns the negation of o on success, or null on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
750 This is the equivalent of the Python expression: -o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
751 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
754 PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
755 |
|
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 Returns the (what?) of o on success, or NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
758 This is the equivalent of the Python expression: +o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
759 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
762 PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
763 |
|
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 Returns the absolute value of o, or null on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
766 the equivalent of the Python expression: abs(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
767 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
770 PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
771 |
|
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 Returns the bitwise negation of o on success, or NULL on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
774 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
775 ~o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
776 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
780 PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
781 |
|
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 Returns the result of left shifting o1 by o2 on success, or |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
784 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
785 expression: o1 << o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
786 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
790 PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
791 |
|
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 Returns the result of right shifting o1 by o2 on success, or |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
794 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
795 expression: o1 >> o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
796 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
799 PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
800 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
801 /* |
|
5116
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
802 Returns the result of bitwise and of o1 and o2 on success, or |
|
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
803 NULL on failure. This is the equivalent of the Python |
|
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
804 expression: o1&o2. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
805 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
809 PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
810 |
|
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 Returns the bitwise exclusive or of o1 by o2 on success, or |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
813 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
814 expression: o1^o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
815 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
819 PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
820 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
821 /* |
|
28102
f4e72a1a9f13
Fix spelling and grammar.
Raymond Hettinger <python@rcn.com>
parents:
26400
diff
changeset
|
822 Returns the result of bitwise or on o1 and o2 on success, or |
|
5116
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
823 NULL on failure. This is the equivalent of the Python |
|
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
824 expression: o1|o2. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
825 |
|
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 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
829 |
|
4217
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
830 int PyNumber_Coerce(PyObject **p1, PyObject **p2); |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
831 |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
832 This function takes the addresses of two variables of type |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
833 PyObject*. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
834 |
|
4217
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
835 If the objects pointed to by *p1 and *p2 have the same type, |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
836 increment their reference count and return 0 (success). |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
837 If the objects can be converted to a common numeric type, |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
838 replace *p1 and *p2 by their converted value (with 'new' |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
839 reference counts), and return 0. |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
840 If no conversion is possible, or if some other error occurs, |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
841 return -1 (failure) and don't increment the reference counts. |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
842 The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
843 statement o1, o2 = coerce(o1, o2). |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
844 |
|
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 |
|
39463
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
847 #define PyIndex_Check(obj) \ |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
848 ((obj)->ob_type->tp_as_number != NULL && \ |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
849 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
|
850 (obj)->ob_type->tp_as_number->nb_index != NULL) |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
851 |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
852 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
|
853 |
|
6a9c7165b17b
Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents:
36834
diff
changeset
|
854 /* |
|
39463
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
855 Returns the object converted to a Python long or int |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
856 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
|
857 */ |
|
6a9c7165b17b
Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents:
36834
diff
changeset
|
858 |
|
39463
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
859 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
|
860 |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
861 /* |
|
45142
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
862 Returns the Integral instance converted to an int. The |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
863 instance is expected to be int or long or have an __int__ |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
864 method. Steals integral's reference. error_format will be |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
865 used to create the TypeError if integral isn't actually an |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
866 Integral instance. error_format should be a format string |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
867 that can accept a char* naming integral's type. |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
868 */ |
|
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 PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
871 PyObject *integral, |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
872 const char* error_format); |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
873 |
|
f03955faffb4
Make int() and long() fall back to __trunc__(). See issue 2002.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
44350
diff
changeset
|
874 /* |
|
39463
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
875 Returns the object converted to Py_ssize_t by going through |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
876 PyNumber_Index first. If an overflow error occurs while |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
877 converting the int-or-long to Py_ssize_t, then the second argument |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
878 is the error-type to return. If it is NULL, then the overflow error |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
879 is cleared and the value is clipped. |
|
6cafdc81cfde
Patch #1538606, Patch to fix __index__() clipping.
Neal Norwitz <nnorwitz@gmail.com>
parents:
37813
diff
changeset
|
880 */ |
|
36882
6a9c7165b17b
Checking in the code for PEP 357.
Guido van Rossum <guido@python.org>
parents:
36834
diff
changeset
|
881 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
882 PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
883 |
|
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 Returns the o converted to an integer object on success, or |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
886 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
887 expression: int(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
888 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
891 PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
892 |
|
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 Returns the o converted to a long integer object on success, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
895 or NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
896 expression: long(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
897 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
900 PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
901 |
|
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 Returns the o converted to a float object on success, or NULL |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
904 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
905 float(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
906 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
907 |
|
14162
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
908 /* 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
|
909 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
910 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
|
911 |
|
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 Returns the result of adding o2 to o1, possibly in-place, or null |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
914 on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
915 o1 += o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
916 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
919 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
|
920 |
|
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 Returns the result of subtracting o2 from o1, possibly in-place or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
923 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
924 o1 -= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
925 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
928 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
|
929 |
|
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 Returns the result of multiplying o1 by o2, possibly in-place, or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
932 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
933 o1 *= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
934 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
937 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
|
938 |
|
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 Returns the result of dividing o1 by o2, possibly in-place, or null |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
941 on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
942 o1 /= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
943 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
946 PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, |
|
19051
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
947 PyObject *o2); |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
948 |
|
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 Returns the result of dividing o1 by o2 giving an integral result, |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
951 possibly in-place, or null on failure. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
952 This is the equivalent of the Python expression: |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
953 o1 /= o2. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
954 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
957 PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, |
|
19051
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
958 PyObject *o2); |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
959 |
|
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 Returns the result of dividing o1 by o2 giving a float result, |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
962 possibly in-place, or null on failure. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
963 This is the equivalent of the Python expression: |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
964 o1 /= o2. |
|
f20727cc3d0f
Implement PEP 238 in its (almost) full glory.
Guido van Rossum <guido@python.org>
parents:
18933
diff
changeset
|
965 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
968 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
|
969 |
|
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 Returns the remainder of dividing o1 by o2, possibly in-place, or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
972 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
973 o1 %= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
974 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
977 PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(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
|
978 PyObject *o3); |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
979 |
|
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 Returns the result of raising o1 to the power of o2, possibly |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
982 in-place, or null on failure. This is the equivalent of the Python |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
983 expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
984 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
987 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
|
988 |
|
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 Returns the result of left shifting o1 by o2, possibly in-place, or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
991 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
992 o1 <<= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
993 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
996 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
|
997 |
|
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 Returns the result of right shifting o1 by o2, possibly in-place or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1000 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1001 o1 >>= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1002 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1005 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
|
1006 |
|
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 Returns the result of bitwise and of o1 and o2, possibly in-place, |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1009 or null on failure. This is the equivalent of the Python |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1010 expression: o1 &= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1011 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1014 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
|
1015 |
|
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 Returns the bitwise exclusive or of o1 by o2, possibly in-place, or |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1018 null on failure. This is the equivalent of the Python expression: |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1019 o1 ^= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1020 |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1023 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
|
1024 |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1025 /* |
| 30723 | 1026 Returns the result of bitwise or of o1 and o2, possibly in-place, |
|
14162
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1027 or null on failure. This is the equivalent of the Python |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1028 expression: o1 |= o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1029 |
|
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 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1032 |
|
45267
6ebe89328b5e
Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents:
45142
diff
changeset
|
1033 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
|
1034 |
|
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 Returns the integer n converted to a string with a base, with a base |
|
6ebe89328b5e
Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents:
45142
diff
changeset
|
1037 marker of 0b, 0o or 0x prefixed if applicable. |
|
6ebe89328b5e
Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents:
45142
diff
changeset
|
1038 If n is not an int object, it is converted with PyNumber_Index first. |
|
6ebe89328b5e
Forgot to modify header file in r60707.
Eric Smith <eric@trueblade.com>
parents:
45142
diff
changeset
|
1039 */ |
|
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 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1042 /* Sequence protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1043 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1044 PyAPI_FUNC(int) PySequence_Check(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1045 |
|
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 Return 1 if the object provides sequence protocol, and zero |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1048 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1049 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1050 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1051 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1054 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
|
1055 |
|
3762
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
1056 /* |
|
13575
7c119f050290
change abstract size functions PySequence_Size &c.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13444
diff
changeset
|
1057 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
|
1058 |
|
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 |
|
13634
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1061 /* For DLL compatibility */ |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1062 #undef PySequence_Length |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1063 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
|
1064 #define PySequence_Length PySequence_Size |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1065 |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1066 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1067 PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1068 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1069 /* |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13589
diff
changeset
|
1070 Return the concatenation of o1 and o2 on success, and NULL on |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1071 failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1072 expression: o1+o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1073 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1076 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
|
1077 |
|
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 Return the result of repeating sequence object o count times, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1080 or NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1081 expression: o1*count. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1082 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1085 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
|
1086 |
|
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 Return the ith element of o, or NULL on failure. This is the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1089 equivalent of the Python expression: o[i]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1090 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1091 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1092 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
|
1093 |
|
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 Return the slice of sequence object o between i1 and i2, or |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1096 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1097 expression: o[i1:i2]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1098 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1101 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
|
1102 |
|
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 Assign object v to the ith element of o. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1105 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1106 statement: o[i]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1107 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1110 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
|
1111 |
|
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 Delete the ith element of object v. Returns |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1114 -1 on failure. This is the equivalent of the Python |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1115 statement: del o[i]. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1116 */ |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1117 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1118 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
|
1119 PyObject *v); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1120 |
|
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 Assign the sequence object, v, to the slice in sequence |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1123 object, o, from i1 to i2. Returns -1 on failure. This is the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1124 equivalent of the Python statement: o[i1:i2]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1125 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1126 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1127 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
|
1128 |
|
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 Delete the slice in sequence object, o, from i1 to i2. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1131 Returns -1 on failure. This is the equivalent of the Python |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1132 statement: del o[i1:i2]. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1133 */ |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
1134 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1135 PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1136 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1137 /* |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
1138 Returns the sequence, o, as a tuple on success, and NULL on failure. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1139 This is equivalent to the Python expression: tuple(o) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1140 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1141 |
| 12952 | 1142 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1143 PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); |
|
4581
c837f25c7e47
Added missing for PySequence_List.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
1144 /* |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
1145 Returns the sequence, o, as a list on success, and NULL on failure. |
|
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
1146 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
|
1147 */ |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
1148 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1149 PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); |
| 12952 | 1150 /* |
| 1151 Returns the sequence, o, as a tuple, unless it's already a | |
| 1152 tuple or list. Use PySequence_Fast_GET_ITEM to access the | |
|
20683
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1153 members of this list, and PySequence_Fast_GET_SIZE to get its length. |
| 12952 | 1154 |
|
17684
399d99601b2d
Generalize tuple() to work nicely with iterators.
Tim Peters <tim.peters@gmail.com>
parents:
17683
diff
changeset
|
1155 Returns NULL on failure. If the object does not support iteration, |
| 12952 | 1156 raises a TypeError exception with m as the message text. |
| 1157 */ | |
| 1158 | |
|
20683
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1159 #define PySequence_Fast_GET_SIZE(o) \ |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1160 (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1161 /* |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1162 Return the size of o, assuming that o was returned by |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1163 PySequence_Fast and is not NULL. |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1164 */ |
|
505dd34e0eeb
Generalize dictionary() to accept a sequence of 2-sequences. At the
Tim Peters <tim.peters@gmail.com>
parents:
19808
diff
changeset
|
1165 |
| 12952 | 1166 #define PySequence_Fast_GET_ITEM(o, i)\ |
| 1167 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) | |
| 1168 /* | |
| 1169 Return the ith element of o, assuming that o was returned by | |
| 1170 PySequence_Fast, and that i is within bounds. | |
| 1171 */ | |
| 1172 | |
|
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
|
1173 #define PySequence_ITEM(o, i)\ |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
44193
diff
changeset
|
1174 ( 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
|
1175 /* Assume tp_as_sequence and sq_item exist and that i does not |
|
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 need to be corrected for a negative index |
|
0d8740094bec
Patch #552433: Special-case tuples. Avoid sub-type checking for lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
21644
diff
changeset
|
1177 */ |
|
0d8740094bec
Patch #552433: Special-case tuples. Avoid sub-type checking for lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
21644
diff
changeset
|
1178 |
|
31650
be782d07c518
Make PySequence_Fast_ITEMS public. (Thanks Skip.)
Raymond Hettinger <python@rcn.com>
parents:
31645
diff
changeset
|
1179 #define PySequence_Fast_ITEMS(sf) \ |
|
31645
5760b4dd3a22
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents:
30723
diff
changeset
|
1180 (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ |
|
5760b4dd3a22
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents:
30723
diff
changeset
|
1181 : ((PyTupleObject *)(sf))->ob_item) |
|
5760b4dd3a22
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents:
30723
diff
changeset
|
1182 /* Return a pointer to the underlying item array for |
|
5760b4dd3a22
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents:
30723
diff
changeset
|
1183 an object retured by PySequence_Fast */ |
|
5760b4dd3a22
Use a new macro, PySequence_Fast_ITEMS to factor out code common to
Raymond Hettinger <python@rcn.com>
parents:
30723
diff
changeset
|
1184 |
|
36834
0b7809660456
Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
1185 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
|
1186 |
|
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 Return the number of occurrences on value on o, that is, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1189 return the number of keys for which o[key]==value. On |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1190 failure, return -1. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1191 expression: o.count(value). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1192 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1193 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1194 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
|
1195 /* |
|
1812476b7fe4
Reimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters <tim.peters@gmail.com>
parents:
17684
diff
changeset
|
1196 Return -1 if error; 1 if ob in seq; 0 if ob not in seq. |
|
19808
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1197 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
|
1198 */ |
|
1812476b7fe4
Reimplement PySequence_Contains() and instance_contains(), so they work
Tim Peters <tim.peters@gmail.com>
parents:
17684
diff
changeset
|
1199 |
|
19808
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1200 #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
|
1201 #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
|
1202 #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
|
1203 PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, |
|
0b7809660456
Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
1204 PyObject *obj, int operation); |
|
19808
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1205 /* |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1206 Iterate over seq. Result depends on the operation: |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1207 PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1208 error. |
|
28102
f4e72a1a9f13
Fix spelling and grammar.
Raymond Hettinger <python@rcn.com>
parents:
26400
diff
changeset
|
1209 PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of |
|
19808
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1210 obj in seq; set ValueError and return -1 if none found; |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1211 also return -1 on error. |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1212 PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1213 error. |
|
0584c9132525
Generalize operator.indexOf (PySequence_Index) to work with any
Tim Peters <tim.peters@gmail.com>
parents:
19051
diff
changeset
|
1214 */ |
|
10412
e9e69b02d0f0
Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
1215 |
|
e9e69b02d0f0
Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
1216 /* 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
|
1217 #undef PySequence_In |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1218 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
|
1219 |
|
e9e69b02d0f0
Add DLL level b/w compat for PySequence_In and PyEval_CallObject
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
1220 /* For source-level backwards compatibility */ |
|
9031
d2722a4cbd9c
Move an indented #define to column 1.
Guido van Rossum <guido@python.org>
parents:
8401
diff
changeset
|
1221 #define PySequence_In PySequence_Contains |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1222 |
|
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 Determine if o contains value. If an item in o is equal to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1225 X, return 1, otherwise return 0. On error, return -1. This |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1226 is equivalent to the Python expression: value in o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1227 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1228 |
|
36834
0b7809660456
Change some sequnce APIs to use Py_ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
1229 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
|
1230 |
|
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 Return the first index for which o[i]=value. On error, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1233 return -1. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1234 expression: o.index(value). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1235 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1236 |
|
14162
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1237 /* 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
|
1238 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1239 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
|
1240 |
|
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 Append o2 to o1, in-place when possible. Return the resulting |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1243 object, which could be o1, or NULL on failure. This is the |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1244 equivalent of the Python expression: o1 += o2. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1245 |
|
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 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1248 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
|
1249 |
|
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 Repeat o1 by count, in-place when possible. Return the resulting |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1252 object, which could be o1, or NULL on failure. This is the |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1253 equivalent of the Python expression: o1 *= count. |
|
27d7d89c774b
The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents:
13830
diff
changeset
|
1254 |
|
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 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1257 /* Mapping protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1258 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1259 PyAPI_FUNC(int) PyMapping_Check(PyObject *o); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1260 |
|
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 Return 1 if the object provides mapping protocol, and zero |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1263 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1264 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1265 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1266 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1267 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1268 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
|
1269 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1270 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1271 Returns the number of keys in object o on success, and -1 on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1272 failure. For objects that do not provide sequence protocol, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1273 this is equivalent to the Python expression: len(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1274 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1275 |
|
13634
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1276 /* For DLL compatibility */ |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1277 #undef PyMapping_Length |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36484
diff
changeset
|
1278 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
|
1279 #define PyMapping_Length PyMapping_Size |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1280 |
|
6f0d96e6b5a5
Restore PyXXX_Length() APIs for binary compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
13620
diff
changeset
|
1281 |
|
4218
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
1282 /* implemented as a macro: |
|
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
1283 |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1284 int PyMapping_DelItemString(PyObject *o, char *key); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1285 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1286 Remove the mapping for object, key, from the object *o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1287 Returns -1 on failure. This is equivalent to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1288 the Python statement: del o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1289 */ |
|
21069
7d3a211ef233
Fix SF bug [ #476852 ] Some bad macros in abstract.h
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20946
diff
changeset
|
1290 #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
|
1291 |
|
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
1292 /* implemented as a macro: |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1293 |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
1294 int PyMapping_DelItem(PyObject *o, PyObject *key); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1295 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1296 Remove the mapping for object, key, from the object *o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1297 Returns -1 on failure. This is equivalent to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1298 the Python statement: del o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1299 */ |
|
21069
7d3a211ef233
Fix SF bug [ #476852 ] Some bad macros in abstract.h
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20946
diff
changeset
|
1300 #define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1301 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1302 PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1303 |
|
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 On success, return 1 if the mapping object has the key, key, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1306 and 0 otherwise. This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1307 o.has_key(key). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1308 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1309 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1310 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1311 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1312 PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1313 |
|
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 Return 1 if the mapping object has the key, key, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1316 and 0 otherwise. This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1317 o.has_key(key). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1318 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1319 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1320 |
|
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 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1324 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1325 PyObject *PyMapping_Keys(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1326 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1327 On success, return a list of the keys in object o. On |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1328 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1329 expression: o.keys(). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1330 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1331 #define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1332 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1333 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1334 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1335 PyObject *PyMapping_Values(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1336 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1337 On success, return a list of the values in object o. On |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1338 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1339 expression: o.values(). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1340 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1341 #define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1342 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1343 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1344 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1345 PyObject *PyMapping_Items(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1346 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1347 On success, return a list of the items in object o, where |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1348 each item is a tuple containing a key-value pair. On |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1349 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1350 expression: o.items(). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1351 |
|
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 #define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1354 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1355 PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1356 |
|
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 Return element of o corresponding to the object, key, or NULL |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1359 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1360 o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1361 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1362 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1363 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
|
1364 PyObject *value); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1365 |
|
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 Map the object, key, to the value, v. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1368 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1369 statement: o[key]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1370 */ |
|
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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1373 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
|
1374 /* isinstance(object, typeorclass) */ |
|
bf678a11c21a
Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents:
15952
diff
changeset
|
1375 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
23397
diff
changeset
|
1376 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
|
1377 /* issubclass(object, typeorclass) */ |
|
bf678a11c21a
Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents:
15952
diff
changeset
|
1378 |
|
bf678a11c21a
Move the code implementing isinstance() and issubclass() to new C
Guido van Rossum <guido@python.org>
parents:
15952
diff
changeset
|
1379 |
|
48876
d01c1d768841
Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents:
48221
diff
changeset
|
1380 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
|
1381 |
|
d01c1d768841
Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents:
48221
diff
changeset
|
1382 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
|
1383 |
|
d01c1d768841
Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
Antoine Pitrou <solipsis@pitrou.net>
parents:
48221
diff
changeset
|
1384 |
| 3098 | 1385 #ifdef __cplusplus |
| 1386 } | |
| 1387 #endif | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1388 #endif /* Py_ABSTRACTOBJECT_H */ |
