Mercurial > cpython-lru_cache-weakref
annotate Include/abstract.h @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 61f89beba1aa |
| children | aa7d69d67c81 |
| 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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 /*********************************************************** |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 The Netherlands. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 All Rights Reserved |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
13 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
14 documentation for any purpose and without fee is hereby granted, |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
16 both that copyright notice and this permission notice appear in |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
18 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
19 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
20 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
21 permission. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
23 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
24 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
25 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
26 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
27 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
28 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
29 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
30 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
31 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
32 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4218
diff
changeset
|
34 PERFORMANCE OF THIS SOFTWARE. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 /* Abstract Object Interface (many thanks to Jim Fulton) */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 PROPOSAL: A Generic Python Object Interface for Python C Modules |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 Problem |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 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
|
46 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
|
47 include files. Unfortunately, these routines vary according to the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 tuple: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 if(is_tupleobject(o)) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 e=gettupleitem(o,i) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 else if(is_listitem(o)) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 e=getlistitem(o,i) |
|
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 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
|
60 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
|
61 correctly. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 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
|
64 _typeobject structure provides a means of invoking up to (currently |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 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
|
66 item from any object that provides sequence behavior. However, to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 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
|
68 the current Python implementation. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 Also, certain semantics, especially memory management semantics, may |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 differ by the type of object being used. Unfortunately, these |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 semantics are not clearly described in the current include files. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 An abstract interface providing more consistent semantics is needed. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 Proposal |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 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
|
78 library of routines and/or macros) for generically obtaining the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 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
|
80 components of a Python C interface consisting of several components. |
|
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 From the viewpoint of of C access to Python services, we have (as |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 suggested by Guido in off-line discussions): |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 - "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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 be part of this API.) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 - "Abstract objects layer": which is the subject of this proposal. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 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
|
96 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
|
97 through the Python parser. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 - "Concrete objects layer": This is the public type-dependent |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 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
|
101 strings, and lists. This interface exists and is currently |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 documented by the collection of include files provides with the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 Python distributions. |
|
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 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
|
106 modules: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 - "Python module interface": this interface consist of the basic |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 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
|
110 current extensions-writing guide deals with this interface. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 - "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
|
113 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
|
114 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
|
115 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 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
|
117 discussion. See especially the lists of notes. |
|
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 The Python C object interface will provide four protocols: object, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 numeric, sequence, and mapping. Each protocol consists of a |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 collection of related operations. If an operation that is not |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 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
|
123 NotImplementedError is raised with a operation name as an argument. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 In addition, for convenience this interface defines a set of |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 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
|
126 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
|
127 objects generically. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 Memory Management |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 argument in anticipation of the object's retention. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 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
|
138 objects. Functions that return objects assume that the caller will |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 must decrement the reference count of the object (using |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 DECREF(object)) to prevent memory leaks. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 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
|
146 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
|
147 type-specific routines are called directly (e.g. setlistitem). The |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 proposed abstraction layer will provide a consistent memory |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 management interface, correcting for inconsistent behavior for some |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 built-in types. |
|
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 Protocols |
|
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 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ |
|
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 /* Object Protocol: */ |
|
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 /* Implemented elsewhere: |
|
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 int PyObject_Print(PyObject *o, FILE *fp, int flags); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 Print an object, o, on file, fp. Returns -1 on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 error. The flags argument is used to enable certain printing |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 options. The only option currently supported is Py_Print_RAW. |
|
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 (What should be said about Py_Print_RAW?) |
|
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 */ |
|
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 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 int PyObject_HasAttrString(PyObject *o, char *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 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
|
175 This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 hasattr(o,attr_name). |
|
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 This function always succeeds. |
|
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 */ |
|
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 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 PyObject* PyObject_GetAttrString(PyObject *o, char *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 Retrieve an attributed named attr_name form object o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 Returns the attribute value on success, or NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 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
|
189 |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 int PyObject_HasAttr(PyObject *o, PyObject *attr_name); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 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
|
197 This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 hasattr(o,attr_name). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); |
|
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 Retrieve an attributed named attr_name form object o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 Returns the attribute value on success, or NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 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
|
211 |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 /* Implemented elsewhere: |
|
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 int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 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
|
220 to the value, v. Returns -1 on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 the equivalent of the Python statement: o.attr_name=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); |
|
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 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
|
230 to the value, v. Returns -1 on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 the equivalent of the Python statement: o.attr_name=v. |
|
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 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 /* implemented as a macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 int PyObject_DelAttrString(PyObject *o, char *attr_name); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 Delete attribute named attr_name, for object o. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 statement: del o.attr_name. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 |
|
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 #define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) |
|
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 /* implemented as a macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 int PyObject_DelAttr(PyObject *o, PyObject *attr_name); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 Delete attribute named attr_name, for object o. Returns -1 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 statement: del o.attr_name. |
|
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 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 #define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 |
| 3098 | 257 int PyObject_Cmp Py_PROTO((PyObject *o1, PyObject *o2, int *result)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
259 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 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
|
261 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
|
262 The result of the comparison is returned in result. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 statement: result=cmp(o1,o2). |
|
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 */ |
|
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 /* Implemented elsewhere: |
|
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 int PyObject_Compare(PyObject *o1, PyObject *o2); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 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
|
273 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
|
274 Returns the result of the comparison on success. On error, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 the value returned is undefined. This is equivalent to the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 Python expression: cmp(o1,o2). |
|
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 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 PyObject *PyObject_Repr(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 Compute the string representation of object, o. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 string representation on success, NULL on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 the equivalent of the Python expression: repr(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 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
|
289 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 PyObject *PyObject_Str(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 Compute the string representation of object, o. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 string representation on success, NULL on failure. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 the equivalent of the Python expression: str(o).) |
|
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 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
|
301 statement. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 |
| 3098 | 305 int PyCallable_Check Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
308 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
|
309 object is callable and 0 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 |
| 3098 | 317 PyObject *PyObject_CallObject Py_PROTO((PyObject *callable_object, |
| 318 PyObject *args)); | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
321 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 Call a callable Python object, callable_object, with |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
323 arguments given by the tuple, args. If no arguments are |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 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
|
325 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
|
326 of the Python expression: apply(o,args). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 |
|
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 |
| 3098 | 330 PyObject *PyObject_CallFunction Py_PROTO((PyObject *callable_object, |
| 331 char *format, ...)); | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 Call a callable Python object, callable_object, with a |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 variable number of C arguments. The C arguments are described |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 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
|
337 indicating that no arguments are provided. Returns the |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
338 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
|
339 the equivalent of the Python expression: apply(o,args). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 */ |
|
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 |
| 3098 | 344 PyObject *PyObject_CallMethod Py_PROTO((PyObject *o, char *m, |
| 345 char *format, ...)); | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
347 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
348 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
|
349 C arguments. The C arguments are described by a mkvalue |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 format string. The format may be NULL, indicating that no |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 arguments are provided. Returns the result of the call on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
352 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
|
353 Python expression: o.method(args). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
354 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 Note that Special method names, such as "__add__", |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 "__getitem__", and so on are not supported. The specific |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
357 abstract-object routines for these must be used. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
358 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
359 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
360 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
362 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
363 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
364 long PyObject_Hash(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 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
|
367 failure, return -1. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
368 expression: hash(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
373 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 int PyObject_IsTrue(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
377 Returns 1 if the object, o, is considered to be true, and |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
378 0 otherwise. This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
379 not not o |
|
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 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
382 |
|
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 |
| 3098 | 385 PyObject *PyObject_Type Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
387 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
388 On success, returns a type object corresponding to the object |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
389 type of object o. On failure, returns NULL. This is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 equivalent to the Python expression: type(o). |
|
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 |
| 3098 | 393 int PyObject_Length Py_PROTO((PyObject *o)); |
|
2838
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 Return the length of object o. If the object, o, provides |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 both sequence and mapping protocols, the sequence length is |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
398 returned. On error, -1 is returned. This is the equivalent |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 to the Python expression: len(o). |
|
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 |
| 3098 | 403 PyObject *PyObject_GetItem Py_PROTO((PyObject *o, PyObject *key)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 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
|
407 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
408 o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 |
| 3098 | 412 int PyObject_SetItem Py_PROTO((PyObject *o, PyObject *key, PyObject *v)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
413 |
|
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 Map the object, key, to the value, v. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
417 statement: o[key]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 |
|
4090
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
420 int PyObject_DelItem Py_PROTO((PyObject *o, PyObject *key)); |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
421 |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
422 /* |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
423 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
|
424 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
|
425 */ |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
426 |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 /* Number Protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 |
| 3098 | 430 int PyNumber_Check Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
433 Returns 1 if the object, o, provides numeric protocols, and |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 false otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 |
| 3098 | 440 PyObject *PyNumber_Add Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 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
|
444 This is the equivalent of the Python expression: o1+o2. |
|
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 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 |
| 3098 | 449 PyObject *PyNumber_Subtract Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 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
|
453 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 o1-o2. |
|
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 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 |
| 3098 | 458 PyObject *PyNumber_Multiply Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
459 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 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
|
462 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
463 o1*o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
464 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
467 |
| 3098 | 468 PyObject *PyNumber_Divide Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
469 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 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
|
472 This is the equivalent of the Python expression: o1/o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
474 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 |
| 3098 | 477 PyObject *PyNumber_Remainder Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
478 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
479 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
480 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
|
481 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
482 o1%o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
483 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
484 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 |
| 3098 | 487 PyObject *PyNumber_Divmod Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
488 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
490 See the built-in function divmod. Returns NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
491 This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
492 divmod(o1,o2). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
493 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
494 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
495 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
496 |
| 3098 | 497 PyObject *PyNumber_Power Py_PROTO((PyObject *o1, PyObject *o2, PyObject *o3)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
498 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
499 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
500 See the built-in function pow. Returns NULL on failure. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
501 This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
502 pow(o1,o2,o3), where o3 is optional. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
503 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
505 |
| 3098 | 506 PyObject *PyNumber_Negative Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 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
|
510 This is the equivalent of the Python expression: -o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 |
| 3098 | 514 PyObject *PyNumber_Positive Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 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
|
518 This is the equivalent of the Python expression: +o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
520 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 |
| 3098 | 522 PyObject *PyNumber_Absolute Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
523 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
524 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
525 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
|
526 the equivalent of the Python expression: abs(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
528 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
529 |
| 3098 | 530 PyObject *PyNumber_Invert Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
531 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
532 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
533 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
|
534 failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
535 ~o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
536 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
537 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
538 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
539 |
| 3098 | 540 PyObject *PyNumber_Lshift Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
541 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
542 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
543 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
|
544 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
545 expression: o1 << o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
546 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
547 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
548 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
549 |
| 3098 | 550 PyObject *PyNumber_Rshift Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
551 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
552 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
553 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
|
554 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
555 expression: o1 >> o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
556 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
557 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 |
| 3098 | 559 PyObject *PyNumber_And Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
561 /* |
|
5116
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
562 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
|
563 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
|
564 expression: o1&o2. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
565 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
567 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
568 |
| 3098 | 569 PyObject *PyNumber_Xor Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
570 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
571 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
572 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
|
573 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
574 expression: o1^o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
575 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
576 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
577 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
578 |
| 3098 | 579 PyObject *PyNumber_Or Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
580 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
581 /* |
|
5116
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
582 Returns the result of bitwise or or o1 and o2 on success, or |
|
506664767736
Fix the comments for bitwise and/or.
Guido van Rossum <guido@python.org>
parents:
4581
diff
changeset
|
583 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
|
584 expression: o1|o2. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
585 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
586 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
587 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
588 /* Implemented elsewhere: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
589 |
|
4217
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
590 int PyNumber_Coerce(PyObject **p1, PyObject **p2); |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
591 |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
592 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
|
593 PyObject*. |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
594 |
|
4217
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
595 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
|
596 increment their reference count and return 0 (success). |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
597 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
|
598 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
|
599 reference counts), and return 0. |
|
c6679b1c6cfc
Correctly document PyNumber_Coerce.
Guido van Rossum <guido@python.org>
parents:
4090
diff
changeset
|
600 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
|
601 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
|
602 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
|
603 statement o1, o2 = coerce(o1, o2). |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
604 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
605 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
606 |
| 3098 | 607 PyObject *PyNumber_Int Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
608 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
609 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
610 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
|
611 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
612 expression: int(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
613 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
614 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
615 |
| 3098 | 616 PyObject *PyNumber_Long Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
617 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
618 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
619 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
|
620 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
|
621 expression: long(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
622 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
623 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
624 |
| 3098 | 625 PyObject *PyNumber_Float Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
626 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
627 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
628 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
|
629 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
630 float(o). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
631 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
632 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
633 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
634 /* Sequence protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
635 |
| 3098 | 636 int PySequence_Check Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
637 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
638 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
639 Return 1 if the object provides sequence protocol, and zero |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
640 otherwise. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
641 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
642 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
643 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
644 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
645 |
|
3959
6af7a703adae
Typo: PySequence_Lenth -> PySequence_Length.
Guido van Rossum <guido@python.org>
parents:
3762
diff
changeset
|
646 int PySequence_Length Py_PROTO((PyObject *o)); |
|
3762
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
647 |
|
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
648 /* |
|
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
649 Return the length of sequence object o, or -1 on failure. |
|
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
650 |
|
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
651 */ |
|
c57b38e40b2d
Added prototype + doc for PySequence_Length()
Guido van Rossum <guido@python.org>
parents:
3098
diff
changeset
|
652 |
| 3098 | 653 PyObject *PySequence_Concat Py_PROTO((PyObject *o1, PyObject *o2)); |
|
2838
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
656 Return the concatination of o1 and o2 on success, and NULL on |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
657 failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
658 expression: o1+o2. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
659 |
|
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 |
| 3098 | 662 PyObject *PySequence_Repeat Py_PROTO((PyObject *o, int count)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
663 |
|
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 Return the result of repeating sequence object o count times, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
666 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
|
667 expression: o1*count. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
668 |
|
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 |
| 3098 | 671 PyObject *PySequence_GetItem Py_PROTO((PyObject *o, int i)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
672 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
673 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
674 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
|
675 equivalent of the Python expression: o[i]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
676 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
677 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
678 |
| 3098 | 679 PyObject *PySequence_GetSlice Py_PROTO((PyObject *o, int i1, int i2)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
680 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
681 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
682 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
|
683 NULL on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
684 expression: o[i1:i2]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
685 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
686 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
687 |
| 3098 | 688 int PySequence_SetItem Py_PROTO((PyObject *o, int i, PyObject *v)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
689 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
690 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
691 Assign object v to the ith element of o. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
692 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
693 statement: o[i]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
694 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
695 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
696 |
|
4090
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
697 int PySequence_DelItem Py_PROTO((PyObject *o, int i)); |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
698 |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
699 /* |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
700 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
|
701 -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
|
702 statement: del o[i]. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
703 */ |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
704 |
| 3098 | 705 int PySequence_SetSlice Py_PROTO((PyObject *o, int i1, int i2, PyObject *v)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
706 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
707 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
708 Assign the sequence object, v, to the slice in sequence |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
709 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
|
710 equivalent of the Python statement: o[i1:i2]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
711 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
712 |
|
4090
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
713 int PySequence_DelSlice Py_PROTO((PyObject *o, int i1, int i2)); |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
714 |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
715 /* |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
716 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
|
717 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
|
718 statement: del o[i1:i2]. |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
719 */ |
|
0b40c8d5b21d
Added PyObject_DelItem and PySequence_Del{Item,Slice}.
Guido van Rossum <guido@python.org>
parents:
3959
diff
changeset
|
720 |
| 3098 | 721 PyObject *PySequence_Tuple Py_PROTO((PyObject *o)); |
|
2838
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 /* |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
724 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
|
725 This is equivalent to the Python expression: tuple(o) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
726 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
727 |
|
4581
c837f25c7e47
Added missing for PySequence_List.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
728 PyObject *PySequence_List Py_PROTO((PyObject *o)); |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
729 |
|
4581
c837f25c7e47
Added missing for PySequence_List.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
730 /* |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
731 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
|
732 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
|
733 */ |
|
5167
61f89beba1aa
A few comment alignment and clarifications.
Guido van Rossum <guido@python.org>
parents:
5116
diff
changeset
|
734 |
| 3098 | 735 int PySequence_Count Py_PROTO((PyObject *o, PyObject *value)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
736 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
737 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
738 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
|
739 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
|
740 failure, return -1. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
741 expression: o.count(value). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
742 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
743 |
| 3098 | 744 int PySequence_In Py_PROTO((PyObject *o, PyObject *value)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
745 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
746 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
747 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
|
748 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
|
749 is equivalent to the Python expression: value in o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
750 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
751 |
| 3098 | 752 int PySequence_Index Py_PROTO((PyObject *o, PyObject *value)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
753 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
754 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
755 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
|
756 return -1. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
757 expression: o.index(value). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
758 */ |
|
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 /* Mapping protocol:*/ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
761 |
| 3098 | 762 int PyMapping_Check Py_PROTO((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 Return 1 if the object provides mapping protocol, and zero |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
766 otherwise. |
|
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 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
769 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
770 |
| 3098 | 771 int PyMapping_Length Py_PROTO((PyObject *o)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
772 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
773 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
774 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
|
775 failure. For objects that do not provide sequence protocol, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
776 this is equivalent to the Python expression: len(o). |
|
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 |
|
4218
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
779 /* implemented as a macro: |
|
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
780 |
| 3098 | 781 int PyMapping_DelItemString Py_PROTO((PyObject *o, char *key)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
782 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
783 Remove the mapping for object, key, from the object *o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
784 Returns -1 on failure. This is equivalent to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
785 the Python statement: del o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
786 */ |
|
4218
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
787 #define PyMapping_DelItemString(O,K) PyDict_DelItemString((O),(K)) |
|
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
788 |
|
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
789 /* implemented as a macro: |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
790 |
| 3098 | 791 int PyMapping_DelItem Py_PROTO((PyObject *o, PyObject *key)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
792 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
793 Remove the mapping for object, key, from the object *o. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
794 Returns -1 on failure. This is equivalent to |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
795 the Python statement: del o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
796 */ |
|
4218
9e0e8417a98a
PyMapping_DelItem[String] are actually macros.
Guido van Rossum <guido@python.org>
parents:
4217
diff
changeset
|
797 #define PyMapping_DelItem(O,K) PyDict_DelItem((O),(K)) |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
798 |
| 3098 | 799 int PyMapping_HasKeyString Py_PROTO((PyObject *o, char *key)); |
|
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 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
802 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
|
803 and 0 otherwise. This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
804 o.has_key(key). |
|
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 This function always succeeds. |
|
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 |
| 3098 | 809 int PyMapping_HasKey Py_PROTO((PyObject *o, PyObject *key)); |
|
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 Return 1 if the mapping object has the key, key, |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
813 and 0 otherwise. This is equivalent to the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
814 o.has_key(key). |
|
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 This function always succeeds. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
817 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
818 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
819 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
820 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
821 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
822 PyObject *PyMapping_Keys(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
823 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
824 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
|
825 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
826 expression: o.keys(). |
|
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 #define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
829 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
830 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
831 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
832 PyObject *PyMapping_Values(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
833 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
834 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
|
835 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
836 expression: o.values(). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
837 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
838 #define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
839 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
840 /* Implemented as macro: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
841 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
842 PyObject *PyMapping_Items(PyObject *o); |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
843 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
844 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
|
845 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
|
846 failure, return NULL. This is equivalent to the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
847 expression: o.items(). |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
848 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
849 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
850 #define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
851 |
| 3098 | 852 PyObject *PyMapping_GetItemString Py_PROTO((PyObject *o, char *key)); |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
853 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
854 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
855 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
|
856 on failure. This is the equivalent of the Python expression: |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
857 o[key]. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
858 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
859 |
| 3098 | 860 int PyMapping_SetItemString Py_PROTO((PyObject *o, char *key, |
| 861 PyObject *value)); | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
862 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
863 /* |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
864 Map the object, key, to the value, v. Returns |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
865 -1 on failure. This is the equivalent of the Python |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
866 statement: o[key]=v. |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
867 */ |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
868 |
|
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
869 |
| 3098 | 870 #ifdef __cplusplus |
| 871 } | |
| 872 #endif | |
|
2838
9b1a326727df
Generic Abstract Object Interface
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
873 #endif /* Py_ABSTRACTOBJECT_H */ |
