1 #ifndef Py_INTERNAL_ABSTRACT_H 2 #define Py_INTERNAL_ABSTRACT_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 // Fast inlined version of PyIndex_Check() 12 static inline int _PyIndex_Check(PyObject * obj)13_PyIndex_Check(PyObject *obj) 14 { 15 PyNumberMethods *tp_as_number = Py_TYPE(obj)->tp_as_number; 16 return (tp_as_number != NULL && tp_as_number->nb_index != NULL); 17 } 18 19 PyObject *_PyNumber_PowerNoMod(PyObject *lhs, PyObject *rhs); 20 PyObject *_PyNumber_InPlacePowerNoMod(PyObject *lhs, PyObject *rhs); 21 22 extern int _PyObject_HasLen(PyObject *o); 23 24 /* === Sequence protocol ================================================ */ 25 26 #define PY_ITERSEARCH_COUNT 1 27 #define PY_ITERSEARCH_INDEX 2 28 #define PY_ITERSEARCH_CONTAINS 3 29 30 /* Iterate over seq. 31 32 Result depends on the operation: 33 34 PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if 35 error. 36 PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of 37 obj in seq; set ValueError and return -1 if none found; 38 also return -1 on error. 39 PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on 40 error. */ 41 extern Py_ssize_t _PySequence_IterSearch(PyObject *seq, 42 PyObject *obj, int operation); 43 44 /* === Mapping protocol ================================================= */ 45 46 extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); 47 48 extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); 49 50 // Convert Python int to Py_ssize_t. Do nothing if the argument is None. 51 // Export for '_bisect' shared extension. 52 PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *); 53 54 // Same as PyNumber_Index() but can return an instance of a subclass of int. 55 // Export for 'math' shared extension. 56 PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o); 57 58 #ifdef __cplusplus 59 } 60 #endif 61 #endif /* !Py_INTERNAL_ABSTRACT_H */ 62