Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 1 | /* enumerate object */ |
| 2 | |
| 3 | #include "Python.h" |
| 4 | |
| 5 | typedef struct { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 6 | PyObject_HEAD |
| 7 | Py_ssize_t en_index; /* current index of enumeration */ |
| 8 | PyObject* en_sit; /* secondary iterator of enumeration */ |
| 9 | PyObject* en_result; /* result tuple */ |
| 10 | PyObject* en_longindex; /* index for sequences >= PY_SSIZE_T_MAX */ |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 11 | } enumobject; |
| 12 | |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 13 | static PyObject * |
| 14 | enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
| 15 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 16 | enumobject *en; |
| 17 | PyObject *seq = NULL; |
| 18 | PyObject *start = NULL; |
| 19 | static char *kwlist[] = {"sequence", "start", 0}; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 20 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 21 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:enumerate", kwlist, |
| 22 | &seq, &start)) |
| 23 | return NULL; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 24 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 25 | en = (enumobject *)type->tp_alloc(type, 0); |
| 26 | if (en == NULL) |
| 27 | return NULL; |
| 28 | if (start != NULL) { |
| 29 | start = PyNumber_Index(start); |
| 30 | if (start == NULL) { |
| 31 | Py_DECREF(en); |
| 32 | return NULL; |
| 33 | } |
| 34 | assert(PyInt_Check(start) || PyLong_Check(start)); |
| 35 | en->en_index = PyInt_AsSsize_t(start); |
| 36 | if (en->en_index == -1 && PyErr_Occurred()) { |
| 37 | PyErr_Clear(); |
| 38 | en->en_index = PY_SSIZE_T_MAX; |
| 39 | en->en_longindex = start; |
| 40 | } else { |
| 41 | en->en_longindex = NULL; |
| 42 | Py_DECREF(start); |
| 43 | } |
| 44 | } else { |
| 45 | en->en_index = 0; |
| 46 | en->en_longindex = NULL; |
| 47 | } |
| 48 | en->en_sit = PyObject_GetIter(seq); |
| 49 | if (en->en_sit == NULL) { |
| 50 | Py_DECREF(en); |
| 51 | return NULL; |
| 52 | } |
| 53 | en->en_result = PyTuple_Pack(2, Py_None, Py_None); |
| 54 | if (en->en_result == NULL) { |
| 55 | Py_DECREF(en); |
| 56 | return NULL; |
| 57 | } |
| 58 | return (PyObject *)en; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | static void |
| 62 | enum_dealloc(enumobject *en) |
| 63 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 64 | PyObject_GC_UnTrack(en); |
| 65 | Py_XDECREF(en->en_sit); |
| 66 | Py_XDECREF(en->en_result); |
| 67 | Py_XDECREF(en->en_longindex); |
| 68 | Py_TYPE(en)->tp_free(en); |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | static int |
| 72 | enum_traverse(enumobject *en, visitproc visit, void *arg) |
| 73 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 74 | Py_VISIT(en->en_sit); |
| 75 | Py_VISIT(en->en_result); |
| 76 | Py_VISIT(en->en_longindex); |
| 77 | return 0; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | static PyObject * |
Raymond Hettinger | 8f66937 | 2007-10-03 21:18:11 +0000 | [diff] [blame] | 81 | enum_next_long(enumobject *en, PyObject* next_item) |
| 82 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 83 | static PyObject *one = NULL; |
| 84 | PyObject *result = en->en_result; |
| 85 | PyObject *next_index; |
| 86 | PyObject *stepped_up; |
Raymond Hettinger | 8f66937 | 2007-10-03 21:18:11 +0000 | [diff] [blame] | 87 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 88 | if (en->en_longindex == NULL) { |
| 89 | en->en_longindex = PyInt_FromSsize_t(PY_SSIZE_T_MAX); |
| 90 | if (en->en_longindex == NULL) |
| 91 | return NULL; |
| 92 | } |
| 93 | if (one == NULL) { |
| 94 | one = PyInt_FromLong(1); |
| 95 | if (one == NULL) |
| 96 | return NULL; |
| 97 | } |
| 98 | next_index = en->en_longindex; |
| 99 | assert(next_index != NULL); |
| 100 | stepped_up = PyNumber_Add(next_index, one); |
| 101 | if (stepped_up == NULL) |
| 102 | return NULL; |
| 103 | en->en_longindex = stepped_up; |
Raymond Hettinger | 8f66937 | 2007-10-03 21:18:11 +0000 | [diff] [blame] | 104 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 105 | if (result->ob_refcnt == 1) { |
| 106 | Py_INCREF(result); |
| 107 | Py_DECREF(PyTuple_GET_ITEM(result, 0)); |
| 108 | Py_DECREF(PyTuple_GET_ITEM(result, 1)); |
| 109 | } else { |
| 110 | result = PyTuple_New(2); |
| 111 | if (result == NULL) { |
| 112 | Py_DECREF(next_index); |
| 113 | Py_DECREF(next_item); |
| 114 | return NULL; |
| 115 | } |
| 116 | } |
| 117 | PyTuple_SET_ITEM(result, 0, next_index); |
| 118 | PyTuple_SET_ITEM(result, 1, next_item); |
| 119 | return result; |
Raymond Hettinger | 8f66937 | 2007-10-03 21:18:11 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | static PyObject * |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 123 | enum_next(enumobject *en) |
| 124 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 125 | PyObject *next_index; |
| 126 | PyObject *next_item; |
| 127 | PyObject *result = en->en_result; |
| 128 | PyObject *it = en->en_sit; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 129 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 130 | next_item = (*Py_TYPE(it)->tp_iternext)(it); |
| 131 | if (next_item == NULL) |
| 132 | return NULL; |
Guido van Rossum | ca5ed5b | 2002-07-16 21:02:42 +0000 | [diff] [blame] | 133 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 134 | if (en->en_index == PY_SSIZE_T_MAX) |
| 135 | return enum_next_long(en, next_item); |
Raymond Hettinger | 8f66937 | 2007-10-03 21:18:11 +0000 | [diff] [blame] | 136 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 137 | next_index = PyInt_FromSsize_t(en->en_index); |
| 138 | if (next_index == NULL) { |
| 139 | Py_DECREF(next_item); |
| 140 | return NULL; |
| 141 | } |
| 142 | en->en_index++; |
Raymond Hettinger | e8b0f04 | 2003-05-28 14:05:34 +0000 | [diff] [blame] | 143 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 144 | if (result->ob_refcnt == 1) { |
| 145 | Py_INCREF(result); |
| 146 | Py_DECREF(PyTuple_GET_ITEM(result, 0)); |
| 147 | Py_DECREF(PyTuple_GET_ITEM(result, 1)); |
| 148 | } else { |
| 149 | result = PyTuple_New(2); |
| 150 | if (result == NULL) { |
| 151 | Py_DECREF(next_index); |
| 152 | Py_DECREF(next_item); |
| 153 | return NULL; |
| 154 | } |
| 155 | } |
| 156 | PyTuple_SET_ITEM(result, 0, next_index); |
| 157 | PyTuple_SET_ITEM(result, 1, next_item); |
| 158 | return result; |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 161 | PyDoc_STRVAR(enum_doc, |
Georg Brandl | e37049c | 2010-05-22 11:44:30 +0000 | [diff] [blame] | 162 | "enumerate(iterable[, start]) -> iterator for index, value of iterable\n" |
Jeremy Hylton | fbbe347 | 2003-04-21 20:26:25 +0000 | [diff] [blame] | 163 | "\n" |
Ezio Melotti | 8159c7a | 2009-09-25 16:10:55 +0000 | [diff] [blame] | 164 | "Return an enumerate object. iterable must be another object that supports\n" |
Jeremy Hylton | fbbe347 | 2003-04-21 20:26:25 +0000 | [diff] [blame] | 165 | "iteration. The enumerate object yields pairs containing a count (from\n" |
Georg Brandl | e37049c | 2010-05-22 11:44:30 +0000 | [diff] [blame] | 166 | "start, which defaults to zero) and a value yielded by the iterable argument.\n" |
| 167 | "enumerate is useful for obtaining an indexed list:\n" |
| 168 | " (0, seq[0]), (1, seq[1]), (2, seq[2]), ..."); |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 169 | |
| 170 | PyTypeObject PyEnum_Type = { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 171 | PyVarObject_HEAD_INIT(&PyType_Type, 0) |
| 172 | "enumerate", /* tp_name */ |
| 173 | sizeof(enumobject), /* tp_basicsize */ |
| 174 | 0, /* tp_itemsize */ |
| 175 | /* methods */ |
| 176 | (destructor)enum_dealloc, /* tp_dealloc */ |
| 177 | 0, /* tp_print */ |
| 178 | 0, /* tp_getattr */ |
| 179 | 0, /* tp_setattr */ |
| 180 | 0, /* tp_compare */ |
| 181 | 0, /* tp_repr */ |
| 182 | 0, /* tp_as_number */ |
| 183 | 0, /* tp_as_sequence */ |
| 184 | 0, /* tp_as_mapping */ |
| 185 | 0, /* tp_hash */ |
| 186 | 0, /* tp_call */ |
| 187 | 0, /* tp_str */ |
| 188 | PyObject_GenericGetAttr, /* tp_getattro */ |
| 189 | 0, /* tp_setattro */ |
| 190 | 0, /* tp_as_buffer */ |
| 191 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | |
| 192 | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
| 193 | enum_doc, /* tp_doc */ |
| 194 | (traverseproc)enum_traverse, /* tp_traverse */ |
| 195 | 0, /* tp_clear */ |
| 196 | 0, /* tp_richcompare */ |
| 197 | 0, /* tp_weaklistoffset */ |
| 198 | PyObject_SelfIter, /* tp_iter */ |
| 199 | (iternextfunc)enum_next, /* tp_iternext */ |
| 200 | 0, /* tp_methods */ |
| 201 | 0, /* tp_members */ |
| 202 | 0, /* tp_getset */ |
| 203 | 0, /* tp_base */ |
| 204 | 0, /* tp_dict */ |
| 205 | 0, /* tp_descr_get */ |
| 206 | 0, /* tp_descr_set */ |
| 207 | 0, /* tp_dictoffset */ |
| 208 | 0, /* tp_init */ |
| 209 | PyType_GenericAlloc, /* tp_alloc */ |
| 210 | enum_new, /* tp_new */ |
| 211 | PyObject_GC_Del, /* tp_free */ |
Guido van Rossum | 7dab242 | 2002-04-26 19:40:56 +0000 | [diff] [blame] | 212 | }; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 213 | |
| 214 | /* Reversed Object ***************************************************************/ |
| 215 | |
| 216 | typedef struct { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 217 | PyObject_HEAD |
| 218 | Py_ssize_t index; |
| 219 | PyObject* seq; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 220 | } reversedobject; |
| 221 | |
| 222 | static PyObject * |
| 223 | reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
| 224 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 225 | Py_ssize_t n; |
| 226 | PyObject *seq; |
| 227 | reversedobject *ro; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 228 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 229 | if (type == &PyReversed_Type && !_PyArg_NoKeywords("reversed()", kwds)) |
| 230 | return NULL; |
Georg Brandl | ecf9091 | 2008-05-16 13:24:29 +0000 | [diff] [blame] | 231 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 232 | if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq) ) |
| 233 | return NULL; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 234 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 235 | if (PyObject_HasAttrString(seq, "__reversed__")) |
| 236 | return PyObject_CallMethod(seq, "__reversed__", NULL); |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 237 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 238 | if (!PySequence_Check(seq)) { |
| 239 | PyErr_SetString(PyExc_TypeError, |
| 240 | "argument to reversed() must be a sequence"); |
| 241 | return NULL; |
| 242 | } |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 243 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 244 | n = PySequence_Size(seq); |
| 245 | if (n == -1) |
| 246 | return NULL; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 247 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 248 | ro = (reversedobject *)type->tp_alloc(type, 0); |
| 249 | if (ro == NULL) |
| 250 | return NULL; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 251 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 252 | ro->index = n-1; |
| 253 | Py_INCREF(seq); |
| 254 | ro->seq = seq; |
| 255 | return (PyObject *)ro; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | static void |
| 259 | reversed_dealloc(reversedobject *ro) |
| 260 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 261 | PyObject_GC_UnTrack(ro); |
| 262 | Py_XDECREF(ro->seq); |
| 263 | Py_TYPE(ro)->tp_free(ro); |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | static int |
| 267 | reversed_traverse(reversedobject *ro, visitproc visit, void *arg) |
| 268 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 269 | Py_VISIT(ro->seq); |
| 270 | return 0; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | static PyObject * |
| 274 | reversed_next(reversedobject *ro) |
| 275 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 276 | PyObject *item; |
| 277 | Py_ssize_t index = ro->index; |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 278 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 279 | if (index >= 0) { |
| 280 | item = PySequence_GetItem(ro->seq, index); |
| 281 | if (item != NULL) { |
| 282 | ro->index--; |
| 283 | return item; |
| 284 | } |
| 285 | if (PyErr_ExceptionMatches(PyExc_IndexError) || |
| 286 | PyErr_ExceptionMatches(PyExc_StopIteration)) |
| 287 | PyErr_Clear(); |
| 288 | } |
| 289 | ro->index = -1; |
| 290 | Py_CLEAR(ro->seq); |
| 291 | return NULL; |
Raymond Hettinger | 029dba5 | 2004-02-10 09:33:39 +0000 | [diff] [blame] | 292 | } |
| 293 | |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 294 | PyDoc_STRVAR(reversed_doc, |
Raymond Hettinger | d2afee4 | 2004-08-25 19:42:12 +0000 | [diff] [blame] | 295 | "reversed(sequence) -> reverse iterator over values of the sequence\n" |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 296 | "\n" |
| 297 | "Return a reverse iterator"); |
| 298 | |
Raymond Hettinger | 6b27cda | 2005-09-24 21:23:05 +0000 | [diff] [blame] | 299 | static PyObject * |
Raymond Hettinger | ef9bf40 | 2004-03-10 10:10:42 +0000 | [diff] [blame] | 300 | reversed_len(reversedobject *ro) |
| 301 | { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 302 | Py_ssize_t position, seqsize; |
Raymond Hettinger | 7892b1c | 2004-04-12 18:10:01 +0000 | [diff] [blame] | 303 | |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 304 | if (ro->seq == NULL) |
| 305 | return PyInt_FromLong(0); |
| 306 | seqsize = PySequence_Size(ro->seq); |
| 307 | if (seqsize == -1) |
| 308 | return NULL; |
| 309 | position = ro->index + 1; |
| 310 | return PyInt_FromSsize_t((seqsize < position) ? 0 : position); |
Raymond Hettinger | ef9bf40 | 2004-03-10 10:10:42 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Armin Rigo | f5b3e36 | 2006-02-11 21:32:43 +0000 | [diff] [blame] | 313 | PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); |
Raymond Hettinger | 6b27cda | 2005-09-24 21:23:05 +0000 | [diff] [blame] | 314 | |
| 315 | static PyMethodDef reversediter_methods[] = { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 316 | {"__length_hint__", (PyCFunction)reversed_len, METH_NOARGS, length_hint_doc}, |
| 317 | {NULL, NULL} /* sentinel */ |
Raymond Hettinger | 06353f7 | 2004-02-08 10:49:42 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 320 | PyTypeObject PyReversed_Type = { |
Antoine Pitrou | c7c96a9 | 2010-05-09 15:15:40 +0000 | [diff] [blame] | 321 | PyVarObject_HEAD_INIT(&PyType_Type, 0) |
| 322 | "reversed", /* tp_name */ |
| 323 | sizeof(reversedobject), /* tp_basicsize */ |
| 324 | 0, /* tp_itemsize */ |
| 325 | /* methods */ |
| 326 | (destructor)reversed_dealloc, /* tp_dealloc */ |
| 327 | 0, /* tp_print */ |
| 328 | 0, /* tp_getattr */ |
| 329 | 0, /* tp_setattr */ |
| 330 | 0, /* tp_compare */ |
| 331 | 0, /* tp_repr */ |
| 332 | 0, /* tp_as_number */ |
| 333 | 0, /* tp_as_sequence */ |
| 334 | 0, /* tp_as_mapping */ |
| 335 | 0, /* tp_hash */ |
| 336 | 0, /* tp_call */ |
| 337 | 0, /* tp_str */ |
| 338 | PyObject_GenericGetAttr, /* tp_getattro */ |
| 339 | 0, /* tp_setattro */ |
| 340 | 0, /* tp_as_buffer */ |
| 341 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | |
| 342 | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
| 343 | reversed_doc, /* tp_doc */ |
| 344 | (traverseproc)reversed_traverse,/* tp_traverse */ |
| 345 | 0, /* tp_clear */ |
| 346 | 0, /* tp_richcompare */ |
| 347 | 0, /* tp_weaklistoffset */ |
| 348 | PyObject_SelfIter, /* tp_iter */ |
| 349 | (iternextfunc)reversed_next, /* tp_iternext */ |
| 350 | reversediter_methods, /* tp_methods */ |
| 351 | 0, /* tp_members */ |
| 352 | 0, /* tp_getset */ |
| 353 | 0, /* tp_base */ |
| 354 | 0, /* tp_dict */ |
| 355 | 0, /* tp_descr_get */ |
| 356 | 0, /* tp_descr_set */ |
| 357 | 0, /* tp_dictoffset */ |
| 358 | 0, /* tp_init */ |
| 359 | PyType_GenericAlloc, /* tp_alloc */ |
| 360 | reversed_new, /* tp_new */ |
| 361 | PyObject_GC_Del, /* tp_free */ |
Raymond Hettinger | 85c20a4 | 2003-11-06 14:06:48 +0000 | [diff] [blame] | 362 | }; |