Mercurial > cpython-lru_cache-weakref
annotate Include/tupleobject.h @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 0e498a9fde3c |
| children |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Tuple object interface */ |
| 3 | |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
4 #ifndef Py_TUPLEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
5 #define Py_TUPLEOBJECT_H |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
6 #ifdef __cplusplus |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
7 extern "C" { |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
8 #endif |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
9 |
| 6 | 10 /* |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
11 Another generally useful object type is a tuple of object pointers. |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
12 For Python, this is an immutable type. C code can change the tuple items |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
13 (but not their number), and even use tuples are general-purpose arrays of |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
14 object references, but in general only brand new tuples should be mutated, |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
15 not ones that might already have been exposed to Python code. |
| 6 | 16 |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
17 *** WARNING *** PyTuple_SetItem does not increment the new item's reference |
| 6 | 18 count, but does decrement the reference count of the item it replaces, |
| 19 if not nil. It does *decrement* the reference count if it is *not* | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
20 inserted in the tuple. Similarly, PyTuple_GetItem does not increment the |
| 6 | 21 returned item's reference count. |
| 22 */ | |
| 23 | |
| 86 | 24 typedef struct { |
|
13445
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
25 PyObject_VAR_HEAD |
|
091ca6b9348f
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
26 PyObject *ob_item[1]; |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
27 |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
28 /* ob_item contains space for 'ob_size' elements. |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
29 * Items must normally not be NULL, except during construction when |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
30 * the tuple is not yet visible outside the function that builds it. |
|
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
30682
diff
changeset
|
31 */ |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
32 } PyTupleObject; |
| 86 | 33 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
19844
diff
changeset
|
34 PyAPI_DATA(PyTypeObject) PyTuple_Type; |
| 6 | 35 |
|
40908
d01bd37bf5ce
Variation of patch # 1624059 to speed up checking if an object is a subclass
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
36 #define PyTuple_Check(op) \ |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
37 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) |
|
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
38 #define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) |
| 6 | 39 |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
40 PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
41 PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
42 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
43 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
44 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
45 PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
46 PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); |
|
52288
0e498a9fde3c
Issue #4688: Add a heuristic so that tuples and dicts containing only
Antoine Pitrou <solipsis@pitrou.net>
parents:
45341
diff
changeset
|
47 PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); |
| 86 | 48 |
| 49 /* Macro, trading safety for speed */ | |
|
2500
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
50 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
51 #define PyTuple_GET_SIZE(op) Py_SIZE(op) |
|
2500
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
52 |
|
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
53 /* Macro, *only* to be used to fill in brand new tuples */ |
|
f217c1b27f86
addet SETTUPLEITEM and added cast to GETTUPLEITEM
Guido van Rossum <guido@python.org>
parents:
2436
diff
changeset
|
54 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
55 |
|
45341
65ae68c7aca3
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
Christian Heimes <christian@cheimes.de>
parents:
44350
diff
changeset
|
56 PyAPI_FUNC(int) PyTuple_ClearFreeList(void); |
|
65ae68c7aca3
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
Christian Heimes <christian@cheimes.de>
parents:
44350
diff
changeset
|
57 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
58 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
59 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
60 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
61 #endif /* !Py_TUPLEOBJECT_H */ |
