Instructions to use dongbobo/MyAwesomeModel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dongbobo/MyAwesomeModel with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dongbobo/MyAwesomeModel")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("dongbobo/MyAwesomeModel", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use dongbobo/MyAwesomeModel with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dongbobo/MyAwesomeModel" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dongbobo/MyAwesomeModel", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/dongbobo/MyAwesomeModel
- SGLang
How to use dongbobo/MyAwesomeModel with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "dongbobo/MyAwesomeModel" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dongbobo/MyAwesomeModel", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "dongbobo/MyAwesomeModel" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dongbobo/MyAwesomeModel", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use dongbobo/MyAwesomeModel with Docker Model Runner:
docker model run hf.co/dongbobo/MyAwesomeModel
| /* Generated by Cython 3.1.2 */ | |
| /* BEGIN: Cython Metadata | |
| { | |
| "distutils": { | |
| "name": "utils.__init__", | |
| "sources": [ | |
| "utils/__init__.py" | |
| ] | |
| }, | |
| "module_name": "utils.__init__" | |
| } | |
| END: Cython Metadata */ | |
| /* InitLimitedAPI */ | |
| /* CModulePreamble */ | |
| /* For very preliminary testing purposes. Most variables are set the same as PyPy. | |
| The existence of this section does not imply that anything works or is even tested */ | |
| enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; | |
| /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 | |
| * but leads to warnings with -pedantic, since it is a C++17 feature */ | |
| template<class T> void CYTHON_UNUSED_VAR( const T& ) { } | |
| typedef unsigned char uint8_t; | |
| typedef unsigned short uint16_t; | |
| typedef unsigned int uint32_t; | |
| typedef unsigned __int8 uint8_t; | |
| typedef unsigned __int16 uint16_t; | |
| typedef unsigned __int32 uint32_t; | |
| typedef unsigned long long __pyx_uintptr_t; | |
| typedef unsigned int __pyx_uintptr_t; | |
| typedef unsigned __int64 __pyx_uintptr_t; | |
| typedef unsigned __int32 __pyx_uintptr_t; | |
| typedef uintptr_t __pyx_uintptr_t; | |
| /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 | |
| * but leads to warnings with -pedantic, since it is a C++17 feature */ | |
| template <typename T> | |
| struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; | |
| /* CInitCode */ | |
| /* PythonCompatibility */ | |
| static int CO_OPTIMIZED; | |
| static int CO_NEWLOCALS; | |
| static int CO_VARARGS; | |
| static int CO_VARKEYWORDS; | |
| static int CO_ASYNC_GENERATOR; | |
| static int CO_GENERATOR; | |
| static int CO_COROUTINE; | |
| static int __Pyx_init_co_variables(void); | |
| typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); | |
| typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, | |
| Py_ssize_t nargs, PyObject *kwnames); | |
| typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, | |
| size_t nargsf, PyObject *kwnames); | |
| static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { | |
| return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; | |
| } | |
| static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) { | |
| return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; | |
| return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; | |
| } | |
| typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); | |
| static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op) | |
| { | |
| void *result; | |
| result = PyModule_GetState(op); | |
| if (!result) | |
| Py_FatalError("Couldn't find the module state"); | |
| return result; | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { | |
| PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); | |
| if (res == NULL) PyErr_Clear(); | |
| return res; | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { | |
| return PyDict_GetItem(dict, name); | |
| PyDictEntry *ep; | |
| PyDictObject *mp = (PyDictObject*) dict; | |
| long hash = ((PyStringObject *) name)->ob_shash; | |
| assert(hash != -1); | |
| ep = (mp->ma_lookup)(mp, name, hash); | |
| if (ep == NULL) { | |
| return NULL; | |
| } | |
| return ep->me_value; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { | |
| *result = PyObject_GetItem(dict, key); | |
| if (*result == NULL) { | |
| if (PyErr_ExceptionMatches(PyExc_KeyError)) { | |
| PyErr_Clear(); | |
| return 0; | |
| } | |
| return -1; | |
| } | |
| return 1; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) { | |
| *result = PyDict_GetItemWithError(dict, key); | |
| if (*result == NULL) { | |
| return PyErr_Occurred() ? -1 : 0; | |
| } | |
| Py_INCREF(*result); | |
| return 1; | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { | |
| PyObject *module = PyImport_AddModule(name); | |
| Py_XINCREF(module); | |
| return module; | |
| } | |
| typedef enum { | |
| PYGEN_RETURN = 0, | |
| PYGEN_ERROR = -1, | |
| PYGEN_NEXT = 1, | |
| } __Pyx_PySendResult; | |
| typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result); | |
| typedef struct { | |
| unaryfunc am_await; | |
| unaryfunc am_aiter; | |
| unaryfunc am_anext; | |
| __Pyx_pyiter_sendfunc am_send; | |
| } __Pyx_PyAsyncMethodsStruct; | |
| extern "C" | |
| PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); | |
| static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) { | |
| int value; | |
| PyObject *py_value = PyObject_GetAttrString(inspect, name); | |
| if (!py_value) return 0; | |
| value = (int) PyLong_AsLong(py_value); | |
| Py_DECREF(py_value); | |
| *write_to = value; | |
| return value != -1 || !PyErr_Occurred(); | |
| } | |
| static int __Pyx_init_co_variables(void) { | |
| PyObject *inspect; | |
| int result; | |
| inspect = PyImport_ImportModule("inspect"); | |
| result = | |
| __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) && | |
| __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) && | |
| __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) && | |
| __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) && | |
| __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) && | |
| __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) && | |
| __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) && | |
| 1; | |
| Py_DECREF(inspect); | |
| return result ? 0 : -1; | |
| } | |
| static int __Pyx_init_co_variables(void) { | |
| return 0; // It's a limited API-only feature | |
| } | |
| /* MathInitCode */ | |
| static CYTHON_INLINE float __PYX_NAN() { | |
| float value; | |
| memset(&value, 0xFF, sizeof(value)); | |
| return value; | |
| } | |
| /* Early includes */ | |
| static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { | |
| return (size_t) i < (size_t) limit; | |
| } | |
| static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); | |
| static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); | |
| static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) { | |
| return Py_NewRef(obj); | |
| Py_INCREF(obj); | |
| return obj; | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) { | |
| return Py_XNewRef(obj); | |
| Py_XINCREF(obj); | |
| return obj; | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b); | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x); | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); | |
| static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t); | |
| static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); | |
| typedef Py_ssize_t __Pyx_compact_pylong; | |
| typedef size_t __Pyx_compact_upylong; | |
| typedef sdigit __Pyx_compact_pylong; | |
| typedef digit __Pyx_compact_upylong; | |
| /* Test for GCC > 2.95 */ | |
| /* PretendToInitialize */ | |
| template <typename T> | |
| static void __Pyx_pretend_to_initialize(T* ptr) { | |
| if ((std::is_trivially_default_constructible<T>::value)) | |
| *ptr = T(); | |
| (void)ptr; | |
| } | |
| static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } | |
| static PyObject *__pyx_m = NULL; | |
| static int __pyx_lineno; | |
| static int __pyx_clineno = 0; | |
| static const char * const __pyx_cfilenm = __FILE__; | |
| static const char *__pyx_filename; | |
| /* #### Code section: filename_table ### */ | |
| static const char* const __pyx_f[] = { | |
| "utils/__init__.py", | |
| }; | |
| /* #### Code section: utility_code_proto_before_types ### */ | |
| /* CriticalSections.proto */ | |
| /* Atomics.proto */ | |
| static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { | |
| __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired); | |
| int result = old == *expected; | |
| *expected = old; | |
| return result; | |
| } | |
| static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) { | |
| __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected); | |
| int result = old == *expected; | |
| *expected = old; | |
| return result; | |
| } | |
| /* #### Code section: numeric_typedefs ### */ | |
| /* #### Code section: complex_type_declarations ### */ | |
| /* #### Code section: type_declarations ### */ | |
| /*--- Type declarations ---*/ | |
| /* #### Code section: utility_code_proto ### */ | |
| /* --- Runtime support code (head) --- */ | |
| /* Refnanny.proto */ | |
| typedef struct { | |
| void (*INCREF)(void*, PyObject*, Py_ssize_t); | |
| void (*DECREF)(void*, PyObject*, Py_ssize_t); | |
| void (*GOTREF)(void*, PyObject*, Py_ssize_t); | |
| void (*GIVEREF)(void*, PyObject*, Py_ssize_t); | |
| void* (*SetupContext)(const char*, Py_ssize_t, const char*); | |
| void (*FinishContext)(void**); | |
| } __Pyx_RefNannyAPIStruct; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); | |
| /* SetPackagePathFromImportLib.proto */ | |
| static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name); | |
| /* PyDictVersioning.proto */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); | |
| /* PyErrExceptionMatches.proto */ | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); | |
| /* PyThreadStateGet.proto */ | |
| /* PyErrFetchRestore.proto */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); | |
| /* PyObjectGetAttrStr.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); | |
| /* PyObjectGetAttrStrNoError.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); | |
| /* CLineInTraceback.proto */ | |
| static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); | |
| /* CodeObjectCache.proto */ | |
| typedef PyObject __Pyx_CachedCodeObjectType; | |
| typedef PyCodeObject __Pyx_CachedCodeObjectType; | |
| typedef struct { | |
| __Pyx_CachedCodeObjectType* code_object; | |
| int code_line; | |
| } __Pyx_CodeObjectCacheEntry; | |
| struct __Pyx_CodeObjectCache { | |
| int count; | |
| int max_count; | |
| __Pyx_CodeObjectCacheEntry* entries; | |
| __pyx_atomic_int_type accessor_count; | |
| }; | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); | |
| static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line); | |
| static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object); | |
| /* AddTraceback.proto */ | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename); | |
| /* FormatTypeName.proto */ | |
| typedef PyObject *__Pyx_TypeName; | |
| static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp); | |
| typedef const char *__Pyx_TypeName; | |
| /* GCCDiagnostics.proto */ | |
| /* PyFunctionFastCall.proto */ | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs, PyObject *kwargs); | |
| static size_t __pyx_pyframe_localsplus_offset = 0; | |
| /* PyObjectCall.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); | |
| /* PyObjectCallMethO.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); | |
| /* PyObjectFastCall.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs); | |
| /* PyObjectVectorCallKwBuilder.proto */ | |
| CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); | |
| static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); | |
| static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); | |
| /* CIntToPy.proto */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *); | |
| /* CIntFromPy.proto */ | |
| static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *); | |
| /* FastTypeChecks.proto */ | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); | |
| static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) { | |
| return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2); | |
| } | |
| /* GetRuntimeVersion.proto */ | |
| static unsigned long __Pyx_get_runtime_version(void); | |
| /* CheckBinaryVersion.proto */ | |
| static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); | |
| /* MultiPhaseInitModuleState.proto */ | |
| static PyObject *__Pyx_State_FindModule(void*); | |
| static int __Pyx_State_AddModule(PyObject* module, void*); | |
| static int __Pyx_State_RemoveModule(void*); | |
| /* #### Code section: module_declarations ### */ | |
| /* CythonABIVersion.proto */ | |
| /* Module declarations from "utils" */ | |
| /* #### Code section: typeinfo ### */ | |
| /* #### Code section: before_global_var ### */ | |
| extern int __pyx_module_is_main_utils____init__; | |
| int __pyx_module_is_main_utils____init__ = 0; | |
| /* Implementation of "utils" */ | |
| /* #### Code section: global_var ### */ | |
| /* #### Code section: string_decls ### */ | |
| static const char __pyx_k_[] = "?"; | |
| static const char __pyx_k_main[] = "__main__"; | |
| static const char __pyx_k_name[] = "__name__"; | |
| static const char __pyx_k_test[] = "__test__"; | |
| static const char __pyx_k_module[] = "__module__"; | |
| static const char __pyx_k_qualname[] = "__qualname__"; | |
| static const char __pyx_k_utils___init[] = "utils.__init__"; | |
| static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; | |
| /* #### Code section: decls ### */ | |
| /* #### Code section: late_includes ### */ | |
| /* #### Code section: module_state ### */ | |
| /* SmallCodeConfig */ | |
| typedef struct { | |
| PyObject *__pyx_d; | |
| PyObject *__pyx_b; | |
| PyObject *__pyx_cython_runtime; | |
| PyObject *__pyx_empty_tuple; | |
| PyObject *__pyx_empty_bytes; | |
| PyObject *__pyx_empty_unicode; | |
| PyTypeObject *__pyx_CyFunctionType; | |
| PyTypeObject *__pyx_FusedFunctionType; | |
| PyTypeObject *__pyx_GeneratorType; | |
| PyTypeObject *__pyx_IterableCoroutineType; | |
| PyTypeObject *__pyx_CoroutineAwaitType; | |
| PyTypeObject *__pyx_CoroutineType; | |
| PyObject *__pyx_string_tab[8]; | |
| /* #### Code section: module_state_contents ### */ | |
| /* CodeObjectCache.module_state_decls */ | |
| struct __Pyx_CodeObjectCache __pyx_code_cache; | |
| /* #### Code section: module_state_end ### */ | |
| } __pyx_mstatetype; | |
| namespace { | |
| extern struct PyModuleDef __pyx_moduledef; | |
| } /* anonymous namespace */ | |
| static struct PyModuleDef __pyx_moduledef; | |
| static __pyx_mstatetype __pyx_mstate_global_static = | |
| {}; | |
| {0}; | |
| static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static; | |
| /* #### Code section: constant_name_defines ### */ | |
| /* #### Code section: module_state_clear ### */ | |
| static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) { | |
| __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m); | |
| if (!clear_module_state) return 0; | |
| Py_CLEAR(clear_module_state->__pyx_d); | |
| Py_CLEAR(clear_module_state->__pyx_b); | |
| Py_CLEAR(clear_module_state->__pyx_cython_runtime); | |
| Py_CLEAR(clear_module_state->__pyx_empty_tuple); | |
| Py_CLEAR(clear_module_state->__pyx_empty_bytes); | |
| Py_CLEAR(clear_module_state->__pyx_empty_unicode); | |
| Py_CLEAR(clear_module_state->__pyx_CyFunctionType); | |
| Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); | |
| __Pyx_State_RemoveModule(NULL); | |
| for (int i=0; i<8; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); } | |
| return 0; | |
| } | |
| /* #### Code section: module_state_traverse ### */ | |
| static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { | |
| __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m); | |
| if (!traverse_module_state) return 0; | |
| Py_VISIT(traverse_module_state->__pyx_d); | |
| Py_VISIT(traverse_module_state->__pyx_b); | |
| Py_VISIT(traverse_module_state->__pyx_cython_runtime); | |
| __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple); | |
| __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes); | |
| __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode); | |
| Py_VISIT(traverse_module_state->__pyx_CyFunctionType); | |
| Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); | |
| for (int i=0; i<8; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); } | |
| return 0; | |
| } | |
| /* #### Code section: module_code ### */ | |
| /* #### Code section: module_exttypes ### */ | |
| static PyMethodDef __pyx_methods[] = { | |
| {0, 0, 0, 0} | |
| }; | |
| /* #### Code section: initfunc_declarations ### */ | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/ | |
| /* #### Code section: init_module ### */ | |
| static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); | |
| /*--- Global init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); | |
| /*--- Variable export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); | |
| /*--- Function export code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); | |
| /*--- Type init code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); | |
| /*--- Type import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); | |
| /*--- Variable import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); | |
| /*--- Function import code ---*/ | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ | |
| static int __pyx_pymod_exec_utils(PyObject* module); /*proto*/ | |
| static PyModuleDef_Slot __pyx_moduledef_slots[] = { | |
| {Py_mod_create, (void*)__pyx_pymod_create}, | |
| {Py_mod_exec, (void*)__pyx_pymod_exec_utils}, | |
| {Py_mod_gil, Py_MOD_GIL_USED}, | |
| {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED}, | |
| {0, NULL} | |
| }; | |
| namespace { | |
| struct PyModuleDef __pyx_moduledef = | |
| static struct PyModuleDef __pyx_moduledef = | |
| { | |
| PyModuleDef_HEAD_INIT, | |
| "utils", | |
| 0, /* m_doc */ | |
| sizeof(__pyx_mstatetype), /* m_size */ | |
| (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */ | |
| __pyx_methods /* m_methods */, | |
| __pyx_moduledef_slots, /* m_slots */ | |
| NULL, /* m_reload */ | |
| __pyx_m_traverse, /* m_traverse */ | |
| __pyx_m_clear, /* m_clear */ | |
| NULL /* m_free */ | |
| NULL, /* m_traverse */ | |
| NULL, /* m_clear */ | |
| NULL /* m_free */ | |
| }; | |
| } /* anonymous namespace */ | |
| /* PyModInitFuncType */ | |
| __Pyx_PyMODINIT_FUNC PyInit_utils(void) CYTHON_SMALL_CODE; /*proto*/ | |
| __Pyx_PyMODINIT_FUNC PyInit___init__(void) { return PyInit_utils(); } | |
| __Pyx_PyMODINIT_FUNC PyInit_utils(void) | |
| { | |
| return PyModuleDef_Init(&__pyx_moduledef); | |
| } | |
| /* ModuleCreationPEP489 */ | |
| static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) { | |
| { | |
| PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think | |
| if (!module) { | |
| PyErr_Clear(); // just try the 3.8-3.12 version | |
| module = PyImport_ImportModule("_xxsubinterpreters"); | |
| if (!module) goto bad; | |
| } | |
| PyObject *current = PyObject_CallMethod(module, "get_current", NULL); | |
| Py_DECREF(module); | |
| if (!current) goto bad; | |
| if (PyTuple_Check(current)) { | |
| PyObject *new_current = PySequence_GetItem(current, 0); | |
| Py_DECREF(current); | |
| current = new_current; | |
| if (!new_current) goto bad; | |
| } | |
| long long as_c_int = PyLong_AsLongLong(current); | |
| Py_DECREF(current); | |
| return as_c_int; | |
| } | |
| bad: | |
| PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n"); | |
| return -1; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { | |
| static PY_INT64_T main_interpreter_id = -1; | |
| PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get()); | |
| PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get()); | |
| PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId(); | |
| PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); | |
| if (unlikely(current_id == -1)) { | |
| return -1; | |
| } | |
| if (main_interpreter_id == -1) { | |
| main_interpreter_id = current_id; | |
| return 0; | |
| } else if (unlikely(main_interpreter_id != current_id)) { | |
| PyErr_SetString( | |
| PyExc_ImportError, | |
| "Interpreter change detected - this module can only be loaded into one interpreter per process."); | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) | |
| { | |
| PyObject *value = PyObject_GetAttrString(spec, from_name); | |
| int result = 0; | |
| if (likely(value)) { | |
| if (allow_none || value != Py_None) { | |
| result = PyDict_SetItemString(moddict, to_name, value); | |
| } | |
| Py_DECREF(value); | |
| } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { | |
| PyErr_Clear(); | |
| } else { | |
| result = -1; | |
| } | |
| return result; | |
| } | |
| static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { | |
| PyObject *module = NULL, *moddict, *modname; | |
| CYTHON_UNUSED_VAR(def); | |
| if (__Pyx_check_single_interpreter()) | |
| return NULL; | |
| if (__pyx_m) | |
| return __Pyx_NewRef(__pyx_m); | |
| modname = PyObject_GetAttrString(spec, "name"); | |
| if (unlikely(!modname)) goto bad; | |
| module = PyModule_NewObject(modname); | |
| Py_DECREF(modname); | |
| if (unlikely(!module)) goto bad; | |
| moddict = PyModule_GetDict(module); | |
| if (unlikely(!moddict)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; | |
| if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; | |
| return module; | |
| bad: | |
| Py_XDECREF(module); | |
| return NULL; | |
| } | |
| static CYTHON_SMALL_CODE int __pyx_pymod_exec_utils(PyObject *__pyx_pyinit_module) | |
| { | |
| int stringtab_initialized = 0; | |
| int pystate_addmodule_run = 0; | |
| __pyx_mstatetype *__pyx_mstate = NULL; | |
| PyObject *__pyx_t_1 = NULL; | |
| PyObject *__pyx_t_2 = NULL; | |
| int __pyx_lineno = 0; | |
| const char *__pyx_filename = NULL; | |
| int __pyx_clineno = 0; | |
| __Pyx_RefNannyDeclarations | |
| if (__pyx_m) { | |
| if (__pyx_m == __pyx_pyinit_module) return 0; | |
| PyErr_SetString(PyExc_RuntimeError, "Module 'utils' has already been imported. Re-initialisation is not supported."); | |
| return -1; | |
| } | |
| if (__pyx_m) return __Pyx_NewRef(__pyx_m); | |
| /*--- Module creation code ---*/ | |
| __pyx_t_1 = __pyx_pyinit_module; | |
| Py_INCREF(__pyx_t_1); | |
| __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| { | |
| int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef); | |
| __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "utils" pseudovariable */ | |
| if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) | |
| pystate_addmodule_run = 1; | |
| } | |
| __pyx_m = __pyx_t_1; | |
| PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED); | |
| __pyx_mstate = __pyx_mstate_global; | |
| CYTHON_UNUSED_VAR(__pyx_t_1); | |
| __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| Py_INCREF(__pyx_mstate->__pyx_d); | |
| __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /* ImportRefnannyAPI */ | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); | |
| if (!__Pyx_RefNanny) { | |
| PyErr_Clear(); | |
| __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); | |
| if (!__Pyx_RefNanny) | |
| Py_FatalError("failed to import 'refnanny' module"); | |
| } | |
| __Pyx_RefNannySetupContext("PyInit_utils", 0); | |
| if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pxy_PyFrame_Initialize_Offsets(); | |
| __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Initialize various global constants etc. ---*/ | |
| if (__Pyx_InitConstants(__pyx_mstate) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| stringtab_initialized = 1; | |
| if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_CommonTypesMetaclass_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Library function declarations ---*/ | |
| if (__pyx_module_is_main_utils____init__) { | |
| if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| if (!CYTHON_PEP489_MULTI_PHASE_INIT) { | |
| if (unlikely((__Pyx_SetPackagePathFromImportLib(__pyx_mstate_global->__pyx_kp_u_utils___init) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| { | |
| PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (!PyDict_GetItemString(modules, "utils")) { | |
| if (unlikely((PyDict_SetItemString(modules, "utils", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) | |
| } | |
| } | |
| /*--- Builtin init code ---*/ | |
| if (__Pyx_InitCachedBuiltins(__pyx_mstate) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Constants init code ---*/ | |
| if (__Pyx_InitCachedConstants(__pyx_mstate) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| if (__Pyx_CreateCodeObjects(__pyx_mstate) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| /*--- Global type/function init code ---*/ | |
| (void)__Pyx_modinit_global_init_code(__pyx_mstate); | |
| (void)__Pyx_modinit_variable_export_code(__pyx_mstate); | |
| (void)__Pyx_modinit_function_export_code(__pyx_mstate); | |
| (void)__Pyx_modinit_type_init_code(__pyx_mstate); | |
| (void)__Pyx_modinit_type_import_code(__pyx_mstate); | |
| (void)__Pyx_modinit_variable_import_code(__pyx_mstate); | |
| (void)__Pyx_modinit_function_import_code(__pyx_mstate); | |
| /*--- Execution code ---*/ | |
| /* "utils/__init__.py":1 | |
| * # Evaluation utilities package # <<<<<<<<<<<<<< | |
| */ | |
| __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_GOTREF(__pyx_t_2); | |
| if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) | |
| __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; | |
| /*--- Wrapped vars code ---*/ | |
| goto __pyx_L0; | |
| __pyx_L1_error:; | |
| __Pyx_XDECREF(__pyx_t_2); | |
| if (__pyx_m) { | |
| if (__pyx_mstate->__pyx_d && stringtab_initialized) { | |
| __Pyx_AddTraceback("init utils", __pyx_clineno, __pyx_lineno, __pyx_filename); | |
| } | |
| Py_CLEAR(__pyx_m); | |
| Py_DECREF(__pyx_m); | |
| if (pystate_addmodule_run) { | |
| PyObject *tp, *value, *tb; | |
| PyErr_Fetch(&tp, &value, &tb); | |
| PyState_RemoveModule(&__pyx_moduledef); | |
| PyErr_Restore(tp, value, tb); | |
| } | |
| } else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_ImportError, "init utils"); | |
| } | |
| __pyx_L0:; | |
| __Pyx_RefNannyFinishContext(); | |
| return (__pyx_m != NULL) ? 0 : -1; | |
| return __pyx_m; | |
| } | |
| /* #### Code section: pystring_table ### */ | |
| typedef struct { | |
| const char *s; | |
| const unsigned short n; | |
| const unsigned int n; | |
| const unsigned long n; | |
| const Py_ssize_t n; | |
| const unsigned int encoding : 5; | |
| const unsigned char encoding; | |
| const unsigned short encoding; | |
| const Py_ssize_t encoding; | |
| const unsigned int is_unicode : 1; | |
| const unsigned int intern : 1; | |
| } __Pyx_StringTabEntry; | |
| static const char * const __pyx_string_tab_encodings[] = { 0 }; | |
| static const __Pyx_StringTabEntry __pyx_string_tab[] = { | |
| {__pyx_k_, sizeof(__pyx_k_), 0, 1, 0}, /* PyObject cname: __pyx_kp_u_ */ | |
| {__pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 1, 1}, /* PyObject cname: __pyx_n_u_cline_in_traceback */ | |
| {__pyx_k_main, sizeof(__pyx_k_main), 0, 1, 1}, /* PyObject cname: __pyx_n_u_main */ | |
| {__pyx_k_module, sizeof(__pyx_k_module), 0, 1, 1}, /* PyObject cname: __pyx_n_u_module */ | |
| {__pyx_k_name, sizeof(__pyx_k_name), 0, 1, 1}, /* PyObject cname: __pyx_n_u_name */ | |
| {__pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 1, 1}, /* PyObject cname: __pyx_n_u_qualname */ | |
| {__pyx_k_test, sizeof(__pyx_k_test), 0, 1, 1}, /* PyObject cname: __pyx_n_u_test */ | |
| {__pyx_k_utils___init, sizeof(__pyx_k_utils___init), 0, 1, 0}, /* PyObject cname: __pyx_kp_u_utils___init */ | |
| {0, 0, 0, 0, 0} | |
| }; | |
| /* InitStrings.proto */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry const *t, PyObject **target, const char* const* encoding_names); | |
| /* #### Code section: cached_builtins ### */ | |
| static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) { | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| return 0; | |
| } | |
| /* #### Code section: cached_constants ### */ | |
| static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) { | |
| __Pyx_RefNannyDeclarations | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); | |
| __Pyx_RefNannyFinishContext(); | |
| return 0; | |
| } | |
| /* #### Code section: init_constants ### */ | |
| static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) { | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| if (__Pyx_InitStrings(__pyx_string_tab, __pyx_mstate->__pyx_string_tab, __pyx_string_tab_encodings) < 0) __PYX_ERR(0, 1, __pyx_L1_error); | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| /* #### Code section: init_codeobjects ### */ | |
| static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) { | |
| CYTHON_UNUSED_VAR(__pyx_mstate); | |
| return 0; | |
| } | |
| /* #### Code section: init_globals ### */ | |
| static int __Pyx_InitGlobals(void) { | |
| /* PythonCompatibility.init */ | |
| if (likely(__Pyx_init_co_variables() == 0)); else | |
| if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) | |
| return 0; | |
| __pyx_L1_error:; | |
| return -1; | |
| } | |
| /* #### Code section: cleanup_globals ### */ | |
| /* #### Code section: cleanup_module ### */ | |
| /* #### Code section: main_method ### */ | |
| /* #### Code section: utility_code_pragmas ### */ | |
| /* Warning 4127: conditional expression is constant | |
| * Cython uses constant conditional expressions to allow in inline functions to be optimized at | |
| * compile-time, so this warning is not useful | |
| */ | |
| /* #### Code section: utility_code_def ### */ | |
| /* --- Runtime support code --- */ | |
| /* Refnanny */ | |
| static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { | |
| PyObject *m = NULL, *p = NULL; | |
| void *r = NULL; | |
| m = PyImport_ImportModule(modname); | |
| if (!m) goto end; | |
| p = PyObject_GetAttrString(m, "RefNannyAPI"); | |
| if (!p) goto end; | |
| r = PyLong_AsVoidPtr(p); | |
| end: | |
| Py_XDECREF(p); | |
| Py_XDECREF(m); | |
| return (__Pyx_RefNannyAPIStruct *)r; | |
| } | |
| /* SetPackagePathFromImportLib */ | |
| static int __Pyx_SetPackagePathFromImportLib(PyObject *module_name) { | |
| PyObject *importlib, *osmod, *ossep, *parts, *package_path; | |
| PyObject *file_path = NULL; | |
| PyObject *item; | |
| int result; | |
| PyObject *spec; | |
| importlib = PyImport_ImportModule("importlib.util"); | |
| if (unlikely(!importlib)) | |
| goto bad; | |
| spec = PyObject_CallMethod(importlib, "find_spec", "(O)", module_name); | |
| Py_DECREF(importlib); | |
| if (unlikely(!spec)) | |
| goto bad; | |
| file_path = PyObject_GetAttrString(spec, "origin"); | |
| Py_DECREF(spec); | |
| if (unlikely(!file_path)) | |
| goto bad; | |
| if (unlikely(PyObject_SetAttrString(__pyx_m, "__file__", file_path) < 0)) | |
| goto bad; | |
| osmod = PyImport_ImportModule("os"); | |
| if (unlikely(!osmod)) | |
| goto bad; | |
| ossep = PyObject_GetAttrString(osmod, "sep"); | |
| Py_DECREF(osmod); | |
| if (unlikely(!ossep)) | |
| goto bad; | |
| parts = PyObject_CallMethod(file_path, "rsplit", "(Oi)", ossep, 1); | |
| Py_DECREF(file_path); file_path = NULL; | |
| Py_DECREF(ossep); | |
| if (unlikely(!parts)) | |
| goto bad; | |
| package_path = Py_BuildValue("[O]", PyList_GET_ITEM(parts, 0)); | |
| item = PyList_GetItem(parts, 0); | |
| if (unlikely(!item)) | |
| goto bad; | |
| package_path = Py_BuildValue("[O]", item); | |
| Py_DECREF(parts); | |
| if (unlikely(!package_path)) | |
| goto bad; | |
| goto set_path; | |
| bad: | |
| PyErr_WriteUnraisable(module_name); | |
| Py_XDECREF(file_path); | |
| PyErr_Clear(); | |
| package_path = PyList_New(0); | |
| if (unlikely(!package_path)) | |
| return -1; | |
| set_path: | |
| result = PyObject_SetAttrString(__pyx_m, "__path__", package_path); | |
| Py_DECREF(package_path); | |
| return result; | |
| } | |
| /* PyDictVersioning */ | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; | |
| } | |
| static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { | |
| PyObject **dictptr = NULL; | |
| Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; | |
| if (offset) { | |
| dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); | |
| dictptr = _PyObject_GetDictPtr(obj); | |
| } | |
| return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { | |
| PyObject *dict = Py_TYPE(obj)->tp_dict; | |
| if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) | |
| return 0; | |
| return obj_dict_version == __Pyx_get_object_dict_version(obj); | |
| } | |
| /* PyErrExceptionMatches */ | |
| static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(tuple); | |
| for (i=0; i<n; i++) { | |
| if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; | |
| } | |
| for (i=0; i<n; i++) { | |
| if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { | |
| int result; | |
| PyObject *exc_type; | |
| PyObject *current_exception = tstate->current_exception; | |
| if (unlikely(!current_exception)) return 0; | |
| exc_type = (PyObject*) Py_TYPE(current_exception); | |
| if (exc_type == err) return 1; | |
| exc_type = tstate->curexc_type; | |
| if (exc_type == err) return 1; | |
| if (unlikely(!exc_type)) return 0; | |
| Py_INCREF(exc_type); | |
| if (unlikely(PyTuple_Check(err))) { | |
| result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); | |
| } else { | |
| result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); | |
| } | |
| Py_DECREF(exc_type); | |
| return result; | |
| } | |
| /* PyErrFetchRestore */ | |
| static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { | |
| PyObject *tmp_value; | |
| assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); | |
| if (value) { | |
| if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) | |
| PyException_SetTraceback(value, tb); | |
| } | |
| tmp_value = tstate->current_exception; | |
| tstate->current_exception = value; | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(type); | |
| Py_XDECREF(tb); | |
| PyObject *tmp_type, *tmp_value, *tmp_tb; | |
| tmp_type = tstate->curexc_type; | |
| tmp_value = tstate->curexc_value; | |
| tmp_tb = tstate->curexc_traceback; | |
| tstate->curexc_type = type; | |
| tstate->curexc_value = value; | |
| tstate->curexc_traceback = tb; | |
| Py_XDECREF(tmp_type); | |
| Py_XDECREF(tmp_value); | |
| Py_XDECREF(tmp_tb); | |
| } | |
| static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { | |
| PyObject* exc_value; | |
| exc_value = tstate->current_exception; | |
| tstate->current_exception = 0; | |
| *value = exc_value; | |
| *type = NULL; | |
| *tb = NULL; | |
| if (exc_value) { | |
| *type = (PyObject*) Py_TYPE(exc_value); | |
| Py_INCREF(*type); | |
| *tb = ((PyBaseExceptionObject*) exc_value)->traceback; | |
| Py_XINCREF(*tb); | |
| *tb = PyException_GetTraceback(exc_value); | |
| } | |
| *type = tstate->curexc_type; | |
| *value = tstate->curexc_value; | |
| *tb = tstate->curexc_traceback; | |
| tstate->curexc_type = 0; | |
| tstate->curexc_value = 0; | |
| tstate->curexc_traceback = 0; | |
| } | |
| /* PyObjectGetAttrStr */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { | |
| PyTypeObject* tp = Py_TYPE(obj); | |
| if (likely(tp->tp_getattro)) | |
| return tp->tp_getattro(obj, attr_name); | |
| return PyObject_GetAttr(obj, attr_name); | |
| } | |
| /* PyObjectGetAttrStrNoError */ | |
| static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { | |
| __Pyx_PyThreadState_declare | |
| __Pyx_PyThreadState_assign | |
| if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) | |
| __Pyx_PyErr_Clear(); | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { | |
| PyObject *result; | |
| (void) PyObject_GetOptionalAttr(obj, attr_name, &result); | |
| return result; | |
| PyTypeObject* tp = Py_TYPE(obj); | |
| if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { | |
| return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); | |
| } | |
| result = __Pyx_PyObject_GetAttrStr(obj, attr_name); | |
| if (unlikely(!result)) { | |
| __Pyx_PyObject_GetAttrStr_ClearAttributeError(); | |
| } | |
| return result; | |
| } | |
| /* CLineInTraceback */ | |
| static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { | |
| PyObject *use_cline; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| PyObject **cython_runtime_dict; | |
| CYTHON_MAYBE_UNUSED_VAR(tstate); | |
| if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) { | |
| return c_line; | |
| } | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| cython_runtime_dict = _PyObject_GetDictPtr(__pyx_mstate_global->__pyx_cython_runtime); | |
| if (likely(cython_runtime_dict)) { | |
| __Pyx_BEGIN_CRITICAL_SECTION(*cython_runtime_dict); | |
| __PYX_PY_DICT_LOOKUP_IF_MODIFIED( | |
| use_cline, *cython_runtime_dict, | |
| __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback)) | |
| Py_XINCREF(use_cline); | |
| __Pyx_END_CRITICAL_SECTION(); | |
| } else | |
| { | |
| PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_cython_runtime, __pyx_mstate_global->__pyx_n_u_cline_in_traceback); | |
| if (use_cline_obj) { | |
| use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; | |
| Py_INCREF(use_cline); | |
| Py_DECREF(use_cline_obj); | |
| } else { | |
| PyErr_Clear(); | |
| use_cline = NULL; | |
| } | |
| } | |
| if (!use_cline) { | |
| c_line = 0; | |
| (void) PyObject_SetAttr(__pyx_mstate_global->__pyx_cython_runtime, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False); | |
| } | |
| else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { | |
| c_line = 0; | |
| } | |
| Py_XDECREF(use_cline); | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| return c_line; | |
| } | |
| /* CodeObjectCache */ | |
| static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { | |
| int start = 0, mid = 0, end = count - 1; | |
| if (end >= 0 && code_line > entries[end].code_line) { | |
| return count; | |
| } | |
| while (start < end) { | |
| mid = start + (end - start) / 2; | |
| if (code_line < entries[mid].code_line) { | |
| end = mid; | |
| } else if (code_line > entries[mid].code_line) { | |
| start = mid + 1; | |
| } else { | |
| return mid; | |
| } | |
| } | |
| if (code_line <= entries[mid].code_line) { | |
| return mid; | |
| } else { | |
| return mid + 1; | |
| } | |
| } | |
| static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) { | |
| __Pyx_CachedCodeObjectType* code_object; | |
| int pos; | |
| if (unlikely(!code_line) || unlikely(!code_cache->entries)) { | |
| return NULL; | |
| } | |
| pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); | |
| if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) { | |
| return NULL; | |
| } | |
| code_object = code_cache->entries[pos].code_object; | |
| Py_INCREF(code_object); | |
| return code_object; | |
| } | |
| static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) { | |
| (void)__pyx__find_code_object; | |
| return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss. | |
| struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; | |
| __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count); | |
| if (old_count < 0) { | |
| __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); | |
| return NULL; | |
| } | |
| __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line); | |
| __pyx_atomic_decr_acq_rel(&code_cache->accessor_count); | |
| return result; | |
| } | |
| static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object) | |
| { | |
| int pos, i; | |
| __Pyx_CodeObjectCacheEntry* entries = code_cache->entries; | |
| if (unlikely(!code_line)) { | |
| return; | |
| } | |
| if (unlikely(!entries)) { | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (likely(entries)) { | |
| code_cache->entries = entries; | |
| code_cache->max_count = 64; | |
| code_cache->count = 1; | |
| entries[0].code_line = code_line; | |
| entries[0].code_object = code_object; | |
| Py_INCREF(code_object); | |
| } | |
| return; | |
| } | |
| pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line); | |
| if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) { | |
| __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object; | |
| entries[pos].code_object = code_object; | |
| Py_INCREF(code_object); | |
| Py_DECREF(tmp); | |
| return; | |
| } | |
| if (code_cache->count == code_cache->max_count) { | |
| int new_max = code_cache->max_count + 64; | |
| entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( | |
| code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); | |
| if (unlikely(!entries)) { | |
| return; | |
| } | |
| code_cache->entries = entries; | |
| code_cache->max_count = new_max; | |
| } | |
| for (i=code_cache->count; i>pos; i--) { | |
| entries[i] = entries[i-1]; | |
| } | |
| entries[pos].code_line = code_line; | |
| entries[pos].code_object = code_object; | |
| code_cache->count++; | |
| Py_INCREF(code_object); | |
| } | |
| static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) { | |
| (void)__pyx__insert_code_object; | |
| return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail. | |
| struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache; | |
| __pyx_nonatomic_int_type expected = 0; | |
| if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) { | |
| return; | |
| } | |
| __pyx__insert_code_object(code_cache, code_line, code_object); | |
| __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN); | |
| } | |
| /* AddTraceback */ | |
| static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, | |
| PyObject *firstlineno, PyObject *name) { | |
| PyObject *replace = NULL; | |
| if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; | |
| if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; | |
| replace = PyObject_GetAttrString(code, "replace"); | |
| if (likely(replace)) { | |
| PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict); | |
| Py_DECREF(replace); | |
| return result; | |
| } | |
| PyErr_Clear(); | |
| return NULL; | |
| } | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; | |
| PyObject *replace = NULL, *getframe = NULL, *frame = NULL; | |
| PyObject *exc_type, *exc_value, *exc_traceback; | |
| int success = 0; | |
| if (c_line) { | |
| (void) __pyx_cfilenm; | |
| (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); | |
| } | |
| PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); | |
| code_object = __pyx_find_code_object(c_line ? -c_line : py_line); | |
| if (!code_object) { | |
| code_object = Py_CompileString("_getframe()", filename, Py_eval_input); | |
| if (unlikely(!code_object)) goto bad; | |
| py_py_line = PyLong_FromLong(py_line); | |
| if (unlikely(!py_py_line)) goto bad; | |
| py_funcname = PyUnicode_FromString(funcname); | |
| if (unlikely(!py_funcname)) goto bad; | |
| dict = PyDict_New(); | |
| if (unlikely(!dict)) goto bad; | |
| { | |
| PyObject *old_code_object = code_object; | |
| code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); | |
| Py_DECREF(old_code_object); | |
| } | |
| if (unlikely(!code_object)) goto bad; | |
| __pyx_insert_code_object(c_line ? -c_line : py_line, code_object); | |
| } else { | |
| dict = PyDict_New(); | |
| } | |
| getframe = PySys_GetObject("_getframe"); | |
| if (unlikely(!getframe)) goto bad; | |
| if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; | |
| frame = PyEval_EvalCode(code_object, dict, dict); | |
| if (unlikely(!frame) || frame == Py_None) goto bad; | |
| success = 1; | |
| bad: | |
| PyErr_Restore(exc_type, exc_value, exc_traceback); | |
| Py_XDECREF(code_object); | |
| Py_XDECREF(py_py_line); | |
| Py_XDECREF(py_funcname); | |
| Py_XDECREF(dict); | |
| Py_XDECREF(replace); | |
| if (success) { | |
| PyTraceBack_Here( | |
| (struct _frame*)frame); | |
| } | |
| Py_XDECREF(frame); | |
| } | |
| static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( | |
| const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = NULL; | |
| PyObject *py_funcname = NULL; | |
| if (c_line) { | |
| py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); | |
| if (!py_funcname) goto bad; | |
| funcname = PyUnicode_AsUTF8(py_funcname); | |
| if (!funcname) goto bad; | |
| } | |
| py_code = PyCode_NewEmpty(filename, funcname, py_line); | |
| Py_XDECREF(py_funcname); | |
| return py_code; | |
| bad: | |
| Py_XDECREF(py_funcname); | |
| return NULL; | |
| } | |
| static void __Pyx_AddTraceback(const char *funcname, int c_line, | |
| int py_line, const char *filename) { | |
| PyCodeObject *py_code = 0; | |
| PyFrameObject *py_frame = 0; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject *ptype, *pvalue, *ptraceback; | |
| if (c_line) { | |
| c_line = __Pyx_CLineForTraceback(tstate, c_line); | |
| } | |
| py_code = __pyx_find_code_object(c_line ? -c_line : py_line); | |
| if (!py_code) { | |
| __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); | |
| py_code = __Pyx_CreateCodeObjectForTraceback( | |
| funcname, c_line, py_line, filename); | |
| if (!py_code) { | |
| /* If the code object creation fails, then we should clear the | |
| fetched exception references and propagate the new exception */ | |
| Py_XDECREF(ptype); | |
| Py_XDECREF(pvalue); | |
| Py_XDECREF(ptraceback); | |
| goto bad; | |
| } | |
| __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); | |
| __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); | |
| } | |
| py_frame = PyFrame_New( | |
| tstate, /*PyThreadState *tstate,*/ | |
| py_code, /*PyCodeObject *code,*/ | |
| __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/ | |
| 0 /*PyObject *locals*/ | |
| ); | |
| if (!py_frame) goto bad; | |
| __Pyx_PyFrame_SetLineNumber(py_frame, py_line); | |
| PyTraceBack_Here(py_frame); | |
| bad: | |
| Py_XDECREF(py_code); | |
| Py_XDECREF(py_frame); | |
| } | |
| /* FormatTypeName */ | |
| static __Pyx_TypeName | |
| __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp) | |
| { | |
| PyObject *module = NULL, *name = NULL, *result = NULL; | |
| name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, | |
| __pyx_mstate_global->__pyx_n_u_qualname); | |
| name = PyType_GetQualName(tp); | |
| if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad; | |
| module = __Pyx_PyObject_GetAttrStr((PyObject *)tp, | |
| __pyx_mstate_global->__pyx_n_u_module); | |
| if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad; | |
| if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) { | |
| result = name; | |
| name = NULL; | |
| goto done; | |
| } | |
| result = PyUnicode_FromFormat("%U.%U", module, name); | |
| if (unlikely(result == NULL)) goto bad; | |
| done: | |
| Py_XDECREF(name); | |
| Py_XDECREF(module); | |
| return result; | |
| bad: | |
| PyErr_Clear(); | |
| if (name) { | |
| result = name; | |
| name = NULL; | |
| } else { | |
| result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u_); | |
| } | |
| goto done; | |
| } | |
| /* PyFunctionFastCall */ | |
| static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject *const *args, Py_ssize_t na, | |
| PyObject *globals) { | |
| PyFrameObject *f; | |
| PyThreadState *tstate = __Pyx_PyThreadState_Current; | |
| PyObject **fastlocals; | |
| Py_ssize_t i; | |
| PyObject *result; | |
| assert(globals != NULL); | |
| /* XXX Perhaps we should create a specialized | |
| PyFrame_New() that doesn't take locals, but does | |
| take builtins without sanity checking them. | |
| */ | |
| assert(tstate != NULL); | |
| f = PyFrame_New(tstate, co, globals, NULL); | |
| if (f == NULL) { | |
| return NULL; | |
| } | |
| fastlocals = __Pyx_PyFrame_GetLocalsplus(f); | |
| for (i = 0; i < na; i++) { | |
| Py_INCREF(*args); | |
| fastlocals[i] = *args++; | |
| } | |
| result = PyEval_EvalFrameEx(f,0); | |
| ++tstate->recursion_depth; | |
| Py_DECREF(f); | |
| --tstate->recursion_depth; | |
| return result; | |
| } | |
| static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs, PyObject *kwargs) { | |
| PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); | |
| PyObject *globals = PyFunction_GET_GLOBALS(func); | |
| PyObject *argdefs = PyFunction_GET_DEFAULTS(func); | |
| PyObject *closure; | |
| PyObject *kwdefs; | |
| PyObject *kwtuple, **k; | |
| PyObject **d; | |
| Py_ssize_t nd; | |
| Py_ssize_t nk; | |
| PyObject *result; | |
| assert(kwargs == NULL || PyDict_Check(kwargs)); | |
| nk = kwargs ? PyDict_Size(kwargs) : 0; | |
| if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) { | |
| return NULL; | |
| } | |
| if ( | |
| co->co_kwonlyargcount == 0 && | |
| likely(kwargs == NULL || nk == 0) && | |
| co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { | |
| if (argdefs == NULL && co->co_argcount == nargs) { | |
| result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); | |
| goto done; | |
| } | |
| else if (nargs == 0 && argdefs != NULL | |
| && co->co_argcount == Py_SIZE(argdefs)) { | |
| /* function called with no arguments, but all parameters have | |
| a default value: use default values as arguments .*/ | |
| args = &PyTuple_GET_ITEM(argdefs, 0); | |
| result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); | |
| goto done; | |
| } | |
| } | |
| if (kwargs != NULL) { | |
| Py_ssize_t pos, i; | |
| kwtuple = PyTuple_New(2 * nk); | |
| if (kwtuple == NULL) { | |
| result = NULL; | |
| goto done; | |
| } | |
| k = &PyTuple_GET_ITEM(kwtuple, 0); | |
| pos = i = 0; | |
| while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { | |
| Py_INCREF(k[i]); | |
| Py_INCREF(k[i+1]); | |
| i += 2; | |
| } | |
| nk = i / 2; | |
| } | |
| else { | |
| kwtuple = NULL; | |
| k = NULL; | |
| } | |
| closure = PyFunction_GET_CLOSURE(func); | |
| kwdefs = PyFunction_GET_KW_DEFAULTS(func); | |
| if (argdefs != NULL) { | |
| d = &PyTuple_GET_ITEM(argdefs, 0); | |
| nd = Py_SIZE(argdefs); | |
| } | |
| else { | |
| d = NULL; | |
| nd = 0; | |
| } | |
| result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, | |
| args, (int)nargs, | |
| k, (int)nk, | |
| d, (int)nd, kwdefs, closure); | |
| Py_XDECREF(kwtuple); | |
| done: | |
| Py_LeaveRecursiveCall(); | |
| return result; | |
| } | |
| /* PyObjectCall */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { | |
| PyObject *result; | |
| ternaryfunc call = Py_TYPE(func)->tp_call; | |
| if (unlikely(!call)) | |
| return PyObject_Call(func, arg, kw); | |
| if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) | |
| return NULL; | |
| result = (*call)(func, arg, kw); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* PyObjectCallMethO */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { | |
| PyObject *self, *result; | |
| PyCFunction cfunc; | |
| cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); | |
| self = __Pyx_CyOrPyCFunction_GET_SELF(func); | |
| if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) | |
| return NULL; | |
| result = cfunc(self, arg); | |
| Py_LeaveRecursiveCall(); | |
| if (unlikely(!result) && unlikely(!PyErr_Occurred())) { | |
| PyErr_SetString( | |
| PyExc_SystemError, | |
| "NULL result without error in PyObject_Call"); | |
| } | |
| return result; | |
| } | |
| /* PyObjectFastCall */ | |
| static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) { | |
| PyObject *argstuple; | |
| PyObject *result = 0; | |
| size_t i; | |
| argstuple = PyTuple_New((Py_ssize_t)nargs); | |
| if (unlikely(!argstuple)) return NULL; | |
| for (i = 0; i < nargs; i++) { | |
| Py_INCREF(args[i]); | |
| if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad; | |
| } | |
| result = __Pyx_PyObject_Call(func, argstuple, kwargs); | |
| bad: | |
| Py_DECREF(argstuple); | |
| return result; | |
| } | |
| static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) { | |
| PyTypeObject *tp = Py_TYPE(callable); | |
| if (__Pyx_CyFunction_CheckExact(callable)) { | |
| return __Pyx_CyFunction_func_vectorcall(callable); | |
| } | |
| if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) { | |
| return NULL; | |
| } | |
| assert(PyCallable_Check(callable)); | |
| Py_ssize_t offset = tp->tp_vectorcall_offset; | |
| assert(offset > 0); | |
| vectorcallfunc ptr; | |
| memcpy(&ptr, (char *) callable + offset, sizeof(ptr)); | |
| return ptr; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) { | |
| Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); | |
| if (nargs == 0 && kwargs == NULL) { | |
| if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) | |
| return __Pyx_PyObject_CallMethO(func, NULL); | |
| } | |
| else if (nargs == 1 && kwargs == NULL) { | |
| if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) | |
| return __Pyx_PyObject_CallMethO(func, args[0]); | |
| } | |
| if (PyCFunction_Check(func)) { | |
| if (kwargs) { | |
| return _PyCFunction_FastCallDict(func, args, nargs, kwargs); | |
| } else { | |
| return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); | |
| } | |
| } | |
| if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { | |
| return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); | |
| } | |
| if (PyFunction_Check(func)) { | |
| return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); | |
| } | |
| if (kwargs == NULL) { | |
| vectorcallfunc f = __Pyx_PyVectorcall_Function(func); | |
| if (f) { | |
| return f(func, args, _nargs, NULL); | |
| } | |
| if (__Pyx_CyFunction_CheckExact(func)) { | |
| __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); | |
| if (f) return f(func, args, _nargs, NULL); | |
| } | |
| return PyObject_Vectorcall(func, args, _nargs, NULL); | |
| } | |
| if (nargs == 0) { | |
| return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs); | |
| } | |
| return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); | |
| return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); | |
| } | |
| /* PyObjectVectorCallKwBuilder */ | |
| static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { | |
| (void)__Pyx_PyObject_FastCallDict; | |
| if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1; | |
| Py_INCREF(key); | |
| args[n] = value; | |
| return 0; | |
| } | |
| CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) { | |
| (void)__Pyx_VectorcallBuilder_AddArgStr; | |
| if (unlikely(!PyUnicode_Check(key))) { | |
| PyErr_SetString(PyExc_TypeError, "keywords must be strings"); | |
| return -1; | |
| } | |
| return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n); | |
| } | |
| static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) { | |
| PyObject *pyKey = PyUnicode_FromString(key); | |
| if (!pyKey) return -1; | |
| return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n); | |
| } | |
| CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) { | |
| if (unlikely(!PyUnicode_Check(key))) { | |
| PyErr_SetString(PyExc_TypeError, "keywords must be strings"); | |
| return -1; | |
| } | |
| return PyDict_SetItem(builder, key, value); | |
| } | |
| /* CIntToPy */ | |
| static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (is_unsigned) { | |
| if (sizeof(long) < sizeof(long)) { | |
| return PyLong_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned long)) { | |
| return PyLong_FromUnsignedLong((unsigned long) value); | |
| } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { | |
| return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); | |
| } | |
| } else { | |
| if (sizeof(long) <= sizeof(long)) { | |
| return PyLong_FromLong((long) value); | |
| } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { | |
| return PyLong_FromLongLong((PY_LONG_LONG) value); | |
| } | |
| } | |
| { | |
| unsigned char *bytes = (unsigned char *)&value; | |
| if (is_unsigned) { | |
| return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1); | |
| } else { | |
| return PyLong_FromNativeBytes(bytes, sizeof(value), -1); | |
| } | |
| int one = 1; int little = (int)*(unsigned char *)&one; | |
| return _PyLong_FromByteArray(bytes, sizeof(long), | |
| little, !is_unsigned); | |
| int one = 1; int little = (int)*(unsigned char *)&one; | |
| PyObject *from_bytes, *result = NULL, *kwds = NULL; | |
| PyObject *py_bytes = NULL, *order_str = NULL; | |
| from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); | |
| if (!from_bytes) return NULL; | |
| py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); | |
| if (!py_bytes) goto limited_bad; | |
| order_str = PyUnicode_FromString(little ? "little" : "big"); | |
| if (!order_str) goto limited_bad; | |
| { | |
| PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str }; | |
| if (!is_unsigned) { | |
| kwds = __Pyx_MakeVectorcallBuilderKwds(1); | |
| if (!kwds) goto limited_bad; | |
| if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad; | |
| } | |
| result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds); | |
| } | |
| limited_bad: | |
| Py_XDECREF(kwds); | |
| Py_XDECREF(order_str); | |
| Py_XDECREF(py_bytes); | |
| Py_XDECREF(from_bytes); | |
| return result; | |
| } | |
| } | |
| /* CIntFromPyVerify */ | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) { | |
| const long neg_one = (long) -1, const_zero = (long) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (unlikely(!PyLong_Check(x))) { | |
| long val; | |
| PyObject *tmp = __Pyx_PyNumber_Long(x); | |
| if (!tmp) return (long) -1; | |
| val = __Pyx_PyLong_As_long(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| if (is_unsigned) { | |
| if (unlikely(__Pyx_PyLong_IsNeg(x))) { | |
| goto raise_neg_overflow; | |
| } else if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_DigitCount(x)) { | |
| case 2: | |
| if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { | |
| return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { | |
| return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { | |
| return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (long) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if ((sizeof(long) <= sizeof(unsigned long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_SignedDigitCount(x)) { | |
| case -2: | |
| if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { | |
| return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { | |
| return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if ((sizeof(long) <= sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) | |
| } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| long val; | |
| int ret = -1; | |
| Py_ssize_t bytes_copied = PyLong_AsNativeBytes( | |
| x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); | |
| if (unlikely(bytes_copied == -1)) { | |
| } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { | |
| goto raise_overflow; | |
| } else { | |
| ret = 0; | |
| } | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| ret = _PyLong_AsByteArray((PyLongObject *)x, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| PyObject *v; | |
| PyObject *stepval = NULL, *mask = NULL, *shift = NULL; | |
| int bits, remaining_bits, is_negative = 0; | |
| int chunk_size = (sizeof(long) < 8) ? 30 : 62; | |
| if (likely(PyLong_CheckExact(x))) { | |
| v = __Pyx_NewRef(x); | |
| } else { | |
| v = PyNumber_Long(x); | |
| if (unlikely(!v)) return (long) -1; | |
| assert(PyLong_CheckExact(v)); | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(v, Py_False, Py_LT); | |
| if (unlikely(result < 0)) { | |
| Py_DECREF(v); | |
| return (long) -1; | |
| } | |
| is_negative = result == 1; | |
| } | |
| if (is_unsigned && unlikely(is_negative)) { | |
| Py_DECREF(v); | |
| goto raise_neg_overflow; | |
| } else if (is_negative) { | |
| stepval = PyNumber_Invert(v); | |
| Py_DECREF(v); | |
| if (unlikely(!stepval)) | |
| return (long) -1; | |
| } else { | |
| stepval = v; | |
| } | |
| v = NULL; | |
| val = (long) 0; | |
| mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; | |
| shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; | |
| for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { | |
| PyObject *tmp, *digit; | |
| long idigit; | |
| digit = PyNumber_And(stepval, mask); | |
| if (unlikely(!digit)) goto done; | |
| idigit = PyLong_AsLong(digit); | |
| Py_DECREF(digit); | |
| if (unlikely(idigit < 0)) goto done; | |
| val |= ((long) idigit) << bits; | |
| tmp = PyNumber_Rshift(stepval, shift); | |
| if (unlikely(!tmp)) goto done; | |
| Py_DECREF(stepval); stepval = tmp; | |
| } | |
| Py_DECREF(shift); shift = NULL; | |
| Py_DECREF(mask); mask = NULL; | |
| { | |
| long idigit = PyLong_AsLong(stepval); | |
| if (unlikely(idigit < 0)) goto done; | |
| remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); | |
| if (unlikely(idigit >= (1L << remaining_bits))) | |
| goto raise_overflow; | |
| val |= ((long) idigit) << bits; | |
| } | |
| if (!is_unsigned) { | |
| if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) | |
| goto raise_overflow; | |
| if (is_negative) | |
| val = ~val; | |
| } | |
| ret = 0; | |
| done: | |
| Py_XDECREF(shift); | |
| Py_XDECREF(mask); | |
| Py_XDECREF(stepval); | |
| if (unlikely(ret)) | |
| return (long) -1; | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to long"); | |
| return (long) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to long"); | |
| return (long) -1; | |
| } | |
| /* CIntFromPy */ | |
| static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) { | |
| const int neg_one = (int) -1, const_zero = (int) 0; | |
| const int is_unsigned = neg_one > const_zero; | |
| if (unlikely(!PyLong_Check(x))) { | |
| int val; | |
| PyObject *tmp = __Pyx_PyNumber_Long(x); | |
| if (!tmp) return (int) -1; | |
| val = __Pyx_PyLong_As_int(tmp); | |
| Py_DECREF(tmp); | |
| return val; | |
| } | |
| if (is_unsigned) { | |
| if (unlikely(__Pyx_PyLong_IsNeg(x))) { | |
| goto raise_neg_overflow; | |
| } else if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_DigitCount(x)) { | |
| case 2: | |
| if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { | |
| return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { | |
| return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { | |
| return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if (unlikely(Py_SIZE(x) < 0)) { | |
| goto raise_neg_overflow; | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(x, Py_False, Py_LT); | |
| if (unlikely(result < 0)) | |
| return (int) -1; | |
| if (unlikely(result == 1)) | |
| goto raise_neg_overflow; | |
| } | |
| if ((sizeof(int) <= sizeof(unsigned long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) | |
| } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) | |
| } | |
| } else { | |
| if (__Pyx_PyLong_IsCompact(x)) { | |
| __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(x); | |
| assert(__Pyx_PyLong_DigitCount(x) > 1); | |
| switch (__Pyx_PyLong_SignedDigitCount(x)) { | |
| case -2: | |
| if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 2: | |
| if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -3: | |
| if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 3: | |
| if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case -4: | |
| if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { | |
| return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| case 4: | |
| if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { | |
| if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { | |
| __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) | |
| } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { | |
| return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| if ((sizeof(int) <= sizeof(long))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) | |
| } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { | |
| __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) | |
| } | |
| } | |
| { | |
| int val; | |
| int ret = -1; | |
| Py_ssize_t bytes_copied = PyLong_AsNativeBytes( | |
| x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0)); | |
| if (unlikely(bytes_copied == -1)) { | |
| } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) { | |
| goto raise_overflow; | |
| } else { | |
| ret = 0; | |
| } | |
| int one = 1; int is_little = (int)*(unsigned char *)&one; | |
| unsigned char *bytes = (unsigned char *)&val; | |
| ret = _PyLong_AsByteArray((PyLongObject *)x, | |
| bytes, sizeof(val), | |
| is_little, !is_unsigned); | |
| PyObject *v; | |
| PyObject *stepval = NULL, *mask = NULL, *shift = NULL; | |
| int bits, remaining_bits, is_negative = 0; | |
| int chunk_size = (sizeof(long) < 8) ? 30 : 62; | |
| if (likely(PyLong_CheckExact(x))) { | |
| v = __Pyx_NewRef(x); | |
| } else { | |
| v = PyNumber_Long(x); | |
| if (unlikely(!v)) return (int) -1; | |
| assert(PyLong_CheckExact(v)); | |
| } | |
| { | |
| int result = PyObject_RichCompareBool(v, Py_False, Py_LT); | |
| if (unlikely(result < 0)) { | |
| Py_DECREF(v); | |
| return (int) -1; | |
| } | |
| is_negative = result == 1; | |
| } | |
| if (is_unsigned && unlikely(is_negative)) { | |
| Py_DECREF(v); | |
| goto raise_neg_overflow; | |
| } else if (is_negative) { | |
| stepval = PyNumber_Invert(v); | |
| Py_DECREF(v); | |
| if (unlikely(!stepval)) | |
| return (int) -1; | |
| } else { | |
| stepval = v; | |
| } | |
| v = NULL; | |
| val = (int) 0; | |
| mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; | |
| shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; | |
| for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { | |
| PyObject *tmp, *digit; | |
| long idigit; | |
| digit = PyNumber_And(stepval, mask); | |
| if (unlikely(!digit)) goto done; | |
| idigit = PyLong_AsLong(digit); | |
| Py_DECREF(digit); | |
| if (unlikely(idigit < 0)) goto done; | |
| val |= ((int) idigit) << bits; | |
| tmp = PyNumber_Rshift(stepval, shift); | |
| if (unlikely(!tmp)) goto done; | |
| Py_DECREF(stepval); stepval = tmp; | |
| } | |
| Py_DECREF(shift); shift = NULL; | |
| Py_DECREF(mask); mask = NULL; | |
| { | |
| long idigit = PyLong_AsLong(stepval); | |
| if (unlikely(idigit < 0)) goto done; | |
| remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); | |
| if (unlikely(idigit >= (1L << remaining_bits))) | |
| goto raise_overflow; | |
| val |= ((int) idigit) << bits; | |
| } | |
| if (!is_unsigned) { | |
| if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) | |
| goto raise_overflow; | |
| if (is_negative) | |
| val = ~val; | |
| } | |
| ret = 0; | |
| done: | |
| Py_XDECREF(shift); | |
| Py_XDECREF(mask); | |
| Py_XDECREF(stepval); | |
| if (unlikely(ret)) | |
| return (int) -1; | |
| return val; | |
| } | |
| raise_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "value too large to convert to int"); | |
| return (int) -1; | |
| raise_neg_overflow: | |
| PyErr_SetString(PyExc_OverflowError, | |
| "can't convert negative value to int"); | |
| return (int) -1; | |
| } | |
| /* FastTypeChecks */ | |
| static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { | |
| while (a) { | |
| a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); | |
| if (a == b) | |
| return 1; | |
| } | |
| return b == &PyBaseObject_Type; | |
| } | |
| static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { | |
| PyObject *mro; | |
| if (a == b) return 1; | |
| mro = a->tp_mro; | |
| if (likely(mro)) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(mro); | |
| for (i = 0; i < n; i++) { | |
| if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| return __Pyx_InBases(a, b); | |
| } | |
| static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { | |
| PyObject *mro; | |
| if (cls == a || cls == b) return 1; | |
| mro = cls->tp_mro; | |
| if (likely(mro)) { | |
| Py_ssize_t i, n; | |
| n = PyTuple_GET_SIZE(mro); | |
| for (i = 0; i < n; i++) { | |
| PyObject *base = PyTuple_GET_ITEM(mro, i); | |
| if (base == (PyObject *)a || base == (PyObject *)b) | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); | |
| } | |
| static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { | |
| if (exc_type1) { | |
| return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); | |
| } else { | |
| return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); | |
| } | |
| } | |
| static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { | |
| Py_ssize_t i, n; | |
| assert(PyExceptionClass_Check(exc_type)); | |
| n = PyTuple_GET_SIZE(tuple); | |
| for (i=0; i<n; i++) { | |
| if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1; | |
| } | |
| for (i=0; i<n; i++) { | |
| PyObject *t = PyTuple_GET_ITEM(tuple, i); | |
| if (likely(PyExceptionClass_Check(t))) { | |
| if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1; | |
| } else { | |
| } | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { | |
| if (likely(err == exc_type)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| if (likely(PyExceptionClass_Check(exc_type))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); | |
| } else if (likely(PyTuple_Check(exc_type))) { | |
| return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type); | |
| } else { | |
| } | |
| } | |
| return PyErr_GivenExceptionMatches(err, exc_type); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { | |
| assert(PyExceptionClass_Check(exc_type1)); | |
| assert(PyExceptionClass_Check(exc_type2)); | |
| if (likely(err == exc_type1 || err == exc_type2)) return 1; | |
| if (likely(PyExceptionClass_Check(err))) { | |
| return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); | |
| } | |
| return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); | |
| } | |
| /* GetRuntimeVersion */ | |
| static unsigned long __Pyx_get_runtime_version(void) { | |
| return Py_Version & ~0xFFUL; | |
| static unsigned long __Pyx_cached_runtime_version = 0; | |
| if (__Pyx_cached_runtime_version == 0) { | |
| const char* rt_version = Py_GetVersion(); | |
| unsigned long version = 0; | |
| unsigned long factor = 0x01000000UL; | |
| unsigned int digit = 0; | |
| int i = 0; | |
| while (factor) { | |
| while ('0' <= rt_version[i] && rt_version[i] <= '9') { | |
| digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); | |
| ++i; | |
| } | |
| version += factor * digit; | |
| if (rt_version[i] != '.') | |
| break; | |
| digit = 0; | |
| factor >>= 8; | |
| ++i; | |
| } | |
| __Pyx_cached_runtime_version = version; | |
| } | |
| return __Pyx_cached_runtime_version; | |
| } | |
| /* CheckBinaryVersion */ | |
| static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { | |
| const unsigned long MAJOR_MINOR = 0xFFFF0000UL; | |
| if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) | |
| return 0; | |
| if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) | |
| return 1; | |
| { | |
| char message[200]; | |
| PyOS_snprintf(message, sizeof(message), | |
| "compile time Python version %d.%d " | |
| "of module '%.100s' " | |
| "%s " | |
| "runtime version %d.%d", | |
| (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), | |
| __Pyx_MODULE_NAME, | |
| (allow_newer) ? "was newer than" : "does not match", | |
| (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) | |
| ); | |
| return PyErr_WarnEx(NULL, message, 1); | |
| } | |
| } | |
| /* InitStrings */ | |
| static int __Pyx_InitStrings(__Pyx_StringTabEntry const *t, PyObject **target, const char* const* encoding_names) { | |
| while (t->s) { | |
| PyObject *str; | |
| if (t->is_unicode) { | |
| if (t->intern) { | |
| str = PyUnicode_InternFromString(t->s); | |
| } else if (t->encoding) { | |
| str = PyUnicode_Decode(t->s, t->n - 1, encoding_names[t->encoding], NULL); | |
| } else { | |
| str = PyUnicode_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| } else { | |
| str = PyBytes_FromStringAndSize(t->s, t->n - 1); | |
| } | |
| if (!str) | |
| return -1; | |
| *target = str; | |
| if (PyObject_Hash(str) == -1) | |
| return -1; | |
| ++t; | |
| ++target; | |
| } | |
| return 0; | |
| } | |
| static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { | |
| size_t len = strlen(s); | |
| if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { | |
| PyErr_SetString(PyExc_OverflowError, "byte string is too long"); | |
| return -1; | |
| } | |
| return (Py_ssize_t) len; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { | |
| Py_ssize_t len = __Pyx_ssize_strlen(c_str); | |
| if (unlikely(len < 0)) return NULL; | |
| return __Pyx_PyUnicode_FromStringAndSize(c_str, len); | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { | |
| Py_ssize_t len = __Pyx_ssize_strlen(c_str); | |
| if (unlikely(len < 0)) return NULL; | |
| return PyByteArray_FromStringAndSize(c_str, len); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { | |
| Py_ssize_t ignore; | |
| return __Pyx_PyObject_AsStringAndSize(o, &ignore); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; | |
| { | |
| const char* result; | |
| Py_ssize_t unicode_length; | |
| CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII | |
| if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL; | |
| result = PyUnicode_AsUTF8AndSize(o, length); | |
| unicode_length = PyUnicode_GetLength(o); | |
| if (unlikely(unicode_length < 0)) return NULL; | |
| if (unlikely(unicode_length != *length)) { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| return result; | |
| } | |
| if (likely(PyUnicode_IS_ASCII(o))) { | |
| *length = PyUnicode_GET_LENGTH(o); | |
| return PyUnicode_AsUTF8(o); | |
| } else { | |
| PyUnicode_AsASCIIString(o); | |
| return NULL; | |
| } | |
| return PyUnicode_AsUTF8AndSize(o, length); | |
| } | |
| static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { | |
| if (PyUnicode_Check(o)) { | |
| return __Pyx_PyUnicode_AsStringAndSize(o, length); | |
| } else | |
| if (PyByteArray_Check(o)) { | |
| *length = PyByteArray_GET_SIZE(o); | |
| return PyByteArray_AS_STRING(o); | |
| *length = PyByteArray_Size(o); | |
| if (*length == -1) return NULL; | |
| return PyByteArray_AsString(o); | |
| } else | |
| { | |
| char* result; | |
| int r = PyBytes_AsStringAndSize(o, &result, length); | |
| if (unlikely(r < 0)) { | |
| return NULL; | |
| } else { | |
| return result; | |
| } | |
| } | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { | |
| int is_true = x == Py_True; | |
| if (is_true | (x == Py_False) | (x == Py_None)) return is_true; | |
| else return PyObject_IsTrue(x); | |
| } | |
| static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { | |
| int retval; | |
| if (unlikely(!x)) return -1; | |
| retval = __Pyx_PyObject_IsTrue(x); | |
| Py_DECREF(x); | |
| return retval; | |
| } | |
| static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) { | |
| __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result)); | |
| if (PyLong_Check(result)) { | |
| if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, | |
| "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " | |
| "The ability to return an instance of a strict subclass of int is deprecated, " | |
| "and may be removed in a future version of Python.", | |
| result_type_name)) { | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| return result; | |
| } | |
| PyErr_Format(PyExc_TypeError, | |
| "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")", | |
| result_type_name); | |
| __Pyx_DECREF_TypeName(result_type_name); | |
| Py_DECREF(result); | |
| return NULL; | |
| } | |
| static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) { | |
| PyNumberMethods *m; | |
| PyObject *res = NULL; | |
| if (likely(PyLong_Check(x))) | |
| return __Pyx_NewRef(x); | |
| m = Py_TYPE(x)->tp_as_number; | |
| if (likely(m && m->nb_int)) { | |
| res = m->nb_int(x); | |
| } | |
| if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { | |
| res = PyNumber_Long(x); | |
| } | |
| if (likely(res)) { | |
| if (unlikely(!PyLong_CheckExact(res))) { | |
| return __Pyx_PyNumber_LongWrongResultType(res); | |
| } | |
| } | |
| else if (!PyErr_Occurred()) { | |
| PyErr_SetString(PyExc_TypeError, | |
| "an integer is required"); | |
| } | |
| return res; | |
| } | |
| static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| if (likely(PyLong_CheckExact(b))) { | |
| if (likely(__Pyx_PyLong_IsCompact(b))) { | |
| return __Pyx_PyLong_CompactValue(b); | |
| } else { | |
| const digit* digits = __Pyx_PyLong_Digits(b); | |
| const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); | |
| switch (size) { | |
| case 2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -2: | |
| if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -3: | |
| if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case 4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| case -4: | |
| if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { | |
| return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); | |
| } | |
| break; | |
| } | |
| } | |
| return PyLong_AsSsize_t(b); | |
| } | |
| x = PyNumber_Index(b); | |
| if (!x) return -1; | |
| ival = PyLong_AsSsize_t(x); | |
| Py_DECREF(x); | |
| return ival; | |
| } | |
| static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { | |
| if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { | |
| return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); | |
| } else { | |
| Py_ssize_t ival; | |
| PyObject *x; | |
| x = PyNumber_Index(o); | |
| if (!x) return -1; | |
| ival = PyLong_AsLong(x); | |
| Py_DECREF(x); | |
| return ival; | |
| } | |
| } | |
| static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) { | |
| CYTHON_UNUSED_VAR(b); | |
| return __Pyx_NewRef(Py_None); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { | |
| return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); | |
| } | |
| static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) { | |
| return PyLong_FromSize_t(ival); | |
| } | |
| /* MultiPhaseInitModuleState */ | |
| static PyMutex __Pyx_ModuleStateLookup_mutex = {0}; | |
| static std::mutex __Pyx_ModuleStateLookup_mutex; | |
| static mtx_t __Pyx_ModuleStateLookup_mutex; | |
| static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT; | |
| static void __Pyx_ModuleStateLookup_initialize_mutex(void) { | |
| mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain); | |
| } | |
| static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER; | |
| static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT; | |
| typedef struct { | |
| int64_t id; | |
| PyObject *module; | |
| } __Pyx_InterpreterIdAndModule; | |
| typedef struct { | |
| char interpreter_id_as_index; | |
| Py_ssize_t count; | |
| Py_ssize_t allocated; | |
| __Pyx_InterpreterIdAndModule table[1]; | |
| } __Pyx_ModuleStateLookupData; | |
| static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0; | |
| static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0; | |
| static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL; | |
| static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound( | |
| __Pyx_InterpreterIdAndModule* table, | |
| Py_ssize_t count, | |
| int64_t interpreterId) { | |
| __Pyx_InterpreterIdAndModule* begin = table; | |
| __Pyx_InterpreterIdAndModule* end = begin + count; | |
| if (begin->id == interpreterId) { | |
| return begin; | |
| } | |
| while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { | |
| __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2; | |
| if (halfway->id == interpreterId) { | |
| return halfway; | |
| } | |
| if (halfway->id < interpreterId) { | |
| begin = halfway; | |
| } else { | |
| end = halfway; | |
| } | |
| } | |
| for (; begin < end; ++begin) { | |
| if (begin->id >= interpreterId) return begin; | |
| } | |
| return begin; | |
| } | |
| static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) { | |
| int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); | |
| if (interpreter_id == -1) return NULL; | |
| __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); | |
| { | |
| __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); | |
| if (likely(data)) { | |
| __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data); | |
| if (likely(data == new_data)) { | |
| goto read_finished; | |
| } | |
| } | |
| __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); | |
| __Pyx_ModuleStateLookup_Lock(); | |
| __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter); | |
| data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data); | |
| __Pyx_ModuleStateLookup_Unlock(); | |
| } | |
| read_finished:; | |
| __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data; | |
| __Pyx_InterpreterIdAndModule* found = NULL; | |
| if (unlikely(!data)) goto end; | |
| if (data->interpreter_id_as_index) { | |
| if (interpreter_id < data->count) { | |
| found = data->table+interpreter_id; | |
| } | |
| } else { | |
| found = __Pyx_State_FindModuleStateLookupTableLowerBound( | |
| data->table, data->count, interpreter_id); | |
| } | |
| end: | |
| { | |
| PyObject *result=NULL; | |
| if (found && found->id == interpreter_id) { | |
| result = found->module; | |
| } | |
| __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter); | |
| return result; | |
| } | |
| } | |
| static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) { | |
| while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0); | |
| } | |
| static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) { | |
| Py_ssize_t to_allocate = (*old_data)->allocated; | |
| while (to_allocate <= interpreter_id) { | |
| if (to_allocate == 0) to_allocate = 1; | |
| else to_allocate *= 2; | |
| } | |
| __Pyx_ModuleStateLookupData *new_data = *old_data; | |
| if (to_allocate != (*old_data)->allocated) { | |
| new_data = (__Pyx_ModuleStateLookupData *)realloc( | |
| *old_data, | |
| sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); | |
| if (!new_data) { | |
| PyErr_NoMemory(); | |
| return -1; | |
| } | |
| for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) { | |
| new_data->table[i].id = i; | |
| new_data->table[i].module = NULL; | |
| } | |
| new_data->allocated = to_allocate; | |
| } | |
| new_data->table[interpreter_id].module = module; | |
| if (new_data->count < interpreter_id+1) { | |
| new_data->count = interpreter_id+1; | |
| } | |
| *old_data = new_data; | |
| return 0; | |
| } | |
| static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) { | |
| __Pyx_InterpreterIdAndModule *read = data->table; | |
| __Pyx_InterpreterIdAndModule *write = data->table; | |
| __Pyx_InterpreterIdAndModule *end = read + data->count; | |
| for (; read<end; ++read) { | |
| if (read->module) { | |
| write->id = read->id; | |
| write->module = read->module; | |
| ++write; | |
| } | |
| } | |
| data->count = write - data->table; | |
| for (; write<end; ++write) { | |
| write->id = 0; | |
| write->module = NULL; | |
| } | |
| data->interpreter_id_as_index = 0; | |
| } | |
| static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) { | |
| int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); | |
| if (interpreter_id == -1) return -1; | |
| int result = 0; | |
| __Pyx_ModuleStateLookup_Lock(); | |
| __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *) | |
| __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); | |
| __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data; | |
| __Pyx_ModuleStateLookupData *new_data = old_data; | |
| if (!new_data) { | |
| new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData)); | |
| if (!new_data) { | |
| result = -1; | |
| PyErr_NoMemory(); | |
| goto end; | |
| } | |
| new_data->allocated = 1; | |
| new_data->interpreter_id_as_index = 1; | |
| } | |
| __Pyx_ModuleStateLookup_wait_until_no_readers(); | |
| if (new_data->interpreter_id_as_index) { | |
| if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) { | |
| result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id); | |
| goto end; | |
| } | |
| __Pyx_State_ConvertFromInterpIdAsIndex(new_data); | |
| } | |
| { | |
| Py_ssize_t insert_at = 0; | |
| { | |
| __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( | |
| new_data->table, new_data->count, interpreter_id); | |
| assert(lower_bound); | |
| insert_at = lower_bound - new_data->table; | |
| if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) { | |
| lower_bound->module = module; | |
| goto end; // already in table, nothing more to do | |
| } | |
| } | |
| if (new_data->count+1 >= new_data->allocated) { | |
| Py_ssize_t to_allocate = (new_data->count+1)*2; | |
| new_data = | |
| (__Pyx_ModuleStateLookupData*)realloc( | |
| new_data, | |
| sizeof(__Pyx_ModuleStateLookupData) + | |
| (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule)); | |
| if (!new_data) { | |
| result = -1; | |
| new_data = old_data; | |
| PyErr_NoMemory(); | |
| goto end; | |
| } | |
| new_data->allocated = to_allocate; | |
| } | |
| ++new_data->count; | |
| int64_t last_id = interpreter_id; | |
| PyObject *last_module = module; | |
| for (Py_ssize_t i=insert_at; i<new_data->count; ++i) { | |
| int64_t current_id = new_data->table[i].id; | |
| new_data->table[i].id = last_id; | |
| last_id = current_id; | |
| PyObject *current_module = new_data->table[i].module; | |
| new_data->table[i].module = last_module; | |
| last_module = current_module; | |
| } | |
| } | |
| end: | |
| __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data); | |
| __Pyx_ModuleStateLookup_data = new_data; | |
| __Pyx_ModuleStateLookup_Unlock(); | |
| return result; | |
| } | |
| static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) { | |
| int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get()); | |
| if (interpreter_id == -1) return -1; | |
| __Pyx_ModuleStateLookup_Lock(); | |
| __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *) | |
| __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0); | |
| __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data; | |
| if (data->interpreter_id_as_index) { | |
| if (interpreter_id < data->count) { | |
| data->table[interpreter_id].module = NULL; | |
| } | |
| goto done; | |
| } | |
| { | |
| __Pyx_ModuleStateLookup_wait_until_no_readers(); | |
| __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound( | |
| data->table, data->count, interpreter_id); | |
| if (!lower_bound) goto done; | |
| if (lower_bound->id != interpreter_id) goto done; | |
| __Pyx_InterpreterIdAndModule *end = data->table+data->count; | |
| for (;lower_bound<end-1; ++lower_bound) { | |
| lower_bound->id = (lower_bound+1)->id; | |
| lower_bound->module = (lower_bound+1)->module; | |
| } | |
| } | |
| --data->count; | |
| if (data->count == 0) { | |
| free(data); | |
| data = NULL; | |
| } | |
| done: | |
| __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data); | |
| __Pyx_ModuleStateLookup_data = data; | |
| __Pyx_ModuleStateLookup_Unlock(); | |
| return 0; | |
| } | |
| /* #### Code section: utility_code_pragmas_end ### */ | |
| /* #### Code section: end ### */ | |