Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cecb27a

Browse files
committed
Patch by Mozhe Zadka, for __contains__ (overloading 'in'). This adds
a new proc type (objobjproc), a new slot sq_contains to PySequenceMethods, and a new flag Py_TPFLAGS_HAVE_SEQUENCE_IN to Py_TPFLAGS_DEFAULT. More to follow.
1 parent 84a7459 commit cecb27a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Include/object.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ typedef int (*getreadbufferproc) Py_PROTO((PyObject *, int, void **));
150150
typedef int (*getwritebufferproc) Py_PROTO((PyObject *, int, void **));
151151
typedef int (*getsegcountproc) Py_PROTO((PyObject *, int *));
152152
typedef int (*getcharbufferproc) Py_PROTO((PyObject *, int, const char **));
153+
typedef int (*objobjproc) Py_PROTO((PyObject *, PyObject *));
153154

154155
typedef struct {
155156
binaryfunc nb_add;
@@ -185,6 +186,7 @@ typedef struct {
185186
intintargfunc sq_slice;
186187
intobjargproc sq_ass_item;
187188
intintobjargproc sq_ass_slice;
189+
objobjproc sq_contains;
188190
} PySequenceMethods;
189191

190192
typedef struct {
@@ -317,7 +319,11 @@ given type object has a specified feature.
317319
/* PyBufferProcs contains bf_getcharbuffer */
318320
#define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0)
319321

320-
#define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER)
322+
/* PySequenceMethods contains sq_contains */
323+
#define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1)
324+
325+
#define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
326+
Py_TPFLAGS_HAVE_SEQUENCE_IN)
321327

322328
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
323329

0 commit comments

Comments
 (0)