diff --git a/README.rst b/README.rst index 8596138..50cc366 100644 --- a/README.rst +++ b/README.rst @@ -106,12 +106,21 @@ Get all items with a given prefix from a trie:: >>> trie.values(u'foob') [10] +Get all suffixes of certain word starting with a given prefix from a trie:: + + >>> trie.suffixes() + [u'pro', u'producer', u'producers', u'product', u'production', u'productivity', u'prof'] + >>> trie.suffixes(u'prod') + [u'ucer', u'ucers', u'uct', u'uction', u'uctivity'] + + Save & load a trie (values must be picklable):: >>> trie.save('my.trie') >>> trie2 = datrie.Trie.load('my.trie') + Trie and BaseTrie ================= @@ -318,6 +327,7 @@ Authors & Contributors * Mikhail Korobov * Jared Suttles * Gabi Davar +* Ahmed T. Youssef This module is based on `libdatrie`_ C library by Theppitak Karoonboonyanan and is inspired by `fast_trie`_ Ruby bindings, `PyTrie`_ pure diff --git a/src/cdatrie.c b/src/cdatrie.c index b70a9d3..660d680 100644 --- a/src/cdatrie.c +++ b/src/cdatrie.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.19.1 on Mon Jul 8 04:02:25 2013 */ +/* Generated by Cython 0.20.1 on Mon Feb 17 23:36:45 2014 */ #define PY_SSIZE_T_CLEAN #ifndef CYTHON_USE_PYLONG_INTERNALS @@ -19,6 +19,7 @@ #elif PY_VERSION_HEX < 0x02040000 #error Cython requires Python 2.4+. #else +#define CYTHON_ABI "0_20_1" #include /* For offsetof */ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -53,6 +54,9 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif +#if CYTHON_COMPILING_IN_PYPY +#define Py_OptimizeFlag 0 +#endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX @@ -60,7 +64,7 @@ #define PY_FORMAT_SIZE_T "" #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ (PyErr_Format(PyExc_TypeError, \ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ @@ -112,13 +116,15 @@ #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type #endif -#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 +#if PY_VERSION_HEX < 0x02060000 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif #if PY_MAJOR_VERSION >= 3 @@ -131,19 +137,44 @@ #if PY_VERSION_HEX < 0x02060000 #define Py_TPFLAGS_HAVE_VERSION_TAG 0 #endif +#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) + #define Py_TPFLAGS_IS_ABSTRACT 0 +#endif +#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type @@ -176,7 +207,7 @@ #else #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) @@ -201,11 +232,12 @@ #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif -#if PY_VERSION_HEX < 0x03020000 +#if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong @@ -264,7 +296,7 @@ #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) + #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict @@ -342,8 +374,20 @@ typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ + (sizeof(type) < sizeof(Py_ssize_t)) || \ + (sizeof(type) > sizeof(Py_ssize_t) && \ + likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX) && \ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ + v == (type)PY_SSIZE_T_MIN))) || \ + (sizeof(type) == sizeof(Py_ssize_t) && \ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); @@ -354,9 +398,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s) #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) #if PY_MAJOR_VERSION < 3 @@ -378,7 +424,6 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else @@ -387,7 +432,7 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; @@ -412,7 +457,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } @@ -436,7 +481,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; char* default_encoding_c; @@ -540,40 +585,22 @@ static const char *__pyx_f[] = { #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); - -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); - -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); - -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); - -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); - -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); - -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static int __Pyx_check_binary_version(void); @@ -608,10 +635,10 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ int __pyx_module_is_main_cdatrie = 0; /* Implementation of 'cdatrie' */ -static char __pyx_k____main__[] = "__main__"; -static char __pyx_k____test__[] = "__test__"; -static PyObject *__pyx_n_s____main__; -static PyObject *__pyx_n_s____test__; +static char __pyx_k_main[] = "__main__"; +static char __pyx_k_test[] = "__test__"; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_test; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} @@ -636,8 +663,8 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, - {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { @@ -709,14 +736,6 @@ PyMODINIT_FUNC PyInit_cdatrie(void) if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (!PyDict_GetItemString(modules, "cdatrie")) { - if (unlikely(PyDict_SetItemString(modules, "cdatrie", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - } - #endif __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); @@ -728,8 +747,16 @@ PyMODINIT_FUNC PyInit_cdatrie(void) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_cdatrie) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "cdatrie")) { + if (unlikely(PyDict_SetItemString(modules, "cdatrie", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } } + #endif /*--- Builtin init code ---*/ if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ @@ -749,9 +776,9 @@ PyMODINIT_FUNC PyInit_cdatrie(void) * */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -787,358 +814,96 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif /* CYTHON_REFNANNY */ -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { - const unsigned char neg_one = (unsigned char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned char" : - "value too large to convert to unsigned char"); - } - return (unsigned char)-1; - } - return (unsigned char)val; - } - return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { - const unsigned short neg_one = (unsigned short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned short" : - "value too large to convert to unsigned short"); - } - return (unsigned short)-1; - } - return (unsigned short)val; - } - return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { - const unsigned int neg_one = (unsigned int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned int" : - "value too large to convert to unsigned int"); - } - return (unsigned int)-1; - } - return (unsigned int)val; - } - return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { - const char neg_one = (char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to char" : - "value too large to convert to char"); - } - return (char)-1; - } - return (char)val; - } - return (char)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { - const short neg_one = (short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to short" : - "value too large to convert to short"); - } - return (short)-1; - } - return (short)val; - } - return (short)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(long) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } - return (int)val; - } - return (int)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { - const signed char neg_one = (signed char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed char" : - "value too large to convert to signed char"); - } - return (signed char)-1; - } - return (signed char)val; - } - return (signed char)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { - const signed short neg_one = (signed short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed short" : - "value too large to convert to signed short"); - } - return (signed short)-1; + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); } - return (signed short)val; } - return (signed short)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { - const signed int neg_one = (signed int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed int" : - "value too large to convert to signed int"); - } - return (signed int)-1; - } - return (signed int)val; + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); } - return (signed int)__Pyx_PyInt_AsSignedLong(x); } -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \ + { \ + func_type value = func(x); \ + if (sizeof(target_type) < sizeof(func_type)) { \ + if (unlikely(value != (func_type) (target_type) value)) { \ + func_type zero = 0; \ + PyErr_SetString(PyExc_OverflowError, \ + (is_unsigned && unlikely(value < zero)) ? \ + "can't convert negative value to " #target_type : \ + "value too large to convert to " #target_type); \ + return (target_type) -1; \ + } \ + } \ + return (target_type) value; \ } - return (int)__Pyx_PyInt_AsLong(x); -} #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -#endif -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { - const unsigned long neg_one = (unsigned long)-1, const_zero = 0; +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)PyLong_AsUnsignedLong(x); + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG) } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - return (unsigned long)PyLong_AsLong(x); - } - } else { - unsigned long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned long)-1; - val = __Pyx_PyInt_AsUnsignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { - const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + "can't convert negative value to long"); + return (long) -1; } -#endif -#endif - return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); - } - } else { - unsigned PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsUnsignedLongLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { - const long neg_one = (long)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; + return (long) val; } - return (long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS + #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); - return (long)-1; + return (long) -1; + } + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(long) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong) } - return (long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS + #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; @@ -1146,198 +911,146 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif -#endif - return (long)PyLong_AsLong(x); - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (long)-1; - val = __Pyx_PyInt_AsLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { - const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; - } - return (PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong) + } else if (sizeof(long) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong) } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); } - return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; } #endif -#endif - return (PY_LONG_LONG)PyLong_AsLongLong(x); + return (long) -1; } } else { - PY_LONG_LONG val; + long val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsLongLong(tmp); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { - const signed long neg_one = (signed long)-1, const_zero = 0; +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; + } + return (int) val; } - return (signed long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (int) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; + "can't convert negative value to int"); + return (int) -1; + } + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(int) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong) } - return (signed long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(int) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(int) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif -#endif - return (signed long)PyLong_AsLong(x); - } - } else { - signed long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed long)-1; - val = __Pyx_PyInt_AsSignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { - const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; - } - return (signed PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong) + } else if (sizeof(int) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong) } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); } - return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; } #endif -#endif - return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + return (int) -1; } } else { - signed PY_LONG_LONG val; + int val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsSignedLongLong(tmp); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } @@ -1603,10 +1316,18 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_ #endif /* PY_VERSION_HEX < 0x03030000 */ } else #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ +#if !CYTHON_COMPILING_IN_PYPY +#if PY_VERSION_HEX >= 0x02060000 + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif +#endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); - if (r < 0) { + if (unlikely(r < 0)) { return NULL; } else { return result; @@ -1651,7 +1372,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, - "__%s__ returned non-%s (type %.200s)", + "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; @@ -1663,9 +1384,35 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { } return res; } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif +#endif static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; - PyObject* x = PyNumber_Index(b); + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) + return PyInt_AS_LONG(b); +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(b)) { + case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; + case 0: return 0; + case 1: return ((PyLongObject*)b)->ob_digit[0]; + } + #endif + #endif + #if PY_VERSION_HEX < 0x02060000 + return PyInt_AsSsize_t(b); + #else + return PyLong_AsSsize_t(b); + #endif + } + x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); @@ -1684,16 +1431,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); #endif } -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { - unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t)-1; - } - return (size_t)val; -} #endif /* Py_PYTHON_H */ diff --git a/src/datrie.c b/src/datrie.c index fea75cf..b50675f 100644 --- a/src/datrie.c +++ b/src/datrie.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.19.1 on Mon Jul 8 04:02:25 2013 */ +/* Generated by Cython 0.20.1 on Mon Feb 17 23:36:45 2014 */ #define PY_SSIZE_T_CLEAN #ifndef CYTHON_USE_PYLONG_INTERNALS @@ -19,6 +19,7 @@ #elif PY_VERSION_HEX < 0x02040000 #error Cython requires Python 2.4+. #else +#define CYTHON_ABI "0_20_1" #include /* For offsetof */ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -53,6 +54,9 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif +#if CYTHON_COMPILING_IN_PYPY +#define Py_OptimizeFlag 0 +#endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX @@ -60,7 +64,7 @@ #define PY_FORMAT_SIZE_T "" #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ (PyErr_Format(PyExc_TypeError, \ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ @@ -112,13 +116,15 @@ #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type #endif -#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 +#if PY_VERSION_HEX < 0x02060000 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif #if PY_MAJOR_VERSION >= 3 @@ -131,19 +137,44 @@ #if PY_VERSION_HEX < 0x02060000 #define Py_TPFLAGS_HAVE_VERSION_TAG 0 #endif +#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) + #define Py_TPFLAGS_IS_ABSTRACT 0 +#endif +#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type @@ -176,7 +207,7 @@ #else #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) @@ -201,11 +232,12 @@ #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif -#if PY_VERSION_HEX < 0x03020000 +#if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong @@ -264,7 +296,7 @@ #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) + #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict @@ -343,8 +375,20 @@ typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ + (sizeof(type) < sizeof(Py_ssize_t)) || \ + (sizeof(type) > sizeof(Py_ssize_t) && \ + likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX) && \ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ + v == (type)PY_SSIZE_T_MIN))) || \ + (sizeof(type) == sizeof(Py_ssize_t) && \ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); @@ -355,9 +399,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s) #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) #if PY_MAJOR_VERSION < 3 @@ -379,7 +425,6 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else @@ -388,7 +433,7 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; @@ -413,7 +458,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } @@ -437,7 +482,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; char* default_encoding_c; @@ -490,22 +535,23 @@ static const char *__pyx_f[] = { }; /*--- Type declarations ---*/ +struct __pyx_obj_6datrie_BaseTrie; +struct __pyx_obj_6datrie_Trie; +struct __pyx_obj_6datrie__TrieState; +struct __pyx_obj_6datrie_BaseState; +struct __pyx_obj_6datrie_State; struct __pyx_obj_6datrie__TrieIterator; +struct __pyx_obj_6datrie_BaseIterator; struct __pyx_obj_6datrie_Iterator; struct __pyx_obj_6datrie_AlphaMap; -struct __pyx_obj_6datrie__TrieState; -struct __pyx_obj_6datrie_State; -struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items; -struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values; -struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values; -struct __pyx_obj_6datrie_BaseTrie; -struct __pyx_obj_6datrie_Trie; struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes; struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items; -struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges; -struct __pyx_obj_6datrie_BaseIterator; +struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values; +struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items; +struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values; struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges; -struct __pyx_obj_6datrie_BaseState; +struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges; +struct __pyx_opt_args_6datrie_8BaseTrie_suffixes; struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item; struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_value; struct __pyx_opt_args_6datrie_8BaseTrie_items; @@ -515,7 +561,19 @@ struct __pyx_opt_args_6datrie_4Trie_items; struct __pyx_opt_args_6datrie_4Trie_values; struct __pyx_opt_args_6datrie_unicode_from_alpha_char; -/* "datrie.pyx":378 +/* "datrie.pyx":279 + * + * + * cpdef suffixes(self, unicode prefix=u''): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's suffixes. + */ +struct __pyx_opt_args_6datrie_8BaseTrie_suffixes { + int __pyx_n; + PyObject *prefix; +}; + +/* "datrie.pyx":401 * return self._longest_prefix_item(key, default) * * cdef _longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< @@ -527,7 +585,7 @@ struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item { PyObject *__pyx_default; }; -/* "datrie.pyx":418 +/* "datrie.pyx":441 * return self._longest_prefix_value(key, default) * * cdef _longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< @@ -539,7 +597,7 @@ struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_value { PyObject *__pyx_default; }; -/* "datrie.pyx":463 +/* "datrie.pyx":486 * cdatrie.trie_state_free(state) * * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -551,7 +609,7 @@ struct __pyx_opt_args_6datrie_8BaseTrie_items { PyObject *prefix; }; -/* "datrie.pyx":491 +/* "datrie.pyx":514 * * * cpdef keys(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -563,7 +621,7 @@ struct __pyx_opt_args_6datrie_8BaseTrie_keys { PyObject *prefix; }; -/* "datrie.pyx":517 +/* "datrie.pyx":540 * return res * * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -575,7 +633,7 @@ struct __pyx_opt_args_6datrie_8BaseTrie_values { PyObject *prefix; }; -/* "datrie.pyx":610 +/* "datrie.pyx":633 * * * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -587,7 +645,7 @@ struct __pyx_opt_args_6datrie_4Trie_items { PyObject *prefix; }; -/* "datrie.pyx":644 +/* "datrie.pyx":667 * return res * * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -599,7 +657,7 @@ struct __pyx_opt_args_6datrie_4Trie_values { PyObject *prefix; }; -/* "datrie.pyx":983 +/* "datrie.pyx":1006 * return data * * cdef unicode unicode_from_alpha_char(cdatrie.AlphaChar* key, int len=0): # <<<<<<<<<<<<<< @@ -611,48 +669,34 @@ struct __pyx_opt_args_6datrie_unicode_from_alpha_char { int len; }; -/* "datrie.pyx":816 +/* "datrie.pyx":29 * * - * cdef class _TrieIterator: # <<<<<<<<<<<<<< - * cdef cdatrie.TrieIterator* _iter - * cdef _TrieState _root + * cdef class BaseTrie: # <<<<<<<<<<<<<< + * """ + * Wrapper for libdatrie's trie. */ -struct __pyx_obj_6datrie__TrieIterator { +struct __pyx_obj_6datrie_BaseTrie { PyObject_HEAD - struct __pyx_vtabstruct_6datrie__TrieIterator *__pyx_vtab; - TrieIterator *_iter; - struct __pyx_obj_6datrie__TrieState *_root; + struct __pyx_vtabstruct_6datrie_BaseTrie *__pyx_vtab; + Trie *_c_trie; }; -/* "datrie.pyx":850 - * +/* "datrie.pyx":565 * - * cdef class Iterator(_TrieIterator): # <<<<<<<<<<<<<< - * """ - * cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie - */ -struct __pyx_obj_6datrie_Iterator { - struct __pyx_obj_6datrie__TrieIterator __pyx_base; -}; - - -/* "datrie.pyx":892 - * # ============================ AlphaMap & utils ================================ * - * cdef class AlphaMap: # <<<<<<<<<<<<<< + * cdef class Trie(BaseTrie): # <<<<<<<<<<<<<< * """ - * Alphabet map. + * Wrapper for libdatrie's trie. */ -struct __pyx_obj_6datrie_AlphaMap { - PyObject_HEAD - struct __pyx_vtabstruct_6datrie_AlphaMap *__pyx_vtab; - struct AlphaMap *_c_alpha_map; +struct __pyx_obj_6datrie_Trie { + struct __pyx_obj_6datrie_BaseTrie __pyx_base; + PyObject *_values; }; -/* "datrie.pyx":736 +/* "datrie.pyx":759 * * * cdef class _TrieState: # <<<<<<<<<<<<<< @@ -667,101 +711,80 @@ struct __pyx_obj_6datrie__TrieState { }; -/* "datrie.pyx":803 - * +/* "datrie.pyx":818 * - * cdef class State(_TrieState): # <<<<<<<<<<<<<< * - * def __cinit__(self, Trie trie): # this is overriden for extra type check + * cdef class BaseState(_TrieState): # <<<<<<<<<<<<<< + * """ + * cdatrie.TrieState wrapper. It can be used for custom trie traversal. */ -struct __pyx_obj_6datrie_State { +struct __pyx_obj_6datrie_BaseState { struct __pyx_obj_6datrie__TrieState __pyx_base; }; -/* "datrie.pyx":717 - * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] +/* "datrie.pyx":826 * - * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< - * for k, v in super(Trie, self).iter_prefix_items(key): - * yield k, self._values[v] + * + * cdef class State(_TrieState): # <<<<<<<<<<<<<< + * + * def __cinit__(self, Trie trie): # this is overriden for extra type check */ -struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items { - PyObject_HEAD - PyObject *__pyx_v_k; - PyObject *__pyx_v_key; - struct __pyx_obj_6datrie_Trie *__pyx_v_self; - PyObject *__pyx_v_v; - PyObject *__pyx_t_0; - Py_ssize_t __pyx_t_1; - PyObject *(*__pyx_t_2)(PyObject *); +struct __pyx_obj_6datrie_State { + struct __pyx_obj_6datrie__TrieState __pyx_base; }; -/* "datrie.pyx":728 - * return [self._values[v] for v in self._prefix_values(key)] +/* "datrie.pyx":839 * - * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * for v in super(Trie, self).iter_prefix_values(key): - * yield self._values[v] + * + * cdef class _TrieIterator: # <<<<<<<<<<<<<< + * cdef cdatrie.TrieIterator* _iter + * cdef _TrieState _root */ -struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values { +struct __pyx_obj_6datrie__TrieIterator { PyObject_HEAD - PyObject *__pyx_v_key; - struct __pyx_obj_6datrie_Trie *__pyx_v_self; - PyObject *__pyx_v_v; - PyObject *__pyx_t_0; - Py_ssize_t __pyx_t_1; - PyObject *(*__pyx_t_2)(PyObject *); + struct __pyx_vtabstruct_6datrie__TrieIterator *__pyx_vtab; + TrieIterator *_iter; + struct __pyx_obj_6datrie__TrieState *_root; }; -/* "datrie.pyx":237 - * cdatrie.trie_state_free(state) +/* "datrie.pyx":864 * - * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns an iterator over the values of this trie that are associated + * + * cdef class BaseIterator(_TrieIterator): # <<<<<<<<<<<<<< + * """ + * cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie */ -struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values { - PyObject_HEAD - Py_UCS4 __pyx_v_char; - PyObject *__pyx_v_key; - struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self; - TrieState *__pyx_v_state; - PyObject *__pyx_t_0; - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - void *__pyx_t_3; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; +struct __pyx_obj_6datrie_BaseIterator { + struct __pyx_obj_6datrie__TrieIterator __pyx_base; }; -/* "datrie.pyx":29 +/* "datrie.pyx":873 * * - * cdef class BaseTrie: # <<<<<<<<<<<<<< + * cdef class Iterator(_TrieIterator): # <<<<<<<<<<<<<< * """ - * Wrapper for libdatrie's trie. + * cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie */ -struct __pyx_obj_6datrie_BaseTrie { - PyObject_HEAD - struct __pyx_vtabstruct_6datrie_BaseTrie *__pyx_vtab; - Trie *_c_trie; +struct __pyx_obj_6datrie_Iterator { + struct __pyx_obj_6datrie__TrieIterator __pyx_base; }; -/* "datrie.pyx":542 - * +/* "datrie.pyx":915 + * # ============================ AlphaMap & utils ================================ * - * cdef class Trie(BaseTrie): # <<<<<<<<<<<<<< + * cdef class AlphaMap: # <<<<<<<<<<<<<< * """ - * Wrapper for libdatrie's trie. + * Alphabet map. */ -struct __pyx_obj_6datrie_Trie { - struct __pyx_obj_6datrie_BaseTrie __pyx_base; - PyObject *_values; +struct __pyx_obj_6datrie_AlphaMap { + PyObject_HEAD + struct __pyx_vtabstruct_6datrie_AlphaMap *__pyx_vtab; + struct AlphaMap *_c_alpha_map; }; @@ -811,37 +834,66 @@ struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items { }; -/* "datrie.pyx":1006 - * yield b[0][1], b[-1][1] +/* "datrie.pyx":237 + * cdatrie.trie_state_free(state) * - * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< - * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): - * yield begin, end + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the values of this trie that are associated */ -struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges { +struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values { PyObject_HEAD - PyObject *__pyx_v_alphabet; - PyObject *__pyx_v_begin; - PyObject *__pyx_v_end; + Py_UCS4 __pyx_v_char; + PyObject *__pyx_v_key; + struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self; + TrieState *__pyx_v_state; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; - PyObject *(*__pyx_t_2)(PyObject *); + Py_ssize_t __pyx_t_2; + void *__pyx_t_3; + int __pyx_t_4; + Py_ssize_t __pyx_t_5; }; -/* "datrie.pyx":841 +/* "datrie.pyx":740 + * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] * + * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * for k, v in super(Trie, self).iter_prefix_items(key): + * yield k, self._values[v] + */ +struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items { + PyObject_HEAD + PyObject *__pyx_v_k; + PyObject *__pyx_v_key; + struct __pyx_obj_6datrie_Trie *__pyx_v_self; + PyObject *__pyx_v_v; + PyObject *__pyx_t_0; + Py_ssize_t __pyx_t_1; + PyObject *(*__pyx_t_2)(PyObject *); +}; + + +/* "datrie.pyx":751 + * return [self._values[v] for v in self._prefix_values(key)] * - * cdef class BaseIterator(_TrieIterator): # <<<<<<<<<<<<<< - * """ - * cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * for v in super(Trie, self).iter_prefix_values(key): + * yield self._values[v] */ -struct __pyx_obj_6datrie_BaseIterator { - struct __pyx_obj_6datrie__TrieIterator __pyx_base; +struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values { + PyObject_HEAD + PyObject *__pyx_v_key; + struct __pyx_obj_6datrie_Trie *__pyx_v_self; + PyObject *__pyx_v_v; + PyObject *__pyx_t_0; + Py_ssize_t __pyx_t_1; + PyObject *(*__pyx_t_2)(PyObject *); }; -/* "datrie.pyx":994 +/* "datrie.pyx":1017 * * * def to_ranges(lst): # <<<<<<<<<<<<<< @@ -859,65 +911,67 @@ struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges { }; -/* "datrie.pyx":795 - * +/* "datrie.pyx":1029 + * yield b[0][1], b[-1][1] * - * cdef class BaseState(_TrieState): # <<<<<<<<<<<<<< - * """ - * cdatrie.TrieState wrapper. It can be used for custom trie traversal. + * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< + * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): + * yield begin, end */ -struct __pyx_obj_6datrie_BaseState { - struct __pyx_obj_6datrie__TrieState __pyx_base; +struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges { + PyObject_HEAD + PyObject *__pyx_v_alphabet; + PyObject *__pyx_v_begin; + PyObject *__pyx_v_end; + PyObject *__pyx_t_0; + Py_ssize_t __pyx_t_1; + PyObject *(*__pyx_t_2)(PyObject *); }; -/* "datrie.pyx":816 +/* "datrie.pyx":29 * * - * cdef class _TrieIterator: # <<<<<<<<<<<<<< - * cdef cdatrie.TrieIterator* _iter - * cdef _TrieState _root + * cdef class BaseTrie: # <<<<<<<<<<<<<< + * """ + * Wrapper for libdatrie's trie. */ -struct __pyx_vtabstruct_6datrie__TrieIterator { - int (*next)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch); - PyObject *(*key)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_6datrie__TrieIterator *__pyx_vtabptr_6datrie__TrieIterator; - - -/* "datrie.pyx":850 - * - * - * cdef class Iterator(_TrieIterator): # <<<<<<<<<<<<<< - * """ - * cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie - */ - -struct __pyx_vtabstruct_6datrie_Iterator { - struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_base; - PyObject *(*data)(struct __pyx_obj_6datrie_Iterator *, int __pyx_skip_dispatch); +struct __pyx_vtabstruct_6datrie_BaseTrie { + int (*is_dirty)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch); + void (*_setitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData); + TrieData (*_getitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); + int (*_delitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, int __pyx_skip_dispatch); + TrieData (*_setdefault)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData); + PyObject *(*suffixes)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_suffixes *__pyx_optional_args); + PyObject *(*_prefix_items)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); + PyObject *(*_prefix_values)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); + PyObject *(*_longest_prefix_item)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item *__pyx_optional_args); + PyObject *(*_longest_prefix_value)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_value *__pyx_optional_args); + PyObject *(*items)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_items *__pyx_optional_args); + PyObject *(*keys)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_keys *__pyx_optional_args); + PyObject *(*values)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_values *__pyx_optional_args); + PyObject *(*_index_to_value)(struct __pyx_obj_6datrie_BaseTrie *, TrieData); }; -static struct __pyx_vtabstruct_6datrie_Iterator *__pyx_vtabptr_6datrie_Iterator; +static struct __pyx_vtabstruct_6datrie_BaseTrie *__pyx_vtabptr_6datrie_BaseTrie; -/* "datrie.pyx":841 +/* "datrie.pyx":565 * * - * cdef class BaseIterator(_TrieIterator): # <<<<<<<<<<<<<< + * cdef class Trie(BaseTrie): # <<<<<<<<<<<<<< * """ - * cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie + * Wrapper for libdatrie's trie. */ -struct __pyx_vtabstruct_6datrie_BaseIterator { - struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_base; - TrieData (*data)(struct __pyx_obj_6datrie_BaseIterator *, int __pyx_skip_dispatch); +struct __pyx_vtabstruct_6datrie_Trie { + struct __pyx_vtabstruct_6datrie_BaseTrie __pyx_base; }; -static struct __pyx_vtabstruct_6datrie_BaseIterator *__pyx_vtabptr_6datrie_BaseIterator; +static struct __pyx_vtabstruct_6datrie_Trie *__pyx_vtabptr_6datrie_Trie; -/* "datrie.pyx":736 +/* "datrie.pyx":759 * * * cdef class _TrieState: # <<<<<<<<<<<<<< @@ -937,7 +991,7 @@ struct __pyx_vtabstruct_6datrie__TrieState { static struct __pyx_vtabstruct_6datrie__TrieState *__pyx_vtabptr_6datrie__TrieState; -/* "datrie.pyx":795 +/* "datrie.pyx":818 * * * cdef class BaseState(_TrieState): # <<<<<<<<<<<<<< @@ -952,7 +1006,7 @@ struct __pyx_vtabstruct_6datrie_BaseState { static struct __pyx_vtabstruct_6datrie_BaseState *__pyx_vtabptr_6datrie_BaseState; -/* "datrie.pyx":803 +/* "datrie.pyx":826 * * * cdef class State(_TrieState): # <<<<<<<<<<<<<< @@ -967,47 +1021,52 @@ struct __pyx_vtabstruct_6datrie_State { static struct __pyx_vtabstruct_6datrie_State *__pyx_vtabptr_6datrie_State; -/* "datrie.pyx":29 +/* "datrie.pyx":839 * * - * cdef class BaseTrie: # <<<<<<<<<<<<<< + * cdef class _TrieIterator: # <<<<<<<<<<<<<< + * cdef cdatrie.TrieIterator* _iter + * cdef _TrieState _root + */ + +struct __pyx_vtabstruct_6datrie__TrieIterator { + int (*next)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch); + PyObject *(*key)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_6datrie__TrieIterator *__pyx_vtabptr_6datrie__TrieIterator; + + +/* "datrie.pyx":864 + * + * + * cdef class BaseIterator(_TrieIterator): # <<<<<<<<<<<<<< * """ - * Wrapper for libdatrie's trie. + * cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie */ -struct __pyx_vtabstruct_6datrie_BaseTrie { - int (*is_dirty)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch); - void (*_setitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData); - TrieData (*_getitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); - int (*_delitem)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, int __pyx_skip_dispatch); - TrieData (*_setdefault)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData); - PyObject *(*_prefix_items)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); - PyObject *(*_prefix_values)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *); - PyObject *(*_longest_prefix_item)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item *__pyx_optional_args); - PyObject *(*_longest_prefix_value)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_value *__pyx_optional_args); - PyObject *(*items)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_items *__pyx_optional_args); - PyObject *(*keys)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_keys *__pyx_optional_args); - PyObject *(*values)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_values *__pyx_optional_args); - PyObject *(*_index_to_value)(struct __pyx_obj_6datrie_BaseTrie *, TrieData); +struct __pyx_vtabstruct_6datrie_BaseIterator { + struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_base; + TrieData (*data)(struct __pyx_obj_6datrie_BaseIterator *, int __pyx_skip_dispatch); }; -static struct __pyx_vtabstruct_6datrie_BaseTrie *__pyx_vtabptr_6datrie_BaseTrie; +static struct __pyx_vtabstruct_6datrie_BaseIterator *__pyx_vtabptr_6datrie_BaseIterator; -/* "datrie.pyx":542 +/* "datrie.pyx":873 * * - * cdef class Trie(BaseTrie): # <<<<<<<<<<<<<< + * cdef class Iterator(_TrieIterator): # <<<<<<<<<<<<<< * """ - * Wrapper for libdatrie's trie. + * cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie */ -struct __pyx_vtabstruct_6datrie_Trie { - struct __pyx_vtabstruct_6datrie_BaseTrie __pyx_base; +struct __pyx_vtabstruct_6datrie_Iterator { + struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_base; + PyObject *(*data)(struct __pyx_obj_6datrie_Iterator *, int __pyx_skip_dispatch); }; -static struct __pyx_vtabstruct_6datrie_Trie *__pyx_vtabptr_6datrie_Trie; +static struct __pyx_vtabstruct_6datrie_Iterator *__pyx_vtabptr_6datrie_Iterator; -/* "datrie.pyx":892 +/* "datrie.pyx":915 * # ============================ AlphaMap & utils ================================ * * cdef class AlphaMap: # <<<<<<<<<<<<<< @@ -1070,6 +1129,14 @@ static struct __pyx_vtabstruct_6datrie_AlphaMap *__pyx_vtabptr_6datrie_AlphaMap; #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) @@ -1099,16 +1166,51 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact); /*proto*/ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/ +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename); /*proto*/ + int lineno, const char *filename, + int full_traceback); /*proto*/ + +#if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX >= 0x03020000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000) +static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) { + PyObject *res; + PyTypeObject *tp = Py_TYPE(obj); +#if PY_MAJOR_VERSION < 3 + if (unlikely(PyInstance_Check(obj))) + return __Pyx_PyObject_GetAttrStr(obj, attr_name); +#endif + res = _PyType_Lookup(tp, attr_name); + if (likely(res)) { + descrgetfunc f = Py_TYPE(res)->tp_descr_get; + if (!f) { + Py_INCREF(res); + } else { + res = f(res, obj, (PyObject *)tp); + } + } else { + PyErr_SetObject(PyExc_AttributeError, attr_name); + } + return res; +} +#else +#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) +#endif + +static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ +static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ @@ -1120,6 +1222,8 @@ static CYTHON_INLINE int __Pyx_init_unicode_iteration( static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( PyObject* text, Py_ssize_t start, Py_ssize_t stop); +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ + #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; @@ -1138,30 +1242,32 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/ -#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ - (((size) <= sizeof(Py_ssize_t)) ? \ - __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \ - __Pyx_GetItemInt_Generic(o, to_py_func(i))) -#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ - (((size) <= sizeof(Py_ssize_t)) ? \ - __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \ - __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \ - (((size) <= sizeof(Py_ssize_t)) ? \ - __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \ - __Pyx_GetItemInt_Generic(o, to_py_func(i))) +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); -#define __Pyx_SetItemInt(o, i, v, size, to_py_func, is_list, wraparound, boundscheck) \ - (((size) <= sizeof(Py_ssize_t)) ? \ - __Pyx_SetItemInt_Fast(o, i, v, is_list, wraparound, boundscheck) : \ - __Pyx_SetItemInt_Generic(o, to_py_func(i), v)) +#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); @@ -1192,11 +1298,15 @@ static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/ +#include + static CYTHON_INLINE PyObject* __Pyx_decode_c_string( const char* cstring, Py_ssize_t start, Py_ssize_t stop, const char* encoding, const char* errors, PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + #define __Pyx_CyFunction_USED 1 #include #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 @@ -1212,28 +1322,30 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { PyCFunctionObject func; - int flags; PyObject *func_dict; PyObject *func_weakreflist; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; + PyObject *func_globals; PyObject *func_code; PyObject *func_closure; PyObject *func_classobj; /* No-args super() class cell */ void *defaults; int defaults_pyobjects; + int flags; PyObject *defaults_tuple; /* Const defaults tuple */ PyObject *defaults_kwdict; /* Const kwonly defaults dict */ PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; /* function annotations dict */ } __pyx_CyFunctionObject; static PyTypeObject *__pyx_CyFunctionType = 0; -#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, code) \ - __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, code) +#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \ + __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *self, PyObject *module, + PyObject *self, + PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, @@ -1246,75 +1358,48 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __Pyx_CyFunction_init(void); -#include - static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/ +static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, + PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/ +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, + PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/ + +static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/ -static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/ +static CYTHON_INLINE TrieData __Pyx_PyInt_As_TrieData(PyObject *); + +static CYTHON_INLINE AlphaChar __Pyx_PyInt_As_AlphaChar(PyObject *); -static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, - PyObject *qualname, PyObject *modname); /*proto*/ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); -static CYTHON_INLINE TrieData __Pyx_PyInt_from_py_TrieData(PyObject *); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_TrieData(TrieData value); -static CYTHON_INLINE AlphaChar __Pyx_PyInt_from_py_AlphaChar(PyObject *); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); -static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_TrieData(TrieData); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); -static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_AlphaChar(AlphaChar); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_AlphaChar(AlphaChar value); #include "descrobject.h" static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/ -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); - -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); - -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); - -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); - -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); - -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); - -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) { PyObject *method, *result = NULL; if (unlikely(!args)) return NULL; method = __Pyx_PyObject_GetAttrStr(obj, method_name); if (unlikely(!method)) goto bad; - result = PyObject_Call(method, args, NULL); + result = __Pyx_PyObject_Call(method, args, NULL); Py_DECREF(method); bad: Py_DECREF(args); @@ -1329,8 +1414,6 @@ static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_ #define __Pyx_PyObject_CallMethod0(obj, name) \ __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple)) -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ - #define __Pyx_Generator_USED #include #include @@ -1346,7 +1429,7 @@ typedef struct { PyObject *classobj; PyObject *yieldfrom; int resume_label; - char is_running; // using T_BOOL for property below requires char value + char is_running; } __pyx_GeneratorObject; static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, PyObject *closure); @@ -1393,22 +1476,22 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Module declarations from 'cdatrie' */ /* Module declarations from 'datrie' */ +static PyTypeObject *__pyx_ptype_6datrie_BaseTrie = 0; +static PyTypeObject *__pyx_ptype_6datrie_Trie = 0; +static PyTypeObject *__pyx_ptype_6datrie__TrieState = 0; +static PyTypeObject *__pyx_ptype_6datrie_BaseState = 0; +static PyTypeObject *__pyx_ptype_6datrie_State = 0; static PyTypeObject *__pyx_ptype_6datrie__TrieIterator = 0; +static PyTypeObject *__pyx_ptype_6datrie_BaseIterator = 0; static PyTypeObject *__pyx_ptype_6datrie_Iterator = 0; static PyTypeObject *__pyx_ptype_6datrie_AlphaMap = 0; -static PyTypeObject *__pyx_ptype_6datrie__TrieState = 0; -static PyTypeObject *__pyx_ptype_6datrie_State = 0; -static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_3_iter_prefix_items = 0; -static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_4_iter_prefix_values = 0; -static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_2_iter_prefix_values = 0; -static PyTypeObject *__pyx_ptype_6datrie_BaseTrie = 0; -static PyTypeObject *__pyx_ptype_6datrie_Trie = 0; static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct__iter_prefixes = 0; static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_1_iter_prefix_items = 0; -static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0; -static PyTypeObject *__pyx_ptype_6datrie_BaseIterator = 0; +static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_2_iter_prefix_values = 0; +static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_3_iter_prefix_items = 0; +static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_4_iter_prefix_values = 0; static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_5_to_ranges = 0; -static PyTypeObject *__pyx_ptype_6datrie_BaseState = 0; +static PyTypeObject *__pyx_ptype_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0; static Trie *__pyx_f_6datrie__load_from_file(PyObject *); /*proto*/ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *); /*proto*/ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *, struct __pyx_opt_args_6datrie_unicode_from_alpha_char *__pyx_optional_args); /*proto*/ @@ -1448,15 +1531,16 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_28iter_prefixes(struct __pyx_obj_6da static PyObject *__pyx_pf_6datrie_8BaseTrie_31iter_prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ static PyObject *__pyx_pf_6datrie_8BaseTrie_34iter_prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_39prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_51items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_53keys(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_55values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_39suffixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_43prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_item(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_49longest_prefix_value(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_51has_keys_with_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_53items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_55keys(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ +static PyObject *__pyx_pf_6datrie_8BaseTrie_57values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */ static int __pyx_pf_6datrie_4Trie___init__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_alphabet, PyObject *__pyx_v_ranges, struct __pyx_obj_6datrie_AlphaMap *__pyx_v_alpha_map, PyObject *__pyx_v__create); /* proto */ static PyObject *__pyx_pf_6datrie_4Trie_2__getitem__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key); /* proto */ static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /* proto */ @@ -1502,248 +1586,261 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self static PyObject *__pyx_pf_6datrie_to_ranges(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lst); /* proto */ static PyObject *__pyx_pf_6datrie_3alphabet_to_ranges(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_alphabet); /* proto */ static PyObject *__pyx_pf_6datrie_6new(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_alphabet, PyObject *__pyx_v_ranges, struct __pyx_obj_6datrie_AlphaMap *__pyx_v_alpha_map); /* proto */ +static PyObject *__pyx_tp_new_6datrie_BaseTrie(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie_Trie(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie__TrieState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie_BaseState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie_State(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie__TrieIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie_BaseIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie_Iterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie_AlphaMap(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie__TrieState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie_State(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie_BaseTrie(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie_Trie(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct__iter_prefixes(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_1_iter_prefix_items(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie_BaseIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_5_to_ranges(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_6datrie_BaseState(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static char __pyx_k_2[] = "Please provide alphabet, ranges or alpha_map argument."; -static char __pyx_k_5[] = "Can't open file descriptor"; -static char __pyx_k_7[] = "Can't write to file"; -static char __pyx_k_18[] = "data:%d, term:%s, leaf:%s, single: %s"; -static char __pyx_k_19[] = "Can't load trie from stream"; -static char __pyx_k_21[] = "range begin > end"; -static char __pyx_k_23[] = "to_ranges.."; -static char __pyx_k_24[] = "datrie.new is deprecated; please use datrie.Trie."; -static char __pyx_k_25[] = "\nCython wrapper for libdatrie.\n"; -static char __pyx_k_28[] = "/Users/jared/Python/datrie/src/datrie.pyx"; -static char __pyx_k_33[] = "to_ranges (line 994)"; -static char __pyx_k_34[] = "\n Converts a list of numbers to a list of ranges::\n\n >>> numbers = [1,2,3,5,6]\n >>> list(to_ranges(numbers))\n [(1, 3), (5, 6)]\n "; -static char __pyx_k__a[] = "a"; -static char __pyx_k__b[] = "b"; -static char __pyx_k__r[] = "r"; -static char __pyx_k__w[] = "w"; -static char __pyx_k__rb[] = "rb"; -static char __pyx_k__wb[] = "wb"; -static char __pyx_k__end[] = "end"; -static char __pyx_k__key[] = "key"; -static char __pyx_k__lst[] = "lst"; -static char __pyx_k__map[] = "map"; -static char __pyx_k__new[] = "new"; -static char __pyx_k__ord[] = "ord"; -static char __pyx_k__sys[] = "sys"; -static char __pyx_k__args[] = "args"; -static char __pyx_k__data[] = "data"; -static char __pyx_k__dump[] = "dump"; -static char __pyx_k__keys[] = "keys"; -static char __pyx_k__load[] = "load"; -static char __pyx_k__next[] = "next"; -static char __pyx_k__open[] = "open"; -static char __pyx_k__read[] = "read"; -static char __pyx_k__seek[] = "seek"; -static char __pyx_k__send[] = "send"; -static char __pyx_k__trie[] = "trie"; -static char __pyx_k__walk[] = "walk"; -static char __pyx_k__warn[] = "warn"; -static char __pyx_k__begin[] = "begin"; -static char __pyx_k__close[] = "close"; -static char __pyx_k__flush[] = "flush"; -static char __pyx_k__items[] = "items"; -static char __pyx_k__state[] = "state"; -static char __pyx_k__super[] = "super"; -static char __pyx_k__throw[] = "throw"; -static char __pyx_k__value[] = "value"; -static char __pyx_k__write[] = "write"; -static char __pyx_k__datrie[] = "datrie"; -static char __pyx_k__fileno[] = "fileno"; -static char __pyx_k__object[] = "object"; -static char __pyx_k__pickle[] = "pickle"; -static char __pyx_k__prefix[] = "prefix"; -static char __pyx_k__ranges[] = "ranges"; -static char __pyx_k__rewind[] = "rewind"; -static char __pyx_k__sorted[] = "sorted"; -static char __pyx_k__values[] = "values"; -static char __pyx_k__IOError[] = "IOError"; -static char __pyx_k___create[] = "_create"; -static char __pyx_k__cPickle[] = "cPickle"; -static char __pyx_k__copy_to[] = "copy_to"; -static char __pyx_k__default[] = "default"; -static char __pyx_k__groupby[] = "groupby"; -static char __pyx_k__is_leaf[] = "is_leaf"; -static char __pyx_k__KeyError[] = "KeyError"; -static char __pyx_k____exit__[] = "__exit__"; -static char __pyx_k____init__[] = "__init__"; -static char __pyx_k____main__[] = "__main__"; -static char __pyx_k____test__[] = "__test__"; -static char __pyx_k___delitem[] = "_delitem"; -static char __pyx_k__alphabet[] = "alphabet"; -static char __pyx_k__is_dirty[] = "is_dirty"; -static char __pyx_k__protocol[] = "protocol"; -static char __pyx_k__warnings[] = "warnings"; -static char __pyx_k__Exception[] = "Exception"; -static char __pyx_k____class__[] = "__class__"; -static char __pyx_k____enter__[] = "__enter__"; -static char __pyx_k__add_range[] = "add_range"; -static char __pyx_k__alpha_map[] = "alpha_map"; -static char __pyx_k__enumerate[] = "enumerate"; -static char __pyx_k__is_single[] = "is_single"; -static char __pyx_k__itertools[] = "itertools"; -static char __pyx_k__to_ranges[] = "to_ranges"; -static char __pyx_k__utf_32_le[] = "utf_32_le"; -static char __pyx_k__ValueError[] = "ValueError"; -static char __pyx_k____import__[] = "__import__"; -static char __pyx_k____module__[] = "__module__"; -static char __pyx_k___add_range[] = "_add_range"; -static char __pyx_k__DatrieError[] = "DatrieError"; -static char __pyx_k__ImportError[] = "ImportError"; -static char __pyx_k__MemoryError[] = "MemoryError"; -static char __pyx_k____unicode__[] = "__unicode__"; -static char __pyx_k__is_terminal[] = "is_terminal"; -static char __pyx_k____qualname__[] = "__qualname__"; -static char __pyx_k__add_alphabet[] = "add_alphabet"; -static char __pyx_k____metaclass__[] = "__metaclass__"; -static char __pyx_k__DELETED_OBJECT[] = "DELETED_OBJECT"; -static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__"; -static char __pyx_k__RAISE_KEY_ERROR[] = "RAISE_KEY_ERROR"; -static char __pyx_k__RERAISE_KEY_ERROR[] = "RERAISE_KEY_ERROR"; -static char __pyx_k__iter_prefix_items[] = "iter_prefix_items"; -static char __pyx_k__DeprecationWarning[] = "DeprecationWarning"; -static char __pyx_k__alphabet_to_ranges[] = "alphabet_to_ranges"; -static char __pyx_k__iter_prefix_values[] = "iter_prefix_values"; -static PyObject *__pyx_kp_u_18; -static PyObject *__pyx_kp_s_19; -static PyObject *__pyx_kp_s_2; -static PyObject *__pyx_kp_s_21; -static PyObject *__pyx_n_s_23; -static PyObject *__pyx_kp_s_24; -static PyObject *__pyx_kp_s_28; -static PyObject *__pyx_kp_u_33; -static PyObject *__pyx_kp_u_34; -static PyObject *__pyx_kp_s_5; -static PyObject *__pyx_kp_s_7; -static PyObject *__pyx_n_s__DELETED_OBJECT; -static PyObject *__pyx_n_s__DatrieError; -static PyObject *__pyx_n_s__DeprecationWarning; -static PyObject *__pyx_n_s__Exception; -static PyObject *__pyx_n_s__IOError; -static PyObject *__pyx_n_s__ImportError; -static PyObject *__pyx_n_s__KeyError; -static PyObject *__pyx_n_s__MemoryError; -static PyObject *__pyx_n_s__RAISE_KEY_ERROR; -static PyObject *__pyx_n_s__RERAISE_KEY_ERROR; -static PyObject *__pyx_n_s__ValueError; -static PyObject *__pyx_n_s____class__; -static PyObject *__pyx_n_s____enter__; -static PyObject *__pyx_n_s____exit__; -static PyObject *__pyx_n_s____import__; -static PyObject *__pyx_n_s____init__; -static PyObject *__pyx_n_s____main__; -static PyObject *__pyx_n_s____metaclass__; -static PyObject *__pyx_n_s____module__; -static PyObject *__pyx_n_s____pyx_vtable__; -static PyObject *__pyx_n_s____qualname__; -static PyObject *__pyx_n_s____test__; -static PyObject *__pyx_n_s____unicode__; -static PyObject *__pyx_n_s___add_range; -static PyObject *__pyx_n_s___create; -static PyObject *__pyx_n_s___delitem; -static PyObject *__pyx_n_s__a; -static PyObject *__pyx_n_s__add_alphabet; -static PyObject *__pyx_n_s__add_range; -static PyObject *__pyx_n_s__alpha_map; -static PyObject *__pyx_n_s__alphabet; -static PyObject *__pyx_n_s__alphabet_to_ranges; -static PyObject *__pyx_n_s__args; -static PyObject *__pyx_n_s__b; -static PyObject *__pyx_n_s__begin; -static PyObject *__pyx_n_s__cPickle; -static PyObject *__pyx_n_s__close; -static PyObject *__pyx_n_s__copy_to; -static PyObject *__pyx_n_s__data; -static PyObject *__pyx_n_s__datrie; -static PyObject *__pyx_n_s__default; -static PyObject *__pyx_n_s__dump; -static PyObject *__pyx_n_s__end; -static PyObject *__pyx_n_s__enumerate; -static PyObject *__pyx_n_s__fileno; -static PyObject *__pyx_n_s__flush; -static PyObject *__pyx_n_s__groupby; -static PyObject *__pyx_n_s__is_dirty; -static PyObject *__pyx_n_s__is_leaf; -static PyObject *__pyx_n_s__is_single; -static PyObject *__pyx_n_s__is_terminal; -static PyObject *__pyx_n_s__items; -static PyObject *__pyx_n_s__iter_prefix_items; -static PyObject *__pyx_n_s__iter_prefix_values; -static PyObject *__pyx_n_s__itertools; -static PyObject *__pyx_n_s__key; -static PyObject *__pyx_n_s__keys; -static PyObject *__pyx_n_s__load; -static PyObject *__pyx_n_s__lst; -static PyObject *__pyx_n_s__map; -static PyObject *__pyx_n_s__new; -static PyObject *__pyx_n_s__next; -static PyObject *__pyx_n_s__object; -static PyObject *__pyx_n_s__open; -static PyObject *__pyx_n_s__ord; -static PyObject *__pyx_n_s__pickle; -static PyObject *__pyx_n_s__prefix; -static PyObject *__pyx_n_s__protocol; -static PyObject *__pyx_n_s__ranges; -static PyObject *__pyx_n_s__rb; -static PyObject *__pyx_n_s__read; -static PyObject *__pyx_n_s__rewind; -static PyObject *__pyx_n_s__seek; -static PyObject *__pyx_n_s__send; -static PyObject *__pyx_n_s__sorted; -static PyObject *__pyx_n_s__state; -static PyObject *__pyx_n_s__super; -static PyObject *__pyx_n_s__sys; -static PyObject *__pyx_n_s__throw; -static PyObject *__pyx_n_s__to_ranges; -static PyObject *__pyx_n_s__trie; -static PyObject *__pyx_n_s__value; -static PyObject *__pyx_n_s__values; -static PyObject *__pyx_n_s__walk; -static PyObject *__pyx_n_s__warn; -static PyObject *__pyx_n_s__warnings; -static PyObject *__pyx_n_s__wb; -static PyObject *__pyx_n_s__write; +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_a[] = "a"; +static char __pyx_k_b[] = "b"; +static char __pyx_k_r[] = "r"; +static char __pyx_k_w[] = "w"; +static char __pyx_k__7[] = ""; +static char __pyx_k_rb[] = "rb"; +static char __pyx_k_wb[] = "wb"; +static char __pyx_k_doc[] = "__doc__"; +static char __pyx_k_end[] = "end"; +static char __pyx_k_key[] = "key"; +static char __pyx_k_lst[] = "lst"; +static char __pyx_k_map[] = "map"; +static char __pyx_k_new[] = "new"; +static char __pyx_k_ord[] = "ord"; +static char __pyx_k_sys[] = "sys"; +static char __pyx_k_args[] = "args"; +static char __pyx_k_data[] = "data"; +static char __pyx_k_dump[] = "dump"; +static char __pyx_k_exit[] = "__exit__"; +static char __pyx_k_init[] = "__init__"; +static char __pyx_k_keys[] = "keys"; +static char __pyx_k_load[] = "load"; +static char __pyx_k_main[] = "__main__"; +static char __pyx_k_next[] = "next"; +static char __pyx_k_open[] = "open"; +static char __pyx_k_read[] = "read"; +static char __pyx_k_seek[] = "seek"; +static char __pyx_k_send[] = "send"; +static char __pyx_k_test[] = "__test__"; +static char __pyx_k_trie[] = "trie"; +static char __pyx_k_walk[] = "walk"; +static char __pyx_k_warn[] = "warn"; +static char __pyx_k_begin[] = "begin"; +static char __pyx_k_close[] = "close"; +static char __pyx_k_enter[] = "__enter__"; +static char __pyx_k_flush[] = "flush"; +static char __pyx_k_items[] = "items"; +static char __pyx_k_state[] = "state"; +static char __pyx_k_super[] = "super"; +static char __pyx_k_throw[] = "throw"; +static char __pyx_k_value[] = "value"; +static char __pyx_k_write[] = "write"; +static char __pyx_k_create[] = "_create"; +static char __pyx_k_datrie[] = "datrie"; +static char __pyx_k_fileno[] = "fileno"; +static char __pyx_k_import[] = "__import__"; +static char __pyx_k_module[] = "__module__"; +static char __pyx_k_object[] = "object"; +static char __pyx_k_pickle[] = "pickle"; +static char __pyx_k_prefix[] = "prefix"; +static char __pyx_k_ranges[] = "ranges"; +static char __pyx_k_rewind[] = "rewind"; +static char __pyx_k_sorted[] = "sorted"; +static char __pyx_k_values[] = "values"; +static char __pyx_k_IOError[] = "IOError"; +static char __pyx_k_cPickle[] = "cPickle"; +static char __pyx_k_copy_to[] = "copy_to"; +static char __pyx_k_default[] = "default"; +static char __pyx_k_delitem[] = "_delitem"; +static char __pyx_k_groupby[] = "groupby"; +static char __pyx_k_is_leaf[] = "is_leaf"; +static char __pyx_k_prepare[] = "__prepare__"; +static char __pyx_k_unicode[] = "__unicode__"; +static char __pyx_k_KeyError[] = "KeyError"; +static char __pyx_k_alphabet[] = "alphabet"; +static char __pyx_k_is_dirty[] = "is_dirty"; +static char __pyx_k_protocol[] = "protocol"; +static char __pyx_k_qualname[] = "__qualname__"; +static char __pyx_k_suffixes[] = "suffixes"; +static char __pyx_k_warnings[] = "warnings"; +static char __pyx_k_Exception[] = "Exception"; +static char __pyx_k_add_range[] = "add_range"; +static char __pyx_k_alpha_map[] = "alpha_map"; +static char __pyx_k_enumerate[] = "enumerate"; +static char __pyx_k_is_single[] = "is_single"; +static char __pyx_k_itertools[] = "itertools"; +static char __pyx_k_metaclass[] = "__metaclass__"; +static char __pyx_k_to_ranges[] = "to_ranges"; +static char __pyx_k_utf_32_le[] = "utf_32_le"; +static char __pyx_k_ValueError[] = "ValueError"; +static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static char __pyx_k_DatrieError[] = "DatrieError"; +static char __pyx_k_ImportError[] = "ImportError"; +static char __pyx_k_MemoryError[] = "MemoryError"; +static char __pyx_k_add_range_2[] = "_add_range"; +static char __pyx_k_is_terminal[] = "is_terminal"; +static char __pyx_k_add_alphabet[] = "add_alphabet"; +static char __pyx_k_DELETED_OBJECT[] = "DELETED_OBJECT"; +static char __pyx_k_RAISE_KEY_ERROR[] = "RAISE_KEY_ERROR"; +static char __pyx_k_range_begin_end[] = "range begin > end"; +static char __pyx_k_RERAISE_KEY_ERROR[] = "RERAISE_KEY_ERROR"; +static char __pyx_k_iter_prefix_items[] = "iter_prefix_items"; +static char __pyx_k_DeprecationWarning[] = "DeprecationWarning"; +static char __pyx_k_alphabet_to_ranges[] = "alphabet_to_ranges"; +static char __pyx_k_iter_prefix_values[] = "iter_prefix_values"; +static char __pyx_k_Can_t_write_to_file[] = "Can't write to file"; +static char __pyx_k_to_ranges_line_1017[] = "to_ranges (line 1017)"; +static char __pyx_k_to_ranges_locals_lambda[] = "to_ranges.."; +static char __pyx_k_Can_t_open_file_descriptor[] = "Can't open file descriptor"; +static char __pyx_k_Can_t_load_trie_from_stream[] = "Can't load trie from stream"; +static char __pyx_k_Cython_wrapper_for_libdatrie[] = "\nCython wrapper for libdatrie.\n"; +static char __pyx_k_data_d_term_s_leaf_s_single_s[] = "data:%d, term:%s, leaf:%s, single: %s"; +static char __pyx_k_Converts_a_list_of_numbers_to_a[] = "\n Converts a list of numbers to a list of ranges::\n\n >>> numbers = [1,2,3,5,6]\n >>> list(to_ranges(numbers))\n [(1, 3), (5, 6)]\n "; +static char __pyx_k_datrie_new_is_deprecated_please[] = "datrie.new is deprecated; please use datrie.Trie."; +static char __pyx_k_home_striky_mywspace_datrie_xmo[] = "/home/striky/mywspace/datrie-xmon-dev/src/datrie.pyx"; +static char __pyx_k_Please_provide_alphabet_ranges_o[] = "Please provide alphabet, ranges or alpha_map argument."; +static PyObject *__pyx_kp_s_Can_t_load_trie_from_stream; +static PyObject *__pyx_kp_s_Can_t_open_file_descriptor; +static PyObject *__pyx_kp_s_Can_t_write_to_file; +static PyObject *__pyx_kp_u_Converts_a_list_of_numbers_to_a; +static PyObject *__pyx_n_s_DELETED_OBJECT; +static PyObject *__pyx_n_s_DatrieError; +static PyObject *__pyx_n_s_DeprecationWarning; +static PyObject *__pyx_n_s_Exception; +static PyObject *__pyx_n_s_IOError; +static PyObject *__pyx_n_s_ImportError; +static PyObject *__pyx_n_s_KeyError; +static PyObject *__pyx_n_s_MemoryError; +static PyObject *__pyx_kp_s_Please_provide_alphabet_ranges_o; +static PyObject *__pyx_n_s_RAISE_KEY_ERROR; +static PyObject *__pyx_n_s_RERAISE_KEY_ERROR; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_kp_u__7; +static PyObject *__pyx_n_s_a; +static PyObject *__pyx_n_s_add_alphabet; +static PyObject *__pyx_n_s_add_range; +static PyObject *__pyx_n_s_add_range_2; +static PyObject *__pyx_n_s_alpha_map; +static PyObject *__pyx_n_s_alphabet; +static PyObject *__pyx_n_s_alphabet_to_ranges; +static PyObject *__pyx_n_s_args; +static PyObject *__pyx_n_s_b; +static PyObject *__pyx_n_s_begin; +static PyObject *__pyx_n_s_cPickle; +static PyObject *__pyx_n_s_close; +static PyObject *__pyx_n_s_copy_to; +static PyObject *__pyx_n_s_create; +static PyObject *__pyx_n_s_data; +static PyObject *__pyx_kp_u_data_d_term_s_leaf_s_single_s; +static PyObject *__pyx_n_s_datrie; +static PyObject *__pyx_kp_s_datrie_new_is_deprecated_please; +static PyObject *__pyx_n_s_default; +static PyObject *__pyx_n_s_delitem; +static PyObject *__pyx_n_s_doc; +static PyObject *__pyx_n_s_dump; +static PyObject *__pyx_n_s_end; +static PyObject *__pyx_n_s_enter; +static PyObject *__pyx_n_s_enumerate; +static PyObject *__pyx_n_s_exit; +static PyObject *__pyx_n_s_fileno; +static PyObject *__pyx_n_s_flush; +static PyObject *__pyx_n_s_groupby; +static PyObject *__pyx_kp_s_home_striky_mywspace_datrie_xmo; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_init; +static PyObject *__pyx_n_s_is_dirty; +static PyObject *__pyx_n_s_is_leaf; +static PyObject *__pyx_n_s_is_single; +static PyObject *__pyx_n_s_is_terminal; +static PyObject *__pyx_n_s_items; +static PyObject *__pyx_n_s_iter_prefix_items; +static PyObject *__pyx_n_s_iter_prefix_values; +static PyObject *__pyx_n_s_itertools; +static PyObject *__pyx_n_s_key; +static PyObject *__pyx_n_s_keys; +static PyObject *__pyx_n_s_load; +static PyObject *__pyx_n_s_lst; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_map; +static PyObject *__pyx_n_s_metaclass; +static PyObject *__pyx_n_s_module; +static PyObject *__pyx_n_s_new; +static PyObject *__pyx_n_s_next; +static PyObject *__pyx_n_s_object; +static PyObject *__pyx_n_s_open; +static PyObject *__pyx_n_s_ord; +static PyObject *__pyx_n_s_pickle; +static PyObject *__pyx_n_s_prefix; +static PyObject *__pyx_n_s_prepare; +static PyObject *__pyx_n_s_protocol; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_qualname; +static PyObject *__pyx_kp_s_range_begin_end; +static PyObject *__pyx_n_s_ranges; +static PyObject *__pyx_n_s_rb; +static PyObject *__pyx_n_s_read; +static PyObject *__pyx_n_s_rewind; +static PyObject *__pyx_n_s_seek; +static PyObject *__pyx_n_s_send; +static PyObject *__pyx_n_s_sorted; +static PyObject *__pyx_n_s_state; +static PyObject *__pyx_n_s_suffixes; +static PyObject *__pyx_n_s_super; +static PyObject *__pyx_n_s_sys; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_throw; +static PyObject *__pyx_n_s_to_ranges; +static PyObject *__pyx_kp_u_to_ranges_line_1017; +static PyObject *__pyx_n_s_to_ranges_locals_lambda; +static PyObject *__pyx_n_s_trie; +static PyObject *__pyx_n_s_unicode; +static PyObject *__pyx_n_s_value; +static PyObject *__pyx_n_s_values; +static PyObject *__pyx_n_s_walk; +static PyObject *__pyx_n_s_warn; +static PyObject *__pyx_n_s_warnings; +static PyObject *__pyx_n_s_wb; +static PyObject *__pyx_n_s_write; static PyObject *__pyx_int_0; static PyObject *__pyx_int_2; -static PyObject *__pyx_k_1; -static PyObject *__pyx_k_10; -static PyObject *__pyx_k_11; -static PyObject *__pyx_k_12; -static PyObject *__pyx_k_13; -static PyObject *__pyx_k_14; -static PyObject *__pyx_k_15; -static PyObject *__pyx_k_16; -static PyObject *__pyx_k_17; -static PyObject *__pyx_k_tuple_3; -static PyObject *__pyx_k_tuple_4; -static PyObject *__pyx_k_tuple_6; -static PyObject *__pyx_k_tuple_8; -static PyObject *__pyx_k_tuple_9; -static PyObject *__pyx_k_tuple_20; -static PyObject *__pyx_k_tuple_22; -static PyObject *__pyx_k_tuple_26; -static PyObject *__pyx_k_tuple_29; -static PyObject *__pyx_k_tuple_31; -static PyObject *__pyx_k_codeobj_27; -static PyObject *__pyx_k_codeobj_30; -static PyObject *__pyx_k_codeobj_32; +static PyObject *__pyx_k__8; +static PyObject *__pyx_k__9; +static PyObject *__pyx_k__10; +static PyObject *__pyx_k__11; +static PyObject *__pyx_k__12; +static PyObject *__pyx_k__13; +static PyObject *__pyx_k__14; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__19; +static PyObject *__pyx_tuple__21; +static PyObject *__pyx_codeobj__18; +static PyObject *__pyx_codeobj__20; +static PyObject *__pyx_codeobj__22; + +/* "datrie.pyx":38 + * cdef cdatrie.Trie *_c_trie + * + * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< + * """ + * For efficiency trie needs to know what unicode symbols + */ /* Python wrapper */ static int __pyx_pw_6datrie_8BaseTrie_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ @@ -1763,20 +1860,12 @@ static int __pyx_pw_6datrie_8BaseTrie_1__init__(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alphabet,&__pyx_n_s__ranges,&__pyx_n_s__alpha_map,&__pyx_n_s___create,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alphabet,&__pyx_n_s_ranges,&__pyx_n_s_alpha_map,&__pyx_n_s_create,0}; PyObject* values[4] = {0,0,0,0}; - - /* "datrie.pyx":38 - * cdef cdatrie.Trie *_c_trie - * - * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< - * """ - * For efficiency trie needs to know what unicode symbols - */ values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); values[2] = (PyObject *)((struct __pyx_obj_6datrie_AlphaMap *)Py_None); - values[3] = __pyx_k_1; + values[3] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -1792,22 +1881,22 @@ static int __pyx_pw_6datrie_8BaseTrie_1__init__(PyObject *__pyx_v_self, PyObject switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alphabet); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ranges); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ranges); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_map); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha_map); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s___create); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_create); if (value) { values[3] = value; kw_args--; } } } @@ -1839,6 +1928,8 @@ static int __pyx_pw_6datrie_8BaseTrie_1__init__(PyObject *__pyx_v_self, PyObject __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alpha_map), __pyx_ptype_6datrie_AlphaMap, 1, "alpha_map", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie___init__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_alphabet, __pyx_v_ranges, __pyx_v_alpha_map, __pyx_v__create); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -1881,9 +1972,7 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie */ __pyx_r = 0; goto __pyx_L0; - goto __pyx_L3; } - __pyx_L3:; /* "datrie.pyx":49 * return @@ -1905,9 +1994,7 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie */ __pyx_r = 0; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; /* "datrie.pyx":52 * return @@ -1938,14 +2025,12 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie * * if alpha_map is None: */ - __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; } - __pyx_L5:; /* "datrie.pyx":55 * raise ValueError("Please provide alphabet, ranges or alpha_map argument.") @@ -1973,11 +2058,10 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie __Pyx_INCREF(__pyx_v_ranges); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ranges); __Pyx_GIVEREF(__pyx_v_ranges); - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_AlphaMap)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_AlphaMap)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_alpha_map)); - __pyx_v_alpha_map = ((struct __pyx_obj_6datrie_AlphaMap *)__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF_SET(__pyx_v_alpha_map, ((struct __pyx_obj_6datrie_AlphaMap *)__pyx_t_6)); __pyx_t_6 = 0; goto __pyx_L6; } @@ -2010,10 +2094,17 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie * def __dealloc__(self): */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; } - __pyx_L7:; + /* "datrie.pyx":38 + * cdef cdatrie.Trie *_c_trie + * + * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< + * """ + * For efficiency trie needs to know what unicode symbols + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -2027,23 +2118,25 @@ static int __pyx_pf_6datrie_8BaseTrie___init__(struct __pyx_obj_6datrie_BaseTrie return __pyx_r; } +/* "datrie.pyx":62 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._c_trie is not NULL: + * cdatrie.trie_free(self._c_trie) + */ + /* Python wrapper */ static void __pyx_pw_6datrie_8BaseTrie_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6datrie_8BaseTrie_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6datrie_8BaseTrie_2__dealloc__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":62 - * raise MemoryError() - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._c_trie is not NULL: - * cdatrie.trie_free(self._c_trie) - */ - static void __pyx_pf_6datrie_8BaseTrie_2__dealloc__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -2071,6 +2164,15 @@ static void __pyx_pf_6datrie_8BaseTrie_2__dealloc__(struct __pyx_obj_6datrie_Bas } __pyx_L3:; + /* "datrie.pyx":62 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._c_trie is not NULL: + * cdatrie.trie_free(self._c_trie) + */ + + /* function exit code */ __Pyx_RefNannyFinishContext(); } @@ -2097,10 +2199,10 @@ static int __pyx_f_6datrie_8BaseTrie_is_dirty(struct __pyx_obj_6datrie_BaseTrie if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_dirty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_dirty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_5is_dirty)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2121,12 +2223,19 @@ static int __pyx_f_6datrie_8BaseTrie_is_dirty(struct __pyx_obj_6datrie_BaseTrie __pyx_r = trie_is_dirty(__pyx_v_self->_c_trie); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":66 + * cdatrie.trie_free(self._c_trie) + * + * cpdef bint is_dirty(self): # <<<<<<<<<<<<<< + * """ + * Returns True if the trie is dirty with some pending changes + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie.BaseTrie.is_dirty", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie.BaseTrie.is_dirty", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -2141,18 +2250,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_5is_dirty(PyObject *__pyx_v_self, CY __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_dirty (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_4is_dirty(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":66 - * cdatrie.trie_free(self._c_trie) - * - * cpdef bint is_dirty(self): # <<<<<<<<<<<<<< - * """ - * Returns True if the trie is dirty with some pending changes - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_4is_dirty(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -2168,8 +2271,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_4is_dirty(struct __pyx_obj_6datrie_B __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.is_dirty", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -2180,26 +2282,28 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_4is_dirty(struct __pyx_obj_6datrie_B return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_7save(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ +/* "datrie.pyx":73 + * return cdatrie.trie_is_dirty(self._c_trie) + * + * def save(self, path): # <<<<<<<<<<<<<< + * """ + * Saves this trie. + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_6datrie_8BaseTrie_7save(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_6save[] = "\n Saves this trie.\n "; static PyObject *__pyx_pw_6datrie_8BaseTrie_7save(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("save (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_6save(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject *)__pyx_v_path)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":73 - * return cdatrie.trie_is_dirty(self._c_trie) - * - * def save(self, path): # <<<<<<<<<<<<<< - * """ - * Saves this trie. - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_path) { PyObject *__pyx_v_f = NULL; PyObject *__pyx_r = NULL; @@ -2212,8 +2316,8 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -2233,20 +2337,20 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT __Pyx_INCREF(__pyx_v_path); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_path); __Pyx_GIVEREF(__pyx_v_path); - __Pyx_INCREF(((PyObject *)__pyx_n_s__wb)); - PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__wb)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__wb)); + __Pyx_INCREF(__pyx_n_s_wb); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_wb); + __Pyx_GIVEREF(__pyx_n_s_wb); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2268,17 +2372,17 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT * * def write(self, f): */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -2303,36 +2407,25 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __pyx_t_8 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_9 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - __pyx_t_11 = ((!(__pyx_t_9 != 0)) != 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_10 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __pyx_t_11 = ((!(__pyx_t_10 != 0)) != 0); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_4); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - goto __pyx_L18; } - __pyx_L18:; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -2353,15 +2446,17 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT } } /*finally:*/ { - if (__pyx_t_3) { - __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_4, NULL); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_11 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*normal exit:*/{ + if (__pyx_t_3) { + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__2, NULL); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + goto __pyx_L6; } + __pyx_L6:; } goto __pyx_L19; __pyx_L3_error:; @@ -2370,6 +2465,15 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT __pyx_L19:; } + /* "datrie.pyx":73 + * return cdatrie.trie_is_dirty(self._c_trie) + * + * def save(self, path): # <<<<<<<<<<<<<< + * """ + * Saves this trie. + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -2386,6 +2490,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_6save(struct __pyx_obj_6datrie_BaseT return __pyx_r; } +/* "datrie.pyx":80 + * self.write(f) + * + * def write(self, f): # <<<<<<<<<<<<<< + * """ + * Writes a trie to a file. File-like objects without real + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_9write(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_8write[] = "\n Writes a trie to a file. File-like objects without real\n file descriptors are not supported.\n "; @@ -2394,18 +2506,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_9write(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_8write(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject *)__pyx_v_f)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":80 - * self.write(f) - * - * def write(self, f): # <<<<<<<<<<<<<< - * """ - * Writes a trie to a file. File-like objects without real - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_f) { FILE *__pyx_v_f_ptr; int __pyx_v_res; @@ -2427,9 +2533,9 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base * * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(f.fileno(), "w") */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2441,14 +2547,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base * if f_ptr == NULL: * raise IOError("Can't open file descriptor") */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s__fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_f_ptr = fdopen(__pyx_t_3, __pyx_k__w); + __pyx_v_f_ptr = fdopen(__pyx_t_3, __pyx_k_w); /* "datrie.pyx":88 * @@ -2467,14 +2573,12 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base * * cdef int res = cdatrie.trie_fwrite(self._c_trie, f_ptr) */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; } - __pyx_L3:; /* "datrie.pyx":91 * raise IOError("Can't open file descriptor") @@ -2502,14 +2606,12 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base * * stdio.fflush(f_ptr) */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; } - __pyx_L4:; /* "datrie.pyx":95 * raise IOError("Can't write to file") @@ -2520,6 +2622,15 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base */ fflush(__pyx_v_f_ptr); + /* "datrie.pyx":80 + * self.write(f) + * + * def write(self, f): # <<<<<<<<<<<<<< + * """ + * Writes a trie to a file. File-like objects without real + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -2533,6 +2644,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_8write(struct __pyx_obj_6datrie_Base return __pyx_r; } +/* "datrie.pyx":99 + * + * @classmethod + * def load(cls, path): # <<<<<<<<<<<<<< + * """ + * Loads a trie from file. + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_11load(PyObject *__pyx_v_cls, PyObject *__pyx_v_path); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_10load[] = "\n Loads a trie from file.\n "; @@ -2541,18 +2660,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_11load(PyObject *__pyx_v_cls, PyObje __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("load (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_10load(((PyObject*)__pyx_v_cls), ((PyObject *)__pyx_v_path)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":99 - * - * @classmethod - * def load(cls, path): # <<<<<<<<<<<<<< - * """ - * Loads a trie from file. - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObject *__pyx_v_path) { PyObject *__pyx_v_f = NULL; PyObject *__pyx_r = NULL; @@ -2565,8 +2678,8 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -2586,20 +2699,20 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje __Pyx_INCREF(__pyx_v_path); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_path); __Pyx_GIVEREF(__pyx_v_path); - __Pyx_INCREF(((PyObject *)__pyx_n_s__rb)); - PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__rb)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb)); + __Pyx_INCREF(__pyx_n_s_rb); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_rb); + __Pyx_GIVEREF(__pyx_n_s_rb); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); - __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2622,17 +2735,17 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje * @classmethod */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s__read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L11_try_return; @@ -2641,12 +2754,6 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L14_try_end; - __pyx_L11_try_return:; - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_XGIVEREF(__pyx_t_6); - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); - goto __pyx_L4; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -2665,36 +2772,25 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __pyx_t_8 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_9 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - __pyx_t_11 = ((!(__pyx_t_9 != 0)) != 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_10 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __pyx_t_11 = ((!(__pyx_t_10 != 0)) != 0); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_4); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} - goto __pyx_L18; } - __pyx_L18:; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -2706,6 +2802,12 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; + __pyx_L11_try_return:; + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); + goto __pyx_L4_return; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); @@ -2715,22 +2817,31 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje } } /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_why = 3; goto __pyx_L6; - __pyx_L6:; - if (__pyx_t_3) { - __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_9, NULL); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_11 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*normal exit:*/{ + if (__pyx_t_3) { + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__5, NULL); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + goto __pyx_L6; } - switch (__pyx_why) { - case 3: goto __pyx_L0; + __pyx_L4_return: { + __pyx_t_7 = __pyx_r; + __pyx_r = 0; + if (__pyx_t_3) { + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__6, NULL); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; } + __pyx_L6:; } goto __pyx_L19; __pyx_L3_error:; @@ -2739,6 +2850,15 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje __pyx_L19:; } + /* "datrie.pyx":99 + * + * @classmethod + * def load(cls, path): # <<<<<<<<<<<<<< + * """ + * Loads a trie from file. + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -2755,6 +2875,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_10load(PyObject *__pyx_v_cls, PyObje return __pyx_r; } +/* "datrie.pyx":107 + * + * @classmethod + * def read(cls, f): # <<<<<<<<<<<<<< + * """ + * Creates a new Trie by reading it from file. + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_13read(PyObject *__pyx_v_cls, PyObject *__pyx_v_f); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_12read[] = "\n Creates a new Trie by reading it from file.\n File-like objects without real file descriptors are not supported.\n\n # XXX: does it work properly in subclasses?\n "; @@ -2763,18 +2891,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_13read(PyObject *__pyx_v_cls, PyObje __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_12read(((PyObject*)__pyx_v_cls), ((PyObject *)__pyx_v_f)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":107 - * - * @classmethod - * def read(cls, f): # <<<<<<<<<<<<<< - * """ - * Creates a new Trie by reading it from file. - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_12read(PyObject *__pyx_v_cls, PyObject *__pyx_v_f) { struct __pyx_obj_6datrie_BaseTrie *__pyx_v_trie = 0; PyObject *__pyx_r = NULL; @@ -2795,14 +2917,11 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_12read(PyObject *__pyx_v_cls, PyObje * return trie */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s___create), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_cls), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_create, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6datrie_BaseTrie))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_trie = ((struct __pyx_obj_6datrie_BaseTrie *)__pyx_t_2); __pyx_t_2 = 0; @@ -2829,8 +2948,15 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_12read(PyObject *__pyx_v_cls, PyObje __pyx_r = ((PyObject *)__pyx_v_trie); goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":107 + * + * @classmethod + * def read(cls, f): # <<<<<<<<<<<<<< + * """ + * Creates a new Trie by reading it from file. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -2843,6 +2969,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_12read(PyObject *__pyx_v_cls, PyObje return __pyx_r; } +/* "datrie.pyx":118 + * return trie + * + * def __setitem__(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * self._setitem(key, value) + * + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8BaseTrie_15__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_arg_value); /*proto*/ static int __pyx_pw_6datrie_8BaseTrie_15__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_arg_value) { @@ -2854,7 +2988,7 @@ static int __pyx_pw_6datrie_8BaseTrie_15__setitem__(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); assert(__pyx_arg_value); { - __pyx_v_value = __Pyx_PyInt_from_py_TrieData(__pyx_arg_value); if (unlikely((__pyx_v_value == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_value = __Pyx_PyInt_As_TrieData(__pyx_arg_value); if (unlikely((__pyx_v_value == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2864,6 +2998,8 @@ static int __pyx_pw_6datrie_8BaseTrie_15__setitem__(PyObject *__pyx_v_self, PyOb __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_14__setitem__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key), ((TrieData)__pyx_v_value)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -2872,14 +3008,6 @@ static int __pyx_pw_6datrie_8BaseTrie_15__setitem__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "datrie.pyx":118 - * return trie - * - * def __setitem__(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< - * self._setitem(key, value) - * - */ - static int __pyx_pf_6datrie_8BaseTrie_14__setitem__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, TrieData __pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -2894,6 +3022,15 @@ static int __pyx_pf_6datrie_8BaseTrie_14__setitem__(struct __pyx_obj_6datrie_Bas */ ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_setitem(__pyx_v_self, __pyx_v_key, __pyx_v_value); + /* "datrie.pyx":118 + * return trie + * + * def __setitem__(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * self._setitem(key, value) + * + */ + + /* function exit code */ __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -2948,12 +3085,33 @@ static void __pyx_f_6datrie_8BaseTrie__setitem(struct __pyx_obj_6datrie_BaseTrie * def __getitem__(self, unicode key): */ /*finally:*/ { - free(__pyx_v_c_key); + /*normal exit:*/{ + free(__pyx_v_c_key); + goto __pyx_L5; + } + __pyx_L5:; } + /* "datrie.pyx":121 + * self._setitem(key, value) + * + * cdef void _setitem(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) + * try: + */ + + /* function exit code */ __Pyx_RefNannyFinishContext(); } +/* "datrie.pyx":128 + * free(c_key) + * + * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< + * return self._getitem(key) + * + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_17__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static PyObject *__pyx_pw_6datrie_8BaseTrie_17__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -2965,6 +3123,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_17__getitem__(PyObject *__pyx_v_self __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_16__getitem__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -2973,14 +3133,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_17__getitem__(PyObject *__pyx_v_self return __pyx_r; } -/* "datrie.pyx":128 - * free(c_key) - * - * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< - * return self._getitem(key) - * - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_16__getitem__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -3000,14 +3152,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_16__getitem__(struct __pyx_obj_6datr */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_getitem(__pyx_v_self, __pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyInt_to_py_TrieData(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_TrieData(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":128 + * free(c_key) + * + * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< + * return self._getitem(key) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("datrie.BaseTrie.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -3076,7 +3235,11 @@ static TrieData __pyx_f_6datrie_8BaseTrie__getitem(struct __pyx_obj_6datrie_Base * if not found: */ /*finally:*/ { - free(__pyx_v_c_key); + /*normal exit:*/{ + free(__pyx_v_c_key); + goto __pyx_L5; + } + __pyx_L5:; } /* "datrie.pyx":140 @@ -3098,18 +3261,16 @@ static TrieData __pyx_f_6datrie_8BaseTrie__getitem(struct __pyx_obj_6datrie_Base */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; } - __pyx_L6:; /* "datrie.pyx":142 * if not found: @@ -3121,8 +3282,15 @@ static TrieData __pyx_f_6datrie_8BaseTrie__getitem(struct __pyx_obj_6datrie_Base __pyx_r = __pyx_v_data; goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":131 + * return self._getitem(key) + * + * cdef cdatrie.TrieData _getitem(self, unicode key) except -1: # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData data + * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); @@ -3133,6 +3301,14 @@ static TrieData __pyx_f_6datrie_8BaseTrie__getitem(struct __pyx_obj_6datrie_Base return __pyx_r; } +/* "datrie.pyx":145 + * + * + * def __contains__(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) + * try: + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8BaseTrie_19__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static int __pyx_pw_6datrie_8BaseTrie_19__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -3144,6 +3320,8 @@ static int __pyx_pw_6datrie_8BaseTrie_19__contains__(PyObject *__pyx_v_self, PyO __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_18__contains__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -3152,18 +3330,11 @@ static int __pyx_pw_6datrie_8BaseTrie_19__contains__(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "datrie.pyx":145 - * - * - * def __contains__(self, unicode key): # <<<<<<<<<<<<<< - * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) - * try: - */ - static int __pyx_pf_6datrie_8BaseTrie_18__contains__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { AlphaChar *__pyx_v_c_key; int __pyx_r; __Pyx_RefNannyDeclarations + int __pyx_t_1; __Pyx_RefNannySetupContext("__contains__", 0); /* "datrie.pyx":146 @@ -3192,7 +3363,7 @@ static int __pyx_pf_6datrie_8BaseTrie_18__contains__(struct __pyx_obj_6datrie_Ba * free(c_key) */ __pyx_r = trie_retrieve(__pyx_v_self->_c_trie, __pyx_v_c_key, NULL); - goto __pyx_L3; + goto __pyx_L3_return; } /* "datrie.pyx":150 @@ -3203,22 +3374,36 @@ static int __pyx_pf_6datrie_8BaseTrie_18__contains__(struct __pyx_obj_6datrie_Ba * def __delitem__(self, unicode key): */ /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L5; - __pyx_L3: __pyx_why = 3; goto __pyx_L5; - __pyx_L5:; - free(__pyx_v_c_key); - switch (__pyx_why) { - case 3: goto __pyx_L0; + __pyx_L3_return: { + __pyx_t_1 = __pyx_r; + free(__pyx_v_c_key); + __pyx_r = __pyx_t_1; + goto __pyx_L0; } } - __pyx_r = 0; + /* "datrie.pyx":145 + * + * + * def __contains__(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) + * try: + */ + + /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } +/* "datrie.pyx":152 + * free(c_key) + * + * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< + * if not self._delitem(key): + * raise KeyError(key) + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8BaseTrie_21__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static int __pyx_pw_6datrie_8BaseTrie_21__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -3230,6 +3415,8 @@ static int __pyx_pw_6datrie_8BaseTrie_21__delitem__(PyObject *__pyx_v_self, PyOb __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_20__delitem__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -3238,14 +3425,6 @@ static int __pyx_pw_6datrie_8BaseTrie_21__delitem__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "datrie.pyx":152 - * free(c_key) - * - * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< - * if not self._delitem(key): - * raise KeyError(key) - */ - static int __pyx_pf_6datrie_8BaseTrie_20__delitem__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -3276,19 +3455,26 @@ static int __pyx_pf_6datrie_8BaseTrie_20__delitem__(struct __pyx_obj_6datrie_Bas */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; } - __pyx_L3:; + /* "datrie.pyx":152 + * free(c_key) + * + * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< + * if not self._delitem(key): + * raise KeyError(key) + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -3326,17 +3512,17 @@ static int __pyx_f_6datrie_8BaseTrie__delitem(struct __pyx_obj_6datrie_BaseTrie if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___delitem); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_delitem); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_23_delitem)) { __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -3372,7 +3558,7 @@ static int __pyx_f_6datrie_8BaseTrie__delitem(struct __pyx_obj_6datrie_BaseTrie * free(c_key) */ __pyx_r = trie_delete(__pyx_v_self->_c_trie, __pyx_v_c_key); - goto __pyx_L3; + goto __pyx_L3_return; } /* "datrie.pyx":165 @@ -3383,23 +3569,28 @@ static int __pyx_f_6datrie_8BaseTrie__delitem(struct __pyx_obj_6datrie_BaseTrie * def __len__(self): */ /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L5; - __pyx_L3: __pyx_why = 3; goto __pyx_L5; - __pyx_L5:; - free(__pyx_v_c_key); - switch (__pyx_why) { - case 3: goto __pyx_L0; + __pyx_L3_return: { + __pyx_t_4 = __pyx_r; + free(__pyx_v_c_key); + __pyx_r = __pyx_t_4; + goto __pyx_L0; } } - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":156 + * raise KeyError(key) + * + * cpdef bint _delitem(self, unicode key): # <<<<<<<<<<<<<< + * """ + * Deletes an entry for the given key from the trie. Returns + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("datrie.BaseTrie._delitem", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie.BaseTrie._delitem", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -3418,6 +3609,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_23_delitem(PyObject *__pyx_v_self, P __Pyx_RefNannySetupContext("_delitem (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_22_delitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -3426,14 +3619,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_23_delitem(PyObject *__pyx_v_self, P return __pyx_r; } -/* "datrie.pyx":156 - * raise KeyError(key) - * - * cpdef bint _delitem(self, unicode key): # <<<<<<<<<<<<<< - * """ - * Deletes an entry for the given key from the trie. Returns - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_22_delitem(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -3449,8 +3634,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_22_delitem(struct __pyx_obj_6datrie_ __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie._delitem", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -3461,6 +3645,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_22_delitem(struct __pyx_obj_6datrie_ return __pyx_r; } +/* "datrie.pyx":167 + * free(c_key) + * + * def __len__(self): # <<<<<<<<<<<<<< + * # XXX: this is very slow + * cdef BaseState s = BaseState(self) + */ + /* Python wrapper */ static Py_ssize_t __pyx_pw_6datrie_8BaseTrie_25__len__(PyObject *__pyx_v_self); /*proto*/ static Py_ssize_t __pyx_pw_6datrie_8BaseTrie_25__len__(PyObject *__pyx_v_self) { @@ -3468,18 +3660,12 @@ static Py_ssize_t __pyx_pw_6datrie_8BaseTrie_25__len__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8BaseTrie_24__len__(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":167 - * free(c_key) - * - * def __len__(self): # <<<<<<<<<<<<<< - * # XXX: this is very slow - * cdef BaseState s = BaseState(self) - */ - static Py_ssize_t __pyx_pf_6datrie_8BaseTrie_24__len__(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self) { struct __pyx_obj_6datrie_BaseState *__pyx_v_s = 0; struct __pyx_obj_6datrie_BaseIterator *__pyx_v_iterator = 0; @@ -3506,9 +3692,9 @@ static Py_ssize_t __pyx_pf_6datrie_8BaseTrie_24__len__(struct __pyx_obj_6datrie_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_s = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_2); __pyx_t_2 = 0; @@ -3524,9 +3710,9 @@ static Py_ssize_t __pyx_pf_6datrie_8BaseTrie_24__len__(struct __pyx_obj_6datrie_ __Pyx_INCREF(((PyObject *)__pyx_v_s)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_s)); __Pyx_GIVEREF(((PyObject *)__pyx_v_s)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_iterator = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; @@ -3570,8 +3756,15 @@ static Py_ssize_t __pyx_pf_6datrie_8BaseTrie_24__len__(struct __pyx_obj_6datrie_ __pyx_r = __pyx_v_counter; goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":167 + * free(c_key) + * + * def __len__(self): # <<<<<<<<<<<<<< + * # XXX: this is very slow + * cdef BaseState s = BaseState(self) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -3584,6 +3777,14 @@ static Py_ssize_t __pyx_pf_6datrie_8BaseTrie_24__len__(struct __pyx_obj_6datrie_ return __pyx_r; } +/* "datrie.pyx":178 + * return counter + * + * def setdefault(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * return self._setdefault(key, value) + * + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3596,7 +3797,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("setdefault (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_value,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -3610,10 +3811,10 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("setdefault", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } @@ -3628,7 +3829,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_key = ((PyObject*)values[0]); - __pyx_v_value = __Pyx_PyInt_from_py_TrieData(values[1]); if (unlikely((__pyx_v_value == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_value = __Pyx_PyInt_As_TrieData(values[1]); if (unlikely((__pyx_v_value == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; @@ -3640,6 +3841,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_26setdefault(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_value); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -3648,14 +3851,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_27setdefault(PyObject *__pyx_v_self, return __pyx_r; } -/* "datrie.pyx":178 - * return counter - * - * def setdefault(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< - * return self._setdefault(key, value) - * - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_26setdefault(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, TrieData __pyx_v_value) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -3673,14 +3868,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_26setdefault(struct __pyx_obj_6datri * cdef cdatrie.TrieData _setdefault(self, unicode key, cdatrie.TrieData value): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_TrieData(((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_setdefault(__pyx_v_self, __pyx_v_key, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_TrieData(((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_setdefault(__pyx_v_self, __pyx_v_key, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":178 + * return counter + * + * def setdefault(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * return self._setdefault(key, value) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.setdefault", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -3706,6 +3908,7 @@ static TrieData __pyx_f_6datrie_8BaseTrie__setdefault(struct __pyx_obj_6datrie_B TrieData __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; + TrieData __pyx_t_2; __Pyx_RefNannySetupContext("_setdefault", 0); /* "datrie.pyx":182 @@ -3753,8 +3956,7 @@ static TrieData __pyx_f_6datrie_8BaseTrie__setdefault(struct __pyx_obj_6datrie_B * cdatrie.trie_store(self._c_trie, c_key, value) */ __pyx_r = __pyx_v_data; - goto __pyx_L3; - goto __pyx_L6; + goto __pyx_L3_return; } /*else*/ { @@ -3775,9 +3977,8 @@ static TrieData __pyx_f_6datrie_8BaseTrie__setdefault(struct __pyx_obj_6datrie_B * free(c_key) */ __pyx_r = __pyx_v_value; - goto __pyx_L3; + goto __pyx_L3_return; } - __pyx_L6:; } /* "datrie.pyx":193 @@ -3788,23 +3989,37 @@ static TrieData __pyx_f_6datrie_8BaseTrie__setdefault(struct __pyx_obj_6datrie_B * */ /*finally:*/ { - int __pyx_why; - __pyx_why = 0; goto __pyx_L5; - __pyx_L3: __pyx_why = 3; goto __pyx_L5; - __pyx_L5:; - free(__pyx_v_c_key); - switch (__pyx_why) { - case 3: goto __pyx_L0; + __pyx_L3_return: { + __pyx_t_2 = __pyx_r; + free(__pyx_v_c_key); + __pyx_r = __pyx_t_2; + goto __pyx_L0; } } - __pyx_r = 0; + /* "datrie.pyx":181 + * return self._setdefault(key, value) + * + * cdef cdatrie.TrieData _setdefault(self, unicode key, cdatrie.TrieData value): # <<<<<<<<<<<<<< + * cdef cdatrie.AlphaChar* c_key = new_alpha_char_from_unicode(key) + * cdef cdatrie.TrieData data + */ + + /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":196 + * + * + * def iter_prefixes(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the keys of this trie that are prefixes + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_29iter_prefixes(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_28iter_prefixes[] = "\n Returns an iterator over the keys of this trie that are prefixes\n of ``key``.\n "; @@ -3817,6 +4032,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_29iter_prefixes(PyObject *__pyx_v_se __Pyx_RefNannySetupContext("iter_prefixes (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_28iter_prefixes(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -3825,14 +4042,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_29iter_prefixes(PyObject *__pyx_v_se return __pyx_r; } -/* "datrie.pyx":196 - * - * - * def iter_prefixes(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns an iterator over the keys of this trie that are prefixes - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_28iter_prefixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -3860,6 +4069,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_28iter_prefixes(struct __pyx_obj_6da return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -3885,6 +4095,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ int __pyx_t_7; Py_ssize_t __pyx_t_8; PyObject *__pyx_t_9 = NULL; + char const *__pyx_t_10; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -3927,9 +4144,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ * cdef int index = 1 */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; } - __pyx_L4:; /* "datrie.pyx":205 * raise MemoryError() @@ -3956,13 +4171,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ * if not cdatrie.trie_state_walk(state, char): * return */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L6;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L6_error;} } - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); __pyx_t_2 = __pyx_cur_scope->__pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L6_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_cur_scope->__pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); @@ -3986,11 +4201,9 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - goto __pyx_L5; - goto __pyx_L10; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L5_return; } - __pyx_L10:; /* "datrie.pyx":210 * if not cdatrie.trie_state_walk(state, char): @@ -4009,13 +4222,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ * index += 1 * finally: */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6_error;} } - __pyx_t_9 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_key, 0, __pyx_cur_scope->__pyx_v_index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __pyx_r = ((PyObject *)__pyx_t_9); + __pyx_t_9 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_key, 0, __pyx_cur_scope->__pyx_v_index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_r = __pyx_t_9; __pyx_t_9 = 0; __Pyx_XGIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; @@ -4038,7 +4251,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ __pyx_t_5 = __pyx_cur_scope->__pyx_t_3; __pyx_t_6 = __pyx_cur_scope->__pyx_t_4; __pyx_t_8 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L6_error;} goto __pyx_L11; } __pyx_L11:; @@ -4052,7 +4265,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ */ __pyx_cur_scope->__pyx_v_index = (__pyx_cur_scope->__pyx_v_index + 1); } - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } /* "datrie.pyx":214 @@ -4063,39 +4276,65 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ * def iter_prefix_items(self, unicode key): */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L7; - __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L7; - __pyx_L6: { - __pyx_why = 4; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; + /*normal exit:*/{ + trie_state_free(__pyx_cur_scope->__pyx_v_state); goto __pyx_L7; } - __pyx_L7:; - trie_state_free(__pyx_cur_scope->__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + /*exception exit:*/{ + __pyx_L6_error:; + __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_10 = __pyx_filename; + { + trie_state_free(__pyx_cur_scope->__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); + } + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_10; + goto __pyx_L1_error; + } + __pyx_L5_return: { + __pyx_t_16 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_cur_scope->__pyx_v_state); + __pyx_r = __pyx_t_16; + __pyx_t_16 = 0; + goto __pyx_L0; } + __pyx_L7:; } + + /* "datrie.pyx":196 + * + * + * def iter_prefixes(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the keys of this trie that are prefixes + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("iter_prefixes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; @@ -4107,6 +4346,14 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_30generator(__pyx_GeneratorObject *_ } static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":216 + * cdatrie.trie_state_free(state) + * + * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the items (``(key,value)`` tuples) + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_32iter_prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_31iter_prefix_items[] = "\n Returns an iterator over the items (``(key,value)`` tuples)\n of this trie that are associated with keys that are prefixes of ``key``.\n "; @@ -4119,6 +4366,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_32iter_prefix_items(PyObject *__pyx_ __Pyx_RefNannySetupContext("iter_prefix_items (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_31iter_prefix_items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -4127,14 +4376,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_32iter_prefix_items(PyObject *__pyx_ return __pyx_r; } -/* "datrie.pyx":216 - * cdatrie.trie_state_free(state) - * - * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns an iterator over the items (``(key,value)`` tuples) - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_31iter_prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -4162,6 +4403,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_31iter_prefix_items(struct __pyx_obj return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -4189,6 +4431,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; + char const *__pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -4231,9 +4480,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * * cdef int index = 1 */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; } - __pyx_L4:; /* "datrie.pyx":226 * raise MemoryError() @@ -4260,13 +4507,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * * if not cdatrie.trie_state_walk(state, char): * return */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L6;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L6_error;} } - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); __pyx_t_2 = __pyx_cur_scope->__pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L6_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_cur_scope->__pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); @@ -4290,11 +4537,9 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - goto __pyx_L5; - goto __pyx_L10; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L5_return; } - __pyx_L10:; /* "datrie.pyx":231 * if not cdatrie.trie_state_walk(state, char): @@ -4313,23 +4558,23 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * * index += 1 * finally: */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6_error;} } - __pyx_t_9 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_key, 0, __pyx_cur_scope->__pyx_v_index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __pyx_t_10 = __Pyx_PyInt_to_py_TrieData(trie_state_get_terminal_data(__pyx_cur_scope->__pyx_v_state)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_9 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_key, 0, __pyx_cur_scope->__pyx_v_index); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyInt_From_TrieData(trie_state_get_terminal_data(__pyx_cur_scope->__pyx_v_state)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6_error;} __Pyx_GOTREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_9 = 0; __pyx_t_10 = 0; - __pyx_r = ((PyObject *)__pyx_t_11); + __pyx_r = __pyx_t_11; __pyx_t_11 = 0; __Pyx_XGIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; @@ -4352,7 +4597,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * __pyx_t_5 = __pyx_cur_scope->__pyx_t_3; __pyx_t_6 = __pyx_cur_scope->__pyx_t_4; __pyx_t_8 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L6_error;} goto __pyx_L11; } __pyx_L11:; @@ -4366,7 +4611,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * */ __pyx_cur_scope->__pyx_v_index = (__pyx_cur_scope->__pyx_v_index + 1); } - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } /* "datrie.pyx":235 @@ -4377,41 +4622,67 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * * def iter_prefix_values(self, unicode key): */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L7; - __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L7; - __pyx_L6: { - __pyx_why = 4; + /*normal exit:*/{ + trie_state_free(__pyx_cur_scope->__pyx_v_state); + goto __pyx_L7; + } + /*exception exit:*/{ + __pyx_L6_error:; + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L7; - } - __pyx_L7:; - trie_state_free(__pyx_cur_scope->__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_12 = __pyx_filename; + { + trie_state_free(__pyx_cur_scope->__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); + } + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_12; + goto __pyx_L1_error; + } + __pyx_L5_return: { + __pyx_t_18 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_cur_scope->__pyx_v_state); + __pyx_r = __pyx_t_18; + __pyx_t_18 = 0; + goto __pyx_L0; } + __pyx_L7:; } + + /* "datrie.pyx":216 + * cdatrie.trie_state_free(state) + * + * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the items (``(key,value)`` tuples) + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); @@ -4425,6 +4696,14 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_33generator1(__pyx_GeneratorObject * } static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":237 + * cdatrie.trie_state_free(state) + * + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the values of this trie that are associated + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_35iter_prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_34iter_prefix_values[] = "\n Returns an iterator over the values of this trie that are associated\n with keys that are prefixes of ``key``.\n "; @@ -4437,6 +4716,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_35iter_prefix_values(PyObject *__pyx __Pyx_RefNannySetupContext("iter_prefix_values (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_34iter_prefix_values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -4445,14 +4726,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_35iter_prefix_values(PyObject *__pyx return __pyx_r; } -/* "datrie.pyx":237 - * cdatrie.trie_state_free(state) - * - * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns an iterator over the values of this trie that are associated - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_34iter_prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -4480,6 +4753,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_34iter_prefix_values(struct __pyx_ob return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -4505,6 +4779,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * int __pyx_t_7; Py_ssize_t __pyx_t_8; PyObject *__pyx_t_9 = NULL; + char const *__pyx_t_10; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -4547,9 +4828,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * * try: */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; } - __pyx_L4:; /* "datrie.pyx":247 * raise MemoryError() @@ -4567,13 +4846,13 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * * if not cdatrie.trie_state_walk(state, char): * return */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L6;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L6_error;} } - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); __pyx_t_2 = __pyx_cur_scope->__pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L6_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_cur_scope->__pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); @@ -4597,11 +4876,9 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * */ __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - goto __pyx_L5; - goto __pyx_L10; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L5_return; } - __pyx_L10:; /* "datrie.pyx":251 * if not cdatrie.trie_state_walk(state, char): @@ -4620,7 +4897,7 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * * finally: * cdatrie.trie_state_free(state) */ - __pyx_t_9 = __Pyx_PyInt_to_py_TrieData(trie_state_get_terminal_data(__pyx_cur_scope->__pyx_v_state)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L6;} + __pyx_t_9 = __Pyx_PyInt_From_TrieData(trie_state_get_terminal_data(__pyx_cur_scope->__pyx_v_state)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L6_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_r = __pyx_t_9; __pyx_t_9 = 0; @@ -4645,12 +4922,12 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * __pyx_t_5 = __pyx_cur_scope->__pyx_t_3; __pyx_t_6 = __pyx_cur_scope->__pyx_t_4; __pyx_t_8 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L6;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L6_error;} goto __pyx_L11; } __pyx_L11:; } - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } /* "datrie.pyx":254 @@ -4661,39 +4938,65 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L7; - __pyx_L5: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L7; - __pyx_L6: { - __pyx_why = 4; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; + /*normal exit:*/{ + trie_state_free(__pyx_cur_scope->__pyx_v_state); goto __pyx_L7; } - __pyx_L7:; - trie_state_free(__pyx_cur_scope->__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + /*exception exit:*/{ + __pyx_L6_error:; + __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_10 = __pyx_filename; + { + trie_state_free(__pyx_cur_scope->__pyx_v_state); + } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); } + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_10; + goto __pyx_L1_error; + } + __pyx_L5_return: { + __pyx_t_16 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_cur_scope->__pyx_v_state); + __pyx_r = __pyx_t_16; + __pyx_t_16 = 0; + goto __pyx_L0; } + __pyx_L7:; } + + /* "datrie.pyx":237 + * cdatrie.trie_state_free(state) + * + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns an iterator over the values of this trie that are associated + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("iter_prefix_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; @@ -4704,6 +5007,14 @@ static PyObject *__pyx_gb_6datrie_8BaseTrie_36generator2(__pyx_GeneratorObject * return NULL; } +/* "datrie.pyx":257 + * + * + * def prefixes(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list with keys of this trie that are prefixes of ``key``. + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8BaseTrie_38prefixes(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_8BaseTrie_37prefixes[] = "\n Returns a list with keys of this trie that are prefixes of ``key``.\n "; @@ -4716,6 +5027,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_38prefixes(PyObject *__pyx_v_self, P __Pyx_RefNannySetupContext("prefixes (wrapper)", 0); if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8BaseTrie_37prefixes(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -4724,14 +5037,6 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_38prefixes(PyObject *__pyx_v_self, P return __pyx_r; } -/* "datrie.pyx":257 - * - * - * def prefixes(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns a list with keys of this trie that are prefixes of ``key``. - */ - static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { TrieState *__pyx_v_state; PyObject *__pyx_v_result = 0; @@ -4749,6 +5054,13 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ int __pyx_t_8; Py_ssize_t __pyx_t_9; int __pyx_t_10; + char const *__pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -4781,9 +5093,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * cdef list result = [] */ PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; } - __pyx_L3:; /* "datrie.pyx":265 * raise MemoryError() @@ -4822,13 +5132,13 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * if not cdatrie.trie_state_walk(state, char): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_3 = __pyx_v_key; - __pyx_t_8 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_3), (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_8 = __Pyx_init_unicode_iteration(__pyx_t_3, (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_5; __pyx_t_9++) { __pyx_t_4 = __pyx_t_9; __pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_7, __pyx_t_6, __pyx_t_4); @@ -4851,9 +5161,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * result.append(key[:index]) */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; /* "datrie.pyx":271 * if not cdatrie.trie_state_walk(state, char): @@ -4872,14 +5180,14 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * index += 1 * return result */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_t_2 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L10; } __pyx_L10:; @@ -4894,7 +5202,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ __pyx_v_index = (__pyx_v_index + 1); } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "datrie.pyx":274 * result.append(key[:index]) @@ -4904,9 +5212,9 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * cdatrie.trie_state_free(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L4; + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L4_return; } /* "datrie.pyx":276 @@ -4914,44 +5222,62 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< * - * def prefix_items(self, unicode key): + * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_11 = __pyx_filename; + { + trie_state_free(__pyx_v_state); + } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); + __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; + __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_11; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_17 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_17; + __pyx_t_17 = 0; + goto __pyx_L0; } } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":257 + * + * + * def prefixes(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list with keys of this trie that are prefixes of ``key``. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("datrie.BaseTrie.prefixes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -4961,18 +5287,275 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_37prefixes(struct __pyx_obj_6datrie_ return __pyx_r; } +/* "datrie.pyx":279 + * + * + * cpdef suffixes(self, unicode prefix=u''): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's suffixes. + */ + +static PyObject *__pyx_pw_6datrie_8BaseTrie_40suffixes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6datrie_8BaseTrie_suffixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_suffixes *__pyx_optional_args) { + PyObject *__pyx_v_prefix = ((PyObject*)__pyx_kp_u__7); + int __pyx_v_success; + PyObject *__pyx_v_res = 0; + struct __pyx_obj_6datrie_BaseState *__pyx_v_state = 0; + struct __pyx_obj_6datrie_BaseIterator *__pyx_v_iter = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("suffixes", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_prefix = __pyx_optional_args->prefix; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_suffixes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_40suffixes)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "datrie.pyx":285 + * """ + * cdef bint success + * cdef list res = [] # <<<<<<<<<<<<<< + * cdef BaseState state = BaseState(self) + * + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_res = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "datrie.pyx":286 + * cdef bint success + * cdef list res = [] + * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< + * + * if prefix is not None: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "datrie.pyx":288 + * cdef BaseState state = BaseState(self) + * + * if prefix is not None: # <<<<<<<<<<<<<< + * success = state.walk(prefix) + * if not success: + */ + __pyx_t_4 = (__pyx_v_prefix != ((PyObject*)Py_None)); + __pyx_t_5 = (__pyx_t_4 != 0); + if (__pyx_t_5) { + + /* "datrie.pyx":289 + * + * if prefix is not None: + * success = state.walk(prefix) # <<<<<<<<<<<<<< + * if not success: + * return res + */ + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_success = __pyx_t_5; + + /* "datrie.pyx":290 + * if prefix is not None: + * success = state.walk(prefix) + * if not success: # <<<<<<<<<<<<<< + * return res + * + */ + __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); + if (__pyx_t_5) { + + /* "datrie.pyx":291 + * success = state.walk(prefix) + * if not success: + * return res # <<<<<<<<<<<<<< + * + * cdef BaseIterator iter = BaseIterator(state) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; + goto __pyx_L0; + } + goto __pyx_L3; + } + __pyx_L3:; + + /* "datrie.pyx":293 + * return res + * + * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< + * + * while iter.next(): + */ + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_state)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "datrie.pyx":295 + * cdef BaseIterator iter = BaseIterator(state) + * + * while iter.next(): # <<<<<<<<<<<<<< + * res.append(iter.key()) + * + */ + while (1) { + __pyx_t_5 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); + if (!__pyx_t_5) break; + + /* "datrie.pyx":296 + * + * while iter.next(): + * res.append(iter.key()) # <<<<<<<<<<<<<< + * + * return res + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "datrie.pyx":298 + * res.append(iter.key()) + * + * return res # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; + goto __pyx_L0; + + /* "datrie.pyx":279 + * + * + * cpdef suffixes(self, unicode prefix=u''): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's suffixes. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("datrie.BaseTrie.suffixes", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_res); + __Pyx_XDECREF((PyObject *)__pyx_v_state); + __Pyx_XDECREF((PyObject *)__pyx_v_iter); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_40prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_39prefix_items[] = "\n Returns a list of the items (``(key,value)`` tuples)\n of this trie that are associated with keys that are\n prefixes of ``key``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_40prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { - CYTHON_UNUSED int __pyx_lineno = 0; - CYTHON_UNUSED const char *__pyx_filename = NULL; - CYTHON_UNUSED int __pyx_clineno = 0; +static PyObject *__pyx_pw_6datrie_8BaseTrie_40suffixes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_39suffixes[] = "\n Returns a list of this trie's suffixes.\n If ``prefix`` is not empty, returns only the suffixes of words prefixed by ``prefix``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_40suffixes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_prefix = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("prefix_items (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_39prefix_items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + __Pyx_RefNannySetupContext("suffixes (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; + PyObject* values[1] = {0}; + values[0] = ((PyObject*)__pyx_kp_u__7); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "suffixes") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_prefix = ((PyObject*)values[0]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("suffixes", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("datrie.BaseTrie.suffixes", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_39suffixes(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -4981,15 +5564,66 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_40prefix_items(PyObject *__pyx_v_sel return __pyx_r; } -/* "datrie.pyx":278 - * cdatrie.trie_state_free(state) +static PyObject *__pyx_pf_6datrie_8BaseTrie_39suffixes(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_6datrie_8BaseTrie_suffixes __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("suffixes", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.prefix = __pyx_v_prefix; + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->suffixes(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("datrie.BaseTrie.suffixes", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "datrie.pyx":301 + * * * def prefix_items(self, unicode key): # <<<<<<<<<<<<<< * ''' * Returns a list of the items (``(key,value)`` tuples) */ -static PyObject *__pyx_pf_6datrie_8BaseTrie_39prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { +/* Python wrapper */ +static PyObject *__pyx_pw_6datrie_8BaseTrie_42prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_41prefix_items[] = "\n Returns a list of the items (``(key,value)`` tuples)\n of this trie that are associated with keys that are\n prefixes of ``key``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_42prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { + CYTHON_UNUSED int __pyx_lineno = 0; + CYTHON_UNUSED const char *__pyx_filename = NULL; + CYTHON_UNUSED int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("prefix_items (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_41prefix_items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -4998,7 +5632,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_39prefix_items(struct __pyx_obj_6dat int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prefix_items", 0); - /* "datrie.pyx":284 + /* "datrie.pyx":307 * prefixes of ``key``. * ''' * return self._prefix_items(key) # <<<<<<<<<<<<<< @@ -5006,14 +5640,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_39prefix_items(struct __pyx_obj_6dat * cdef list _prefix_items(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_prefix_items(__pyx_v_self, __pyx_v_key)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_prefix_items(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":301 + * + * + * def prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the items (``(key,value)`` tuples) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.prefix_items", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -5024,7 +5665,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_39prefix_items(struct __pyx_obj_6dat return __pyx_r; } -/* "datrie.pyx":286 +/* "datrie.pyx":309 * return self._prefix_items(key) * * cdef list _prefix_items(self, unicode key): # <<<<<<<<<<<<<< @@ -5051,12 +5692,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; + char const *__pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + PyObject *__pyx_t_19 = NULL; + PyObject *__pyx_t_20 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_prefix_items", 0); - /* "datrie.pyx":287 + /* "datrie.pyx":310 * * cdef list _prefix_items(self, unicode key): * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -5065,7 +5714,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":289 + /* "datrie.pyx":312 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * * if state == NULL: # <<<<<<<<<<<<<< @@ -5075,31 +5724,29 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":290 + /* "datrie.pyx":313 * * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef list result = [] */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":292 + /* "datrie.pyx":315 * raise MemoryError() * * cdef list result = [] # <<<<<<<<<<<<<< * cdef int index = 1 * try: */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":293 + /* "datrie.pyx":316 * * cdef list result = [] * cdef int index = 1 # <<<<<<<<<<<<<< @@ -5108,7 +5755,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri */ __pyx_v_index = 1; - /* "datrie.pyx":294 + /* "datrie.pyx":317 * cdef list result = [] * cdef int index = 1 * try: # <<<<<<<<<<<<<< @@ -5117,25 +5764,25 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri */ /*try:*/ { - /* "datrie.pyx":295 + /* "datrie.pyx":318 * cdef int index = 1 * try: * for char in key: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, char): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_3 = __pyx_v_key; - __pyx_t_8 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_3), (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_8 = __Pyx_init_unicode_iteration(__pyx_t_3, (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_5; __pyx_t_9++) { __pyx_t_4 = __pyx_t_9; __pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_7, __pyx_t_6, __pyx_t_4); - /* "datrie.pyx":296 + /* "datrie.pyx":319 * try: * for char in key: * if not cdatrie.trie_state_walk(state, char): # <<<<<<<<<<<<<< @@ -5145,7 +5792,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_char)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":297 + /* "datrie.pyx":320 * for char in key: * if not cdatrie.trie_state_walk(state, char): * break # <<<<<<<<<<<<<< @@ -5153,11 +5800,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri * result.append( */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; - /* "datrie.pyx":298 + /* "datrie.pyx":321 * if not cdatrie.trie_state_walk(state, char): * break * if cdatrie.trie_state_is_terminal(state): # word is found # <<<<<<<<<<<<<< @@ -5167,44 +5812,60 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri __pyx_t_1 = (trie_state_is_terminal(__pyx_v_state) != 0); if (__pyx_t_1) { - /* "datrie.pyx":300 + /* "datrie.pyx":323 * if cdatrie.trie_state_is_terminal(state): # word is found * result.append( * (key[:index], # <<<<<<<<<<<<<< * cdatrie.trie_state_get_terminal_data(state)) * ) */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_t_2 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_GOTREF(__pyx_t_2); - /* "datrie.pyx":301 + /* "datrie.pyx":324 * result.append( * (key[:index], * cdatrie.trie_state_get_terminal_data(state)) # <<<<<<<<<<<<<< * ) * index += 1 */ - __pyx_t_10 = __Pyx_PyInt_to_py_TrieData(trie_state_get_terminal_data(__pyx_v_state)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_10 = __Pyx_PyInt_From_TrieData(trie_state_get_terminal_data(__pyx_v_state)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L5;} + + /* "datrie.pyx":323 + * if cdatrie.trie_state_is_terminal(state): # word is found + * result.append( + * (key[:index], # <<<<<<<<<<<<<< + * cdatrie.trie_state_get_terminal_data(state)) + * ) + */ + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_2 = 0; __pyx_t_10 = 0; - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_11)); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; + + /* "datrie.pyx":322 + * break + * if cdatrie.trie_state_is_terminal(state): # word is found + * result.append( # <<<<<<<<<<<<<< + * (key[:index], + * cdatrie.trie_state_get_terminal_data(state)) + */ + __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L10; } __pyx_L10:; - /* "datrie.pyx":303 + /* "datrie.pyx":326 * cdatrie.trie_state_get_terminal_data(state)) * ) * index += 1 # <<<<<<<<<<<<<< @@ -5214,22 +5875,22 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri __pyx_v_index = (__pyx_v_index + 1); } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":304 + /* "datrie.pyx":327 * ) * index += 1 * return result # <<<<<<<<<<<<<< * finally: * cdatrie.trie_state_free(state) */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; - goto __pyx_L4; + goto __pyx_L4_return; } - /* "datrie.pyx":306 + /* "datrie.pyx":329 * return result * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -5237,43 +5898,61 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri * def prefix_values(self, unicode key): */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __Pyx_XGOTREF(__pyx_t_19); + __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_13 = __pyx_filename; + { + trie_state_free(__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_XGIVEREF(__pyx_t_19); + __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); + } + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; + __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_13; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_20 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_20; + __pyx_t_20 = 0; + goto __pyx_L0; } } - __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":309 + * return self._prefix_items(key) + * + * cdef list _prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); + __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datrie.BaseTrie._prefix_items", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -5285,18 +5964,28 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_items(struct __pyx_obj_6datri return __pyx_r; } +/* "datrie.pyx":331 + * cdatrie.trie_state_free(state) + * + * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the values of this trie that are associated + */ + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_42prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_41prefix_values[] = "\n Returns a list of the values of this trie that are associated\n with keys that are prefixes of ``key``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_42prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_44prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_43prefix_values[] = "\n Returns a list of the values of this trie that are associated\n with keys that are prefixes of ``key``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_44prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { CYTHON_UNUSED int __pyx_lineno = 0; CYTHON_UNUSED const char *__pyx_filename = NULL; CYTHON_UNUSED int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("prefix_values (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_41prefix_values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_43prefix_values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -5305,15 +5994,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_42prefix_values(PyObject *__pyx_v_se return __pyx_r; } -/* "datrie.pyx":308 - * cdatrie.trie_state_free(state) - * - * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns a list of the values of this trie that are associated - */ - -static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_43prefix_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5322,7 +6003,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_values(struct __pyx_obj_6da int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prefix_values", 0); - /* "datrie.pyx":313 + /* "datrie.pyx":336 * with keys that are prefixes of ``key``. * ''' * return self._prefix_values(key) # <<<<<<<<<<<<<< @@ -5330,14 +6011,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_values(struct __pyx_obj_6da * cdef list _prefix_values(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_prefix_values(__pyx_v_self, __pyx_v_key)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_prefix_values(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":331 + * cdatrie.trie_state_free(state) + * + * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the values of this trie that are associated + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.prefix_values", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -5348,7 +6036,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_41prefix_values(struct __pyx_obj_6da return __pyx_r; } -/* "datrie.pyx":315 +/* "datrie.pyx":338 * return self._prefix_values(key) * * cdef list _prefix_values(self, unicode key): # <<<<<<<<<<<<<< @@ -5372,12 +6060,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr int __pyx_t_8; Py_ssize_t __pyx_t_9; int __pyx_t_10; + char const *__pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_prefix_values", 0); - /* "datrie.pyx":316 + /* "datrie.pyx":339 * * cdef list _prefix_values(self, unicode key): * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -5386,7 +6082,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":318 + /* "datrie.pyx":341 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * * if state == NULL: # <<<<<<<<<<<<<< @@ -5396,31 +6092,29 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":319 + /* "datrie.pyx":342 * * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef list result = [] */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":321 + /* "datrie.pyx":344 * raise MemoryError() * * cdef list result = [] # <<<<<<<<<<<<<< * try: * for char in key: */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":322 + /* "datrie.pyx":345 * * cdef list result = [] * try: # <<<<<<<<<<<<<< @@ -5429,25 +6123,25 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr */ /*try:*/ { - /* "datrie.pyx":323 + /* "datrie.pyx":346 * cdef list result = [] * try: * for char in key: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, char): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_3 = __pyx_v_key; - __pyx_t_8 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_3), (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_8 = __Pyx_init_unicode_iteration(__pyx_t_3, (&__pyx_t_5), (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_5; __pyx_t_9++) { __pyx_t_4 = __pyx_t_9; __pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_7, __pyx_t_6, __pyx_t_4); - /* "datrie.pyx":324 + /* "datrie.pyx":347 * try: * for char in key: * if not cdatrie.trie_state_walk(state, char): # <<<<<<<<<<<<<< @@ -5457,7 +6151,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_char)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":325 + /* "datrie.pyx":348 * for char in key: * if not cdatrie.trie_state_walk(state, char): * break # <<<<<<<<<<<<<< @@ -5465,11 +6159,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr * result.append(cdatrie.trie_state_get_terminal_data(state)) */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; - /* "datrie.pyx":326 + /* "datrie.pyx":349 * if not cdatrie.trie_state_walk(state, char): * break * if cdatrie.trie_state_is_terminal(state): # word is found # <<<<<<<<<<<<<< @@ -5479,38 +6171,38 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr __pyx_t_1 = (trie_state_is_terminal(__pyx_v_state) != 0); if (__pyx_t_1) { - /* "datrie.pyx":327 + /* "datrie.pyx":350 * break * if cdatrie.trie_state_is_terminal(state): # word is found * result.append(cdatrie.trie_state_get_terminal_data(state)) # <<<<<<<<<<<<<< * return result * finally: */ - __pyx_t_2 = __Pyx_PyInt_to_py_TrieData(trie_state_get_terminal_data(__pyx_v_state)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_From_TrieData(trie_state_get_terminal_data(__pyx_v_state)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L10; } __pyx_L10:; } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":328 + /* "datrie.pyx":351 * if cdatrie.trie_state_is_terminal(state): # word is found * result.append(cdatrie.trie_state_get_terminal_data(state)) * return result # <<<<<<<<<<<<<< * finally: * cdatrie.trie_state_free(state) */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; - goto __pyx_L4; + goto __pyx_L4_return; } - /* "datrie.pyx":330 + /* "datrie.pyx":353 * return result * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -5518,41 +6210,59 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __pyx_t_7 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_11 = __pyx_filename; + { + trie_state_free(__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); + } + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); + __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; + __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_11; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_18 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_18; + __pyx_t_18 = 0; + goto __pyx_L0; } } - __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":338 + * return self._prefix_values(key) + * + * cdef list _prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("datrie.BaseTrie._prefix_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -5562,10 +6272,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__prefix_values(struct __pyx_obj_6datr return __pyx_r; } +/* "datrie.pyx":356 + * + * + * def longest_prefix(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the longest key in this trie that is a prefix of ``key``. + */ + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_43longest_prefix[] = "\n Returns the longest key in this trie that is a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, returns it,\n - otherwise raises ``KeyError``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_45longest_prefix[] = "\n Returns the longest key in this trie that is a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, returns it,\n - otherwise raises ``KeyError``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_key = 0; PyObject *__pyx_v_default = 0; int __pyx_lineno = 0; @@ -5575,9 +6293,9 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("longest_prefix (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__default,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; - values[1] = __pyx_k_10; + values[1] = __pyx_k__8; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -5590,16 +6308,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_s kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5614,14 +6332,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("longest_prefix", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("longest_prefix", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_43longest_prefix(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_45longest_prefix(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -5630,15 +6350,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_44longest_prefix(PyObject *__pyx_v_s return __pyx_r; } -/* "datrie.pyx":333 - * - * - * def longest_prefix(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< - * """ - * Returns the longest key in this trie that is a prefix of ``key``. - */ - -static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { TrieState *__pyx_v_state; int __pyx_v_index; int __pyx_v_last_terminal_index; @@ -5656,12 +6368,19 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d PyObject *__pyx_t_9 = NULL; int __pyx_t_10; PyObject *__pyx_t_11 = NULL; + char const *__pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("longest_prefix", 0); - /* "datrie.pyx":341 + /* "datrie.pyx":364 * - otherwise raises ``KeyError``. * """ * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -5670,7 +6389,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":343 + /* "datrie.pyx":366 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * * if state == NULL: # <<<<<<<<<<<<<< @@ -5680,19 +6399,17 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":344 + /* "datrie.pyx":367 * * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef int index = 0, last_terminal_index = 0 */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":346 + /* "datrie.pyx":369 * raise MemoryError() * * cdef int index = 0, last_terminal_index = 0 # <<<<<<<<<<<<<< @@ -5702,7 +6419,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_v_index = 0; __pyx_v_last_terminal_index = 0; - /* "datrie.pyx":348 + /* "datrie.pyx":371 * cdef int index = 0, last_terminal_index = 0 * * try: # <<<<<<<<<<<<<< @@ -5711,25 +6428,25 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d */ /*try:*/ { - /* "datrie.pyx":349 + /* "datrie.pyx":372 * * try: * for ch in key: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, ch): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_2 = __pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); - /* "datrie.pyx":350 + /* "datrie.pyx":373 * try: * for ch in key: * if not cdatrie.trie_state_walk(state, ch): # <<<<<<<<<<<<<< @@ -5739,7 +6456,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_ch)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":351 + /* "datrie.pyx":374 * for ch in key: * if not cdatrie.trie_state_walk(state, ch): * break # <<<<<<<<<<<<<< @@ -5747,11 +6464,9 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d * index += 1 */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; - /* "datrie.pyx":353 + /* "datrie.pyx":376 * break * * index += 1 # <<<<<<<<<<<<<< @@ -5760,7 +6475,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d */ __pyx_v_index = (__pyx_v_index + 1); - /* "datrie.pyx":354 + /* "datrie.pyx":377 * * index += 1 * if cdatrie.trie_state_is_terminal(state): # <<<<<<<<<<<<<< @@ -5770,7 +6485,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_t_1 = (trie_state_is_terminal(__pyx_v_state) != 0); if (__pyx_t_1) { - /* "datrie.pyx":355 + /* "datrie.pyx":378 * index += 1 * if cdatrie.trie_state_is_terminal(state): * last_terminal_index = index # <<<<<<<<<<<<<< @@ -5783,9 +6498,9 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_L10:; } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":357 + /* "datrie.pyx":380 * last_terminal_index = index * * if not last_terminal_index: # <<<<<<<<<<<<<< @@ -5795,43 +6510,41 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __pyx_t_1 = ((!(__pyx_v_last_terminal_index != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":358 + /* "datrie.pyx":381 * * if not last_terminal_index: * if default is RAISE_KEY_ERROR: # <<<<<<<<<<<<<< * raise KeyError(key) * return default */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_v_default == __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = (__pyx_t_1 != 0); if (__pyx_t_10) { - /* "datrie.pyx":359 + /* "datrie.pyx":382 * if not last_terminal_index: * if default is RAISE_KEY_ERROR: * raise KeyError(key) # <<<<<<<<<<<<<< * return default * */ - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_11 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L5;} - goto __pyx_L12; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_L12:; - /* "datrie.pyx":360 + /* "datrie.pyx":383 * if default is RAISE_KEY_ERROR: * raise KeyError(key) * return default # <<<<<<<<<<<<<< @@ -5841,12 +6554,10 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default); __pyx_r = __pyx_v_default; - goto __pyx_L4; - goto __pyx_L11; + goto __pyx_L4_return; } - __pyx_L11:; - /* "datrie.pyx":362 + /* "datrie.pyx":385 * return default * * return key[:last_terminal_index] # <<<<<<<<<<<<<< @@ -5854,18 +6565,18 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d * cdatrie.trie_state_free(state) */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_t_11 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_last_terminal_index); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_11)); - __pyx_r = ((PyObject *)__pyx_t_11); + __pyx_t_11 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_last_terminal_index); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_r = __pyx_t_11; __pyx_t_11 = 0; - goto __pyx_L4; + goto __pyx_L4_return; } - /* "datrie.pyx":364 + /* "datrie.pyx":387 * return key[:last_terminal_index] * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -5873,41 +6584,59 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_12 = __pyx_filename; + { + trie_state_free(__pyx_v_state); + } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); } + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_12; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_18 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_18; + __pyx_t_18 = 0; + goto __pyx_L0; } } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":356 + * + * + * def longest_prefix(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the longest key in this trie that is a prefix of ``key``. + */ + + /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -5918,10 +6647,18 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_43longest_prefix(struct __pyx_obj_6d return __pyx_r; } +/* "datrie.pyx":390 + * + * + * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the item (``(key,value)`` tuple) associated with the longest + */ + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_45longest_prefix_item[] = "\n Returns the item (``(key,value)`` tuple) associated with the longest\n key in this trie that is a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, returns it,\n - otherwise raises ``KeyError``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_item(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_47longest_prefix_item[] = "\n Returns the item (``(key,value)`` tuple) associated with the longest\n key in this trie that is a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, returns it,\n - otherwise raises ``KeyError``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_item(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_key = 0; PyObject *__pyx_v_default = 0; int __pyx_lineno = 0; @@ -5931,9 +6668,9 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("longest_prefix_item (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__default,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; - values[1] = __pyx_k_11; + values[1] = __pyx_k__9; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -5946,16 +6683,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__py kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_item") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_item") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5970,14 +6707,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("longest_prefix_item", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("longest_prefix_item", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix_item", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_47longest_prefix_item(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -5986,15 +6725,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item(PyObject *__py return __pyx_r; } -/* "datrie.pyx":367 - * - * - * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< - * """ - * Returns the item (``(key,value)`` tuple) associated with the longest - */ - -static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_item(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -6004,7 +6735,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_o int __pyx_clineno = 0; __Pyx_RefNannySetupContext("longest_prefix_item", 0); - /* "datrie.pyx":376 + /* "datrie.pyx":399 * - otherwise raises ``KeyError``. * """ * return self._longest_prefix_item(key, default) # <<<<<<<<<<<<<< @@ -6014,14 +6745,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_o __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.__pyx_default = __pyx_v_default; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_longest_prefix_item(__pyx_v_self, __pyx_v_key, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_longest_prefix_item(__pyx_v_self, __pyx_v_key, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":390 + * + * + * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the item (``(key,value)`` tuple) associated with the longest + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix_item", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -6032,7 +6770,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_o return __pyx_r; } -/* "datrie.pyx":378 +/* "datrie.pyx":401 * return self._longest_prefix_item(key, default) * * cdef _longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< @@ -6041,7 +6779,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_45longest_prefix_item(struct __pyx_o */ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item *__pyx_optional_args) { - PyObject *__pyx_v_default = __pyx_k_12; + PyObject *__pyx_v_default = __pyx_k__10; TrieState *__pyx_v_state; int __pyx_v_index; int __pyx_v_last_terminal_index; @@ -6061,6 +6799,13 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj int __pyx_t_10; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; + char const *__pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; + PyObject *__pyx_t_19 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -6071,7 +6816,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj } } - /* "datrie.pyx":379 + /* "datrie.pyx":402 * * cdef _longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -6080,7 +6825,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":381 + /* "datrie.pyx":404 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * * if state == NULL: # <<<<<<<<<<<<<< @@ -6090,19 +6835,17 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":382 + /* "datrie.pyx":405 * * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef int index = 0, last_terminal_index = 0, data */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":384 + /* "datrie.pyx":407 * raise MemoryError() * * cdef int index = 0, last_terminal_index = 0, data # <<<<<<<<<<<<<< @@ -6112,7 +6855,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_v_index = 0; __pyx_v_last_terminal_index = 0; - /* "datrie.pyx":386 + /* "datrie.pyx":409 * cdef int index = 0, last_terminal_index = 0, data * * try: # <<<<<<<<<<<<<< @@ -6121,25 +6864,25 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj */ /*try:*/ { - /* "datrie.pyx":387 + /* "datrie.pyx":410 * * try: * for ch in key: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, ch): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_2 = __pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); - /* "datrie.pyx":388 + /* "datrie.pyx":411 * try: * for ch in key: * if not cdatrie.trie_state_walk(state, ch): # <<<<<<<<<<<<<< @@ -6149,7 +6892,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_ch)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":389 + /* "datrie.pyx":412 * for ch in key: * if not cdatrie.trie_state_walk(state, ch): * break # <<<<<<<<<<<<<< @@ -6157,11 +6900,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj * index += 1 */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; - /* "datrie.pyx":391 + /* "datrie.pyx":414 * break * * index += 1 # <<<<<<<<<<<<<< @@ -6170,7 +6911,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj */ __pyx_v_index = (__pyx_v_index + 1); - /* "datrie.pyx":392 + /* "datrie.pyx":415 * * index += 1 * if cdatrie.trie_state_is_terminal(state): # <<<<<<<<<<<<<< @@ -6180,7 +6921,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_t_1 = (trie_state_is_terminal(__pyx_v_state) != 0); if (__pyx_t_1) { - /* "datrie.pyx":393 + /* "datrie.pyx":416 * index += 1 * if cdatrie.trie_state_is_terminal(state): * last_terminal_index = index # <<<<<<<<<<<<<< @@ -6189,7 +6930,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj */ __pyx_v_last_terminal_index = __pyx_v_index; - /* "datrie.pyx":394 + /* "datrie.pyx":417 * if cdatrie.trie_state_is_terminal(state): * last_terminal_index = index * data = cdatrie.trie_state_get_terminal_data(state) # <<<<<<<<<<<<<< @@ -6202,9 +6943,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_L10:; } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":396 + /* "datrie.pyx":419 * data = cdatrie.trie_state_get_terminal_data(state) * * if not last_terminal_index: # <<<<<<<<<<<<<< @@ -6214,43 +6955,41 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __pyx_t_1 = ((!(__pyx_v_last_terminal_index != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":397 + /* "datrie.pyx":420 * * if not last_terminal_index: * if default is RAISE_KEY_ERROR: # <<<<<<<<<<<<<< * raise KeyError(key) * return default */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_v_default == __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = (__pyx_t_1 != 0); if (__pyx_t_10) { - /* "datrie.pyx":398 + /* "datrie.pyx":421 * if not last_terminal_index: * if default is RAISE_KEY_ERROR: * raise KeyError(key) # <<<<<<<<<<<<<< * return default * */ - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_11 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L5;} - goto __pyx_L12; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_L12:; - /* "datrie.pyx":399 + /* "datrie.pyx":422 * if default is RAISE_KEY_ERROR: * raise KeyError(key) * return default # <<<<<<<<<<<<<< @@ -6260,12 +6999,10 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default); __pyx_r = __pyx_v_default; - goto __pyx_L4; - goto __pyx_L11; + goto __pyx_L4_return; } - __pyx_L11:; - /* "datrie.pyx":401 + /* "datrie.pyx":424 * return default * * return key[:last_terminal_index], data # <<<<<<<<<<<<<< @@ -6273,28 +7010,28 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj * finally: */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_t_11 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_last_terminal_index); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_11)); - __pyx_t_9 = PyInt_FromLong(__pyx_v_data); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_11 = __Pyx_PyUnicode_Substring(__pyx_v_key, 0, __pyx_v_last_terminal_index); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L5_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_data); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_11)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_11)); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_11 = 0; __pyx_t_9 = 0; - __pyx_r = ((PyObject *)__pyx_t_12); + __pyx_r = __pyx_t_12; __pyx_t_12 = 0; - goto __pyx_L4; + goto __pyx_L4_return; } - /* "datrie.pyx":404 + /* "datrie.pyx":427 * * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -6302,42 +7039,60 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __Pyx_XGOTREF(__pyx_t_19); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_13 = __pyx_filename; + { + trie_state_free(__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_XGIVEREF(__pyx_t_19); + __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); + } + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); + __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_13; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_19 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_19; + __pyx_t_19 = 0; + goto __pyx_L0; } } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":401 + * return self._longest_prefix_item(key, default) + * + * cdef _longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) + * + */ + + /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); @@ -6349,10 +7104,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_item(struct __pyx_obj return __pyx_r; } +/* "datrie.pyx":430 + * + * + * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the value associated with the longest key in this trie that is + */ + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_47longest_prefix_value[] = "\n Returns the value associated with the longest key in this trie that is\n a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, return it\n - otherwise raise ``KeyError``\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_50longest_prefix_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_49longest_prefix_value[] = "\n Returns the value associated with the longest key in this trie that is\n a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, return it\n - otherwise raise ``KeyError``\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_50longest_prefix_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_key = 0; PyObject *__pyx_v_default = 0; int __pyx_lineno = 0; @@ -6362,9 +7125,9 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("longest_prefix_value (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__default,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; - values[1] = __pyx_k_13; + values[1] = __pyx_k__11; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -6377,16 +7140,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__p kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -6401,14 +7164,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__p } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("longest_prefix_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("longest_prefix_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_49longest_prefix_value(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -6417,15 +7182,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value(PyObject *__p return __pyx_r; } -/* "datrie.pyx":407 - * - * - * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< - * """ - * Returns the value associated with the longest key in this trie that is - */ - -static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_49longest_prefix_value(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -6435,7 +7192,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("longest_prefix_value", 0); - /* "datrie.pyx":416 + /* "datrie.pyx":439 * - otherwise raise ``KeyError`` * """ * return self._longest_prefix_value(key, default) # <<<<<<<<<<<<<< @@ -6445,14 +7202,21 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_ __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.__pyx_default = __pyx_v_default; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_longest_prefix_value(__pyx_v_self, __pyx_v_key, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->_longest_prefix_value(__pyx_v_self, __pyx_v_key, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":430 + * + * + * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the value associated with the longest key in this trie that is + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.longest_prefix_value", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -6463,7 +7227,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_ return __pyx_r; } -/* "datrie.pyx":418 +/* "datrie.pyx":441 * return self._longest_prefix_value(key, default) * * cdef _longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< @@ -6472,7 +7236,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_47longest_prefix_value(struct __pyx_ */ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_key, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_value *__pyx_optional_args) { - PyObject *__pyx_v_default = __pyx_k_14; + PyObject *__pyx_v_default = __pyx_k__12; TrieState *__pyx_v_state; int __pyx_v_data; char __pyx_v_found; @@ -6490,6 +7254,13 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob PyObject *__pyx_t_9 = NULL; int __pyx_t_10; PyObject *__pyx_t_11 = NULL; + char const *__pyx_t_12; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *__pyx_t_17 = NULL; + PyObject *__pyx_t_18 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -6500,7 +7271,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob } } - /* "datrie.pyx":419 + /* "datrie.pyx":442 * * cdef _longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -6509,7 +7280,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":421 + /* "datrie.pyx":444 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * * if state == NULL: # <<<<<<<<<<<<<< @@ -6519,19 +7290,17 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":422 + /* "datrie.pyx":445 * * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef int data = 0 */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":424 + /* "datrie.pyx":447 * raise MemoryError() * * cdef int data = 0 # <<<<<<<<<<<<<< @@ -6540,7 +7309,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob */ __pyx_v_data = 0; - /* "datrie.pyx":425 + /* "datrie.pyx":448 * * cdef int data = 0 * cdef char found = 0 # <<<<<<<<<<<<<< @@ -6549,7 +7318,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob */ __pyx_v_found = 0; - /* "datrie.pyx":427 + /* "datrie.pyx":450 * cdef char found = 0 * * try: # <<<<<<<<<<<<<< @@ -6558,25 +7327,25 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob */ /*try:*/ { - /* "datrie.pyx":428 + /* "datrie.pyx":451 * * try: * for ch in key: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, ch): * break */ - if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) { + if (unlikely(__pyx_v_key == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_key)); + __Pyx_INCREF(__pyx_v_key); __pyx_t_2 = __pyx_v_key; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); - /* "datrie.pyx":429 + /* "datrie.pyx":452 * try: * for ch in key: * if not cdatrie.trie_state_walk(state, ch): # <<<<<<<<<<<<<< @@ -6586,7 +7355,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_ch)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":430 + /* "datrie.pyx":453 * for ch in key: * if not cdatrie.trie_state_walk(state, ch): * break # <<<<<<<<<<<<<< @@ -6594,11 +7363,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob * if cdatrie.trie_state_is_terminal(state): */ goto __pyx_L8_break; - goto __pyx_L9; } - __pyx_L9:; - /* "datrie.pyx":432 + /* "datrie.pyx":455 * break * * if cdatrie.trie_state_is_terminal(state): # <<<<<<<<<<<<<< @@ -6608,7 +7375,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __pyx_t_1 = (trie_state_is_terminal(__pyx_v_state) != 0); if (__pyx_t_1) { - /* "datrie.pyx":433 + /* "datrie.pyx":456 * * if cdatrie.trie_state_is_terminal(state): * found = 1 # <<<<<<<<<<<<<< @@ -6617,7 +7384,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob */ __pyx_v_found = 1; - /* "datrie.pyx":434 + /* "datrie.pyx":457 * if cdatrie.trie_state_is_terminal(state): * found = 1 * data = cdatrie.trie_state_get_terminal_data(state) # <<<<<<<<<<<<<< @@ -6630,9 +7397,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __pyx_L10:; } __pyx_L8_break:; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":436 + /* "datrie.pyx":459 * data = cdatrie.trie_state_get_terminal_data(state) * * if not found: # <<<<<<<<<<<<<< @@ -6642,43 +7409,41 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __pyx_t_1 = ((!(__pyx_v_found != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":437 + /* "datrie.pyx":460 * * if not found: * if default is RAISE_KEY_ERROR: # <<<<<<<<<<<<<< * raise KeyError(key) * return default */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_v_default == __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = (__pyx_t_1 != 0); if (__pyx_t_10) { - /* "datrie.pyx":438 + /* "datrie.pyx":461 * if not found: * if default is RAISE_KEY_ERROR: * raise KeyError(key) # <<<<<<<<<<<<<< * return default * */ - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_9); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_11 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L5;} - goto __pyx_L12; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __pyx_L12:; - /* "datrie.pyx":439 + /* "datrie.pyx":462 * if default is RAISE_KEY_ERROR: * raise KeyError(key) * return default # <<<<<<<<<<<<<< @@ -6688,12 +7453,10 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default); __pyx_r = __pyx_v_default; - goto __pyx_L4; - goto __pyx_L11; + goto __pyx_L4_return; } - __pyx_L11:; - /* "datrie.pyx":441 + /* "datrie.pyx":464 * return default * * return data # <<<<<<<<<<<<<< @@ -6701,14 +7464,14 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob * finally: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_11 = PyInt_FromLong(__pyx_v_data); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_data); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L5_error;} __Pyx_GOTREF(__pyx_t_11); __pyx_r = __pyx_t_11; __pyx_t_11 = 0; - goto __pyx_L4; + goto __pyx_L4_return; } - /* "datrie.pyx":444 + /* "datrie.pyx":467 * * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -6716,41 +7479,59 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __Pyx_XGOTREF(__pyx_t_16); + __Pyx_XGOTREF(__pyx_t_17); + __Pyx_XGOTREF(__pyx_t_18); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_12 = __pyx_filename; + { + trie_state_free(__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_16); + __Pyx_XGIVEREF(__pyx_t_17); + __Pyx_XGIVEREF(__pyx_t_18); + __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); + } + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ErrRestore(__pyx_t_13, __pyx_t_14, __pyx_t_15); + __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_12; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_18 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_18; + __pyx_t_18 = 0; + goto __pyx_L0; } } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":441 + * return self._longest_prefix_value(key, default) + * + * cdef _longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) + * + */ + + /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datrie.BaseTrie._longest_prefix_value", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -6761,18 +7542,28 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__longest_prefix_value(struct __pyx_ob return __pyx_r; } +/* "datrie.pyx":471 + * + * + * def has_keys_with_prefix(self, unicode prefix): # <<<<<<<<<<<<<< + * """ + * Returns True if any key in the trie begins with ``prefix``. + */ + /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_50has_keys_with_prefix(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_49has_keys_with_prefix[] = "\n Returns True if any key in the trie begins with ``prefix``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_50has_keys_with_prefix(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_52has_keys_with_prefix(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_51has_keys_with_prefix[] = "\n Returns True if any key in the trie begins with ``prefix``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_52has_keys_with_prefix(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix) { CYTHON_UNUSED int __pyx_lineno = 0; CYTHON_UNUSED const char *__pyx_filename = NULL; CYTHON_UNUSED int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("has_keys_with_prefix (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_prefix)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_51has_keys_with_prefix(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), ((PyObject*)__pyx_v_prefix)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -6781,15 +7572,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_50has_keys_with_prefix(PyObject *__p return __pyx_r; } -/* "datrie.pyx":448 - * - * - * def has_keys_with_prefix(self, unicode prefix): # <<<<<<<<<<<<<< - * """ - * Returns True if any key in the trie begins with ``prefix``. - */ - -static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_51has_keys_with_prefix(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { TrieState *__pyx_v_state; Py_UCS4 __pyx_v_char; PyObject *__pyx_r = NULL; @@ -6802,13 +7585,19 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ int __pyx_t_6; int __pyx_t_7; Py_ssize_t __pyx_t_8; - PyObject *__pyx_t_9 = NULL; + char const *__pyx_t_9; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("has_keys_with_prefix", 0); - /* "datrie.pyx":452 + /* "datrie.pyx":475 * Returns True if any key in the trie begins with ``prefix``. * """ * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) # <<<<<<<<<<<<<< @@ -6817,7 +7606,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ */ __pyx_v_state = trie_root(__pyx_v_self->_c_trie); - /* "datrie.pyx":453 + /* "datrie.pyx":476 * """ * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * if state == NULL: # <<<<<<<<<<<<<< @@ -6827,19 +7616,17 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ __pyx_t_1 = ((__pyx_v_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":454 + /* "datrie.pyx":477 * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * if state == NULL: * raise MemoryError() # <<<<<<<<<<<<<< * try: * for char in prefix: */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":455 + /* "datrie.pyx":478 * if state == NULL: * raise MemoryError() * try: # <<<<<<<<<<<<<< @@ -6848,25 +7635,25 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ */ /*try:*/ { - /* "datrie.pyx":456 + /* "datrie.pyx":479 * raise MemoryError() * try: * for char in prefix: # <<<<<<<<<<<<<< * if not cdatrie.trie_state_walk(state, char): * return False */ - if (unlikely(((PyObject *)__pyx_v_prefix) == Py_None)) { + if (unlikely(__pyx_v_prefix == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L5;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L5_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); + __Pyx_INCREF(__pyx_v_prefix); __pyx_t_2 = __pyx_v_prefix; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_2), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_2, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L5_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_3 = __pyx_t_8; __pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_3); - /* "datrie.pyx":457 + /* "datrie.pyx":480 * try: * for char in prefix: * if not cdatrie.trie_state_walk(state, char): # <<<<<<<<<<<<<< @@ -6876,7 +7663,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ __pyx_t_1 = ((!(trie_state_walk(__pyx_v_state, ((AlphaChar)__pyx_v_char)) != 0)) != 0); if (__pyx_t_1) { - /* "datrie.pyx":458 + /* "datrie.pyx":481 * for char in prefix: * if not cdatrie.trie_state_walk(state, char): * return False # <<<<<<<<<<<<<< @@ -6884,19 +7671,15 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ * finally: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_r = __pyx_t_9; - __pyx_t_9 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - goto __pyx_L4; - goto __pyx_L9; + __Pyx_INCREF(Py_False); + __pyx_r = Py_False; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L4_return; } - __pyx_L9:; } - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":459 + /* "datrie.pyx":482 * if not cdatrie.trie_state_walk(state, char): * return False * return True # <<<<<<<<<<<<<< @@ -6904,14 +7687,12 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ * cdatrie.trie_state_free(state) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_9 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_r = __pyx_t_9; - __pyx_t_9 = 0; - goto __pyx_L4; + __Pyx_INCREF(Py_True); + __pyx_r = Py_True; + goto __pyx_L4_return; } - /* "datrie.pyx":461 + /* "datrie.pyx":484 * return True * finally: * cdatrie.trie_state_free(state) # <<<<<<<<<<<<<< @@ -6919,41 +7700,57 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ * cpdef items(self, unicode prefix=None): */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L6; - __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L6; - __pyx_L5: { - __pyx_why = 4; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L6; - } - __pyx_L6:; - trie_state_free(__pyx_v_state); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + /*exception exit:*/{ + __pyx_L5_error:; + __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __Pyx_XGOTREF(__pyx_t_13); + __Pyx_XGOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_t_15); + __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_9 = __pyx_filename; + { + trie_state_free(__pyx_v_state); } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_13); + __Pyx_XGIVEREF(__pyx_t_14); + __Pyx_XGIVEREF(__pyx_t_15); + __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); + } + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12); + __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; + __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_9; + goto __pyx_L1_error; + } + __pyx_L4_return: { + __pyx_t_15 = __pyx_r; + __pyx_r = 0; + trie_state_free(__pyx_v_state); + __pyx_r = __pyx_t_15; + __pyx_t_15 = 0; + goto __pyx_L0; } } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":471 + * + * + * def has_keys_with_prefix(self, unicode prefix): # <<<<<<<<<<<<<< + * """ + * Returns True if any key in the trie begins with ``prefix``. + */ + + /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_2)); - __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("datrie.BaseTrie.has_keys_with_prefix", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -6962,7 +7759,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ return __pyx_r; } -/* "datrie.pyx":463 +/* "datrie.pyx":486 * cdatrie.trie_state_free(state) * * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -6970,7 +7767,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_49has_keys_with_prefix(struct __pyx_ * Returns a list of this trie's items (``(key,value)`` tuples). */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6datrie_8BaseTrie_54items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_items *__pyx_optional_args) { PyObject *__pyx_v_prefix = ((PyObject*)Py_None); int __pyx_v_success; @@ -6998,18 +7795,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_52items)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_54items)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7018,37 +7815,37 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":471 + /* "datrie.pyx":494 * """ * cdef bint success * cdef list res = [] # <<<<<<<<<<<<<< * cdef BaseState state = BaseState(self) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_res = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":472 + /* "datrie.pyx":495 * cdef bint success * cdef list res = [] * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< * * if prefix is not None: */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":474 + /* "datrie.pyx":497 * cdef BaseState state = BaseState(self) * * if prefix is not None: # <<<<<<<<<<<<<< @@ -7059,20 +7856,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":475 + /* "datrie.pyx":498 * * if prefix is not None: * success = state.walk(prefix) # <<<<<<<<<<<<<< * if not success: * return res */ - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_5; - /* "datrie.pyx":476 + /* "datrie.pyx":499 * if prefix is not None: * success = state.walk(prefix) * if not success: # <<<<<<<<<<<<<< @@ -7082,7 +7879,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_5) { - /* "datrie.pyx":477 + /* "datrie.pyx":500 * success = state.walk(prefix) * if not success: * return res # <<<<<<<<<<<<<< @@ -7090,35 +7887,33 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr * cdef BaseIterator iter = BaseIterator(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "datrie.pyx":479 + /* "datrie.pyx":502 * return res * * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< * * if prefix is None: */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":481 + /* "datrie.pyx":504 * cdef BaseIterator iter = BaseIterator(state) * * if prefix is None: # <<<<<<<<<<<<<< @@ -7129,7 +7924,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "datrie.pyx":482 + /* "datrie.pyx":505 * * if prefix is None: * while iter.next(): # <<<<<<<<<<<<<< @@ -7140,18 +7935,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":483 + /* "datrie.pyx":506 * if prefix is None: * while iter.next(): * res.append((iter.key(), iter.data())) # <<<<<<<<<<<<<< * else: * while iter.next(): */ - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_to_py_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -7159,14 +7954,14 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __Pyx_GIVEREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } goto __pyx_L5; } /*else*/ { - /* "datrie.pyx":485 + /* "datrie.pyx":508 * res.append((iter.key(), iter.data())) * else: * while iter.next(): # <<<<<<<<<<<<<< @@ -7177,35 +7972,35 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":486 + /* "datrie.pyx":509 * else: * while iter.next(): * res.append((prefix+iter.key(), iter.data())) # <<<<<<<<<<<<<< * * return res */ - __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_prefix), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_prefix, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_to_py_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_2 = 0; - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } __pyx_L5:; - /* "datrie.pyx":488 + /* "datrie.pyx":511 * res.append((prefix+iter.key(), iter.data())) * * return res # <<<<<<<<<<<<<< @@ -7213,12 +8008,19 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr * */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":486 + * cdatrie.trie_state_free(state) + * + * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's items (``(key,value)`` tuples). + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -7235,9 +8037,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_items(struct __pyx_obj_6datrie_BaseTr } /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_51items[] = "\n Returns a list of this trie's items (``(key,value)`` tuples).\n\n If ``prefix`` is not None, returns only the items\n associated with keys prefixed by ``prefix``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_54items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_53items[] = "\n Returns a list of this trie's items (``(key,value)`` tuples).\n\n If ``prefix`` is not None, returns only the items\n associated with keys prefixed by ``prefix``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_54items(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_prefix = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -7246,16 +8048,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("items (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__prefix,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; PyObject* values[1] = {0}; - - /* "datrie.pyx":463 - * cdatrie.trie_state_free(state) - * - * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< - * """ - * Returns a list of this trie's items (``(key,value)`` tuples). - */ values[0] = ((PyObject*)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -7269,12 +8063,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyOb switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "items") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "items") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7287,14 +8081,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("items", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("items", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.items", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_51items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_53items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -7303,7 +8099,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_52items(PyObject *__pyx_v_self, PyOb return __pyx_r; } -static PyObject *__pyx_pf_6datrie_8BaseTrie_51items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_53items(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7315,14 +8111,13 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_51items(struct __pyx_obj_6datrie_Bas __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.prefix = __pyx_v_prefix; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->items(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->items(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.items", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -7333,7 +8128,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_51items(struct __pyx_obj_6datrie_Bas return __pyx_r; } -/* "datrie.pyx":491 +/* "datrie.pyx":514 * * * cpdef keys(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -7341,7 +8136,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_51items(struct __pyx_obj_6datrie_Bas * Returns a list of this trie's keys. */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6datrie_8BaseTrie_56keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_keys *__pyx_optional_args) { PyObject *__pyx_v_prefix = ((PyObject*)Py_None); int __pyx_v_success; @@ -7369,18 +8164,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_54keys)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_56keys)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7389,37 +8184,37 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":498 + /* "datrie.pyx":521 * """ * cdef bint success * cdef list res = [] # <<<<<<<<<<<<<< * cdef BaseState state = BaseState(self) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_res = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":499 + /* "datrie.pyx":522 * cdef bint success * cdef list res = [] * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< * * if prefix is not None: */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":501 + /* "datrie.pyx":524 * cdef BaseState state = BaseState(self) * * if prefix is not None: # <<<<<<<<<<<<<< @@ -7430,20 +8225,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":502 + /* "datrie.pyx":525 * * if prefix is not None: * success = state.walk(prefix) # <<<<<<<<<<<<<< * if not success: * return res */ - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_5; - /* "datrie.pyx":503 + /* "datrie.pyx":526 * if prefix is not None: * success = state.walk(prefix) * if not success: # <<<<<<<<<<<<<< @@ -7453,7 +8248,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_5) { - /* "datrie.pyx":504 + /* "datrie.pyx":527 * success = state.walk(prefix) * if not success: * return res # <<<<<<<<<<<<<< @@ -7461,35 +8256,33 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri * cdef BaseIterator iter = BaseIterator(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "datrie.pyx":506 + /* "datrie.pyx":529 * return res * * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< * * if prefix is None: */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":508 + /* "datrie.pyx":531 * cdef BaseIterator iter = BaseIterator(state) * * if prefix is None: # <<<<<<<<<<<<<< @@ -7500,7 +8293,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "datrie.pyx":509 + /* "datrie.pyx":532 * * if prefix is None: * while iter.next(): # <<<<<<<<<<<<<< @@ -7511,23 +8304,23 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":510 + /* "datrie.pyx":533 * if prefix is None: * while iter.next(): * res.append(iter.key()) # <<<<<<<<<<<<<< * else: * while iter.next(): */ - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } goto __pyx_L5; } /*else*/ { - /* "datrie.pyx":512 + /* "datrie.pyx":535 * res.append(iter.key()) * else: * while iter.next(): # <<<<<<<<<<<<<< @@ -7538,25 +8331,25 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":513 + /* "datrie.pyx":536 * else: * while iter.next(): * res.append(prefix+iter.key()) # <<<<<<<<<<<<<< * * return res */ - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_prefix), __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_prefix, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_3); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } __pyx_L5:; - /* "datrie.pyx":515 + /* "datrie.pyx":538 * res.append(prefix+iter.key()) * * return res # <<<<<<<<<<<<<< @@ -7564,12 +8357,19 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri * cpdef values(self, unicode prefix=None): */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":514 + * + * + * cpdef keys(self, unicode prefix=None): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's keys. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -7586,9 +8386,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_keys(struct __pyx_obj_6datrie_BaseTri } /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_53keys[] = "\n Returns a list of this trie's keys.\n\n If ``prefix`` is not None, returns only the keys prefixed by ``prefix``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_56keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_55keys[] = "\n Returns a list of this trie's keys.\n\n If ``prefix`` is not None, returns only the keys prefixed by ``prefix``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_56keys(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_prefix = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -7597,16 +8397,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("keys (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__prefix,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; PyObject* values[1] = {0}; - - /* "datrie.pyx":491 - * - * - * cpdef keys(self, unicode prefix=None): # <<<<<<<<<<<<<< - * """ - * Returns a list of this trie's keys. - */ values[0] = ((PyObject*)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -7620,12 +8412,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObj switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "keys") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "keys") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7638,14 +8430,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("keys", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("keys", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.keys", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_53keys(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_55keys(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -7654,7 +8448,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_54keys(PyObject *__pyx_v_self, PyObj return __pyx_r; } -static PyObject *__pyx_pf_6datrie_8BaseTrie_53keys(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_55keys(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7666,14 +8460,13 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_53keys(struct __pyx_obj_6datrie_Base __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.prefix = __pyx_v_prefix; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->keys(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->keys(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.keys", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -7684,7 +8477,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_53keys(struct __pyx_obj_6datrie_Base return __pyx_r; } -/* "datrie.pyx":517 +/* "datrie.pyx":540 * return res * * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -7692,7 +8485,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_53keys(struct __pyx_obj_6datrie_Base * Returns a list of this trie's values. */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_6datrie_8BaseTrie_58values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_values *__pyx_optional_args) { PyObject *__pyx_v_prefix = ((PyObject*)Py_None); int __pyx_v_success; @@ -7720,18 +8513,18 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_56values)) { + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8BaseTrie_58values)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -7740,37 +8533,37 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":525 + /* "datrie.pyx":548 * """ * cdef bint success * cdef list res = [] # <<<<<<<<<<<<<< * cdef BaseState state = BaseState(self) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_res = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":526 + /* "datrie.pyx":549 * cdef bint success * cdef list res = [] * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< * * if prefix is not None: */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":528 + /* "datrie.pyx":551 * cdef BaseState state = BaseState(self) * * if prefix is not None: # <<<<<<<<<<<<<< @@ -7781,20 +8574,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":529 + /* "datrie.pyx":552 * * if prefix is not None: * success = state.walk(prefix) # <<<<<<<<<<<<<< * if not success: * return res */ - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_5; - /* "datrie.pyx":530 + /* "datrie.pyx":553 * if prefix is not None: * success = state.walk(prefix) * if not success: # <<<<<<<<<<<<<< @@ -7804,7 +8597,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_5) { - /* "datrie.pyx":531 + /* "datrie.pyx":554 * success = state.walk(prefix) * if not success: * return res # <<<<<<<<<<<<<< @@ -7812,35 +8605,33 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT * cdef BaseIterator iter = BaseIterator(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "datrie.pyx":533 + /* "datrie.pyx":556 * return res * * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< * while iter.next(): * res.append(iter.data()) */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":534 + /* "datrie.pyx":557 * * cdef BaseIterator iter = BaseIterator(state) * while iter.next(): # <<<<<<<<<<<<<< @@ -7851,20 +8642,20 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT __pyx_t_5 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_5) break; - /* "datrie.pyx":535 + /* "datrie.pyx":558 * cdef BaseIterator iter = BaseIterator(state) * while iter.next(): * res.append(iter.data()) # <<<<<<<<<<<<<< * return res * */ - __pyx_t_1 = __Pyx_PyInt_to_py_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":536 + /* "datrie.pyx":559 * while iter.next(): * res.append(iter.data()) * return res # <<<<<<<<<<<<<< @@ -7872,12 +8663,19 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT * cdef _index_to_value(self, cdatrie.TrieData index): */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":540 + * return res + * + * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's values. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -7894,9 +8692,9 @@ static PyObject *__pyx_f_6datrie_8BaseTrie_values(struct __pyx_obj_6datrie_BaseT } /* Python wrapper */ -static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6datrie_8BaseTrie_55values[] = "\n Returns a list of this trie's values.\n\n If ``prefix`` is not None, returns only the values\n associated with keys prefixed by ``prefix``.\n "; -static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_6datrie_8BaseTrie_58values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6datrie_8BaseTrie_57values[] = "\n Returns a list of this trie's values.\n\n If ``prefix`` is not None, returns only the values\n associated with keys prefixed by ``prefix``.\n "; +static PyObject *__pyx_pw_6datrie_8BaseTrie_58values(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_prefix = 0; int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -7905,16 +8703,8 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyO __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("values (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__prefix,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; PyObject* values[1] = {0}; - - /* "datrie.pyx":517 - * return res - * - * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< - * """ - * Returns a list of this trie's values. - */ values[0] = ((PyObject*)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -7928,12 +8718,12 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyO switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "values") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "values") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7946,14 +8736,16 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyO } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("values", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("values", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.BaseTrie.values", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_6datrie_8BaseTrie_55values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_6datrie_8BaseTrie_57values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -7962,7 +8754,7 @@ static PyObject *__pyx_pw_6datrie_8BaseTrie_56values(PyObject *__pyx_v_self, PyO return __pyx_r; } -static PyObject *__pyx_pf_6datrie_8BaseTrie_55values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { +static PyObject *__pyx_pf_6datrie_8BaseTrie_57values(struct __pyx_obj_6datrie_BaseTrie *__pyx_v_self, PyObject *__pyx_v_prefix) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7974,14 +8766,13 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_55values(struct __pyx_obj_6datrie_Ba __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.prefix = __pyx_v_prefix; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->values(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_vtab)->values(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie.values", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -7992,7 +8783,7 @@ static PyObject *__pyx_pf_6datrie_8BaseTrie_55values(struct __pyx_obj_6datrie_Ba return __pyx_r; } -/* "datrie.pyx":538 +/* "datrie.pyx":561 * return res * * cdef _index_to_value(self, cdatrie.TrieData index): # <<<<<<<<<<<<<< @@ -8009,7 +8800,7 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__index_to_value(CYTHON_UNUSED struct int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_index_to_value", 0); - /* "datrie.pyx":539 + /* "datrie.pyx":562 * * cdef _index_to_value(self, cdatrie.TrieData index): * return index # <<<<<<<<<<<<<< @@ -8017,14 +8808,21 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__index_to_value(CYTHON_UNUSED struct * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_TrieData(__pyx_v_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_TrieData(__pyx_v_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":561 + * return res + * + * cdef _index_to_value(self, cdatrie.TrieData index): # <<<<<<<<<<<<<< + * return index + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseTrie._index_to_value", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -8035,6 +8833,14 @@ static PyObject *__pyx_f_6datrie_8BaseTrie__index_to_value(CYTHON_UNUSED struct return __pyx_r; } +/* "datrie.pyx":573 + * cdef list _values + * + * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< + * """ + * For efficiency trie needs to know what unicode symbols + */ + /* Python wrapper */ static int __pyx_pw_6datrie_4Trie_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6datrie_4Trie___init__[] = "\n For efficiency trie needs to know what unicode symbols\n it should be able to store so this constructor requires\n either ``alphabet`` (a string/iterable with all allowed characters),\n ``ranges`` (a list of (begin, end) pairs, e.g. [('a', 'z')])\n or ``alpha_map`` (:class:`datrie.AlphaMap` instance).\n "; @@ -8053,20 +8859,12 @@ static int __pyx_pw_6datrie_4Trie_1__init__(PyObject *__pyx_v_self, PyObject *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alphabet,&__pyx_n_s__ranges,&__pyx_n_s__alpha_map,&__pyx_n_s___create,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alphabet,&__pyx_n_s_ranges,&__pyx_n_s_alpha_map,&__pyx_n_s_create,0}; PyObject* values[4] = {0,0,0,0}; - - /* "datrie.pyx":550 - * cdef list _values - * - * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< - * """ - * For efficiency trie needs to know what unicode symbols - */ values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); values[2] = (PyObject *)((struct __pyx_obj_6datrie_AlphaMap *)Py_None); - values[3] = __pyx_k_15; + values[3] = ((PyObject *)Py_True); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -8082,27 +8880,27 @@ static int __pyx_pw_6datrie_4Trie_1__init__(PyObject *__pyx_v_self, PyObject *__ switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alphabet); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ranges); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ranges); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_map); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha_map); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s___create); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_create); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -8121,14 +8919,16 @@ static int __pyx_pw_6datrie_4Trie_1__init__(PyObject *__pyx_v_self, PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alpha_map), __pyx_ptype_6datrie_AlphaMap, 1, "alpha_map", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alpha_map), __pyx_ptype_6datrie_AlphaMap, 1, "alpha_map", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie___init__(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_alphabet, __pyx_v_ranges, __pyx_v_alpha_map, __pyx_v__create); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -8148,29 +8948,29 @@ static int __pyx_pf_6datrie_4Trie___init__(struct __pyx_obj_6datrie_Trie *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "datrie.pyx":559 + /* "datrie.pyx":582 * """ * * self._values = [] # <<<<<<<<<<<<<< * super(Trie, self).__init__(alphabet, ranges, alpha_map, _create) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->_values); - __Pyx_DECREF(((PyObject *)__pyx_v_self->_values)); + __Pyx_DECREF(__pyx_v_self->_values); __pyx_v_self->_values = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":560 + /* "datrie.pyx":583 * * self._values = [] * super(Trie, self).__init__(alphabet, ranges, alpha_map, _create) # <<<<<<<<<<<<<< * * def __getitem__(self, unicode key): */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); @@ -8178,13 +8978,13 @@ static int __pyx_pf_6datrie_4Trie___init__(struct __pyx_obj_6datrie_Trie *__pyx_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_alphabet); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_alphabet); @@ -8198,12 +8998,21 @@ static int __pyx_pf_6datrie_4Trie___init__(struct __pyx_obj_6datrie_Trie *__pyx_ __Pyx_INCREF(__pyx_v__create); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v__create); __Pyx_GIVEREF(__pyx_v__create); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + /* "datrie.pyx":573 + * cdef list _values + * + * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< + * """ + * For efficiency trie needs to know what unicode symbols + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -8217,6 +9026,14 @@ static int __pyx_pf_6datrie_4Trie___init__(struct __pyx_obj_6datrie_Trie *__pyx_ return __pyx_r; } +/* "datrie.pyx":585 + * super(Trie, self).__init__(alphabet, ranges, alpha_map, _create) + * + * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData index = self._getitem(key) + * return self._values[index] + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static PyObject *__pyx_pw_6datrie_4Trie_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -8226,8 +9043,10 @@ static PyObject *__pyx_pw_6datrie_4Trie_3__getitem__(PyObject *__pyx_v_self, PyO PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_2__getitem__(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -8236,14 +9055,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_3__getitem__(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "datrie.pyx":562 - * super(Trie, self).__init__(alphabet, ranges, alpha_map, _create) - * - * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< - * cdef cdatrie.TrieData index = self._getitem(key) - * return self._values[index] - */ - static PyObject *__pyx_pf_6datrie_4Trie_2__getitem__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { TrieData __pyx_v_index; PyObject *__pyx_r = NULL; @@ -8255,17 +9066,17 @@ static PyObject *__pyx_pf_6datrie_4Trie_2__getitem__(struct __pyx_obj_6datrie_Tr int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "datrie.pyx":563 + /* "datrie.pyx":586 * * def __getitem__(self, unicode key): * cdef cdatrie.TrieData index = self._getitem(key) # <<<<<<<<<<<<<< * return self._values[index] * */ - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._getitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._getitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_index = __pyx_t_1; - /* "datrie.pyx":564 + /* "datrie.pyx":587 * def __getitem__(self, unicode key): * cdef cdatrie.TrieData index = self._getitem(key) * return self._values[index] # <<<<<<<<<<<<<< @@ -8273,18 +9084,25 @@ static PyObject *__pyx_pf_6datrie_4Trie_2__getitem__(struct __pyx_obj_6datrie_Tr * def __setitem__(self, unicode key, object value): */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_v_index, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_v_index, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":585 + * super(Trie, self).__init__(alphabet, ranges, alpha_map, _create) + * + * def __getitem__(self, unicode key): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData index = self._getitem(key) + * return self._values[index] + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("datrie.Trie.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -8295,6 +9113,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_2__getitem__(struct __pyx_obj_6datrie_Tr return __pyx_r; } +/* "datrie.pyx":589 + * return self._values[index] + * + * def __setitem__(self, unicode key, object value): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData next_index = len(self._values) + * cdef cdatrie.TrieData index = self._setdefault(key, next_index) + */ + /* Python wrapper */ static int __pyx_pw_6datrie_4Trie_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_6datrie_4Trie_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) { @@ -8304,8 +9130,10 @@ static int __pyx_pw_6datrie_4Trie_5__setitem__(PyObject *__pyx_v_self, PyObject int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_4__setitem__(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key), ((PyObject *)__pyx_v_value)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -8314,14 +9142,6 @@ static int __pyx_pw_6datrie_4Trie_5__setitem__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "datrie.pyx":566 - * return self._values[index] - * - * def __setitem__(self, unicode key, object value): # <<<<<<<<<<<<<< - * cdef cdatrie.TrieData next_index = len(self._values) - * cdef cdatrie.TrieData index = self._setdefault(key, next_index) - */ - static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) { TrieData __pyx_v_next_index; TrieData __pyx_v_index; @@ -8336,24 +9156,24 @@ static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "datrie.pyx":567 + /* "datrie.pyx":590 * * def __setitem__(self, unicode key, object value): * cdef cdatrie.TrieData next_index = len(self._values) # <<<<<<<<<<<<<< * cdef cdatrie.TrieData index = self._setdefault(key, next_index) * if index == next_index: */ - __pyx_t_1 = ((PyObject *)__pyx_v_self->_values); + __pyx_t_1 = __pyx_v_self->_values; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_next_index = __pyx_t_2; - /* "datrie.pyx":568 + /* "datrie.pyx":591 * def __setitem__(self, unicode key, object value): * cdef cdatrie.TrieData next_index = len(self._values) * cdef cdatrie.TrieData index = self._setdefault(key, next_index) # <<<<<<<<<<<<<< @@ -8362,7 +9182,7 @@ static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__ */ __pyx_v_index = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._setdefault(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_next_index); - /* "datrie.pyx":569 + /* "datrie.pyx":592 * cdef cdatrie.TrieData next_index = len(self._values) * cdef cdatrie.TrieData index = self._setdefault(key, next_index) * if index == next_index: # <<<<<<<<<<<<<< @@ -8372,37 +9192,46 @@ static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__ __pyx_t_3 = ((__pyx_v_index == __pyx_v_next_index) != 0); if (__pyx_t_3) { - /* "datrie.pyx":570 + /* "datrie.pyx":593 * cdef cdatrie.TrieData index = self._setdefault(key, next_index) * if index == next_index: * self._values.append(value) # insert # <<<<<<<<<<<<<< * else: * self._values[index] = value # update */ - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_values, __pyx_v_value); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_values, __pyx_v_value); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } /*else*/ { - /* "datrie.pyx":572 + /* "datrie.pyx":595 * self._values.append(value) # insert * else: * self._values[index] = value # update # <<<<<<<<<<<<<< * * def setdefault(self, unicode key, object value): */ - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - if (__Pyx_SetItemInt(((PyObject *)__pyx_v_self->_values), __pyx_v_index, __pyx_v_value, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_SetItemInt(__pyx_v_self->_values, __pyx_v_index, __pyx_v_value, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; + /* "datrie.pyx":589 + * return self._values[index] + * + * def __setitem__(self, unicode key, object value): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData next_index = len(self._values) + * cdef cdatrie.TrieData index = self._setdefault(key, next_index) + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -8414,6 +9243,14 @@ static int __pyx_pf_6datrie_4Trie_4__setitem__(struct __pyx_obj_6datrie_Trie *__ return __pyx_r; } +/* "datrie.pyx":597 + * self._values[index] = value # update + * + * def setdefault(self, unicode key, object value): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData next_index = len(self._values) + * cdef cdatrie.TrieData index = self._setdefault(key, next_index) + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -8426,7 +9263,7 @@ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("setdefault (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_value,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -8440,16 +9277,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyOb kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("setdefault", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("setdefault", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setdefault") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setdefault") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -8462,14 +9299,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("setdefault", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("setdefault", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.setdefault", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_6setdefault(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_key, __pyx_v_value); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -8478,14 +9317,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_7setdefault(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "datrie.pyx":574 - * self._values[index] = value # update - * - * def setdefault(self, unicode key, object value): # <<<<<<<<<<<<<< - * cdef cdatrie.TrieData next_index = len(self._values) - * cdef cdatrie.TrieData index = self._setdefault(key, next_index) - */ - static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) { TrieData __pyx_v_next_index; TrieData __pyx_v_index; @@ -8500,24 +9331,24 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("setdefault", 0); - /* "datrie.pyx":575 + /* "datrie.pyx":598 * * def setdefault(self, unicode key, object value): * cdef cdatrie.TrieData next_index = len(self._values) # <<<<<<<<<<<<<< * cdef cdatrie.TrieData index = self._setdefault(key, next_index) * */ - __pyx_t_1 = ((PyObject *)__pyx_v_self->_values); + __pyx_t_1 = __pyx_v_self->_values; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_next_index = __pyx_t_2; - /* "datrie.pyx":576 + /* "datrie.pyx":599 * def setdefault(self, unicode key, object value): * cdef cdatrie.TrieData next_index = len(self._values) * cdef cdatrie.TrieData index = self._setdefault(key, next_index) # <<<<<<<<<<<<<< @@ -8526,7 +9357,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri */ __pyx_v_index = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._setdefault(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, __pyx_v_next_index); - /* "datrie.pyx":578 + /* "datrie.pyx":601 * cdef cdatrie.TrieData index = self._setdefault(key, next_index) * * if index == next_index: # <<<<<<<<<<<<<< @@ -8536,20 +9367,20 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri __pyx_t_3 = ((__pyx_v_index == __pyx_v_next_index) != 0); if (__pyx_t_3) { - /* "datrie.pyx":579 + /* "datrie.pyx":602 * * if index == next_index: * self._values.append(value) # insert # <<<<<<<<<<<<<< * return value * else: */ - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_values, __pyx_v_value); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->_values, __pyx_v_value); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":580 + /* "datrie.pyx":603 * if index == next_index: * self._values.append(value) # insert * return value # <<<<<<<<<<<<<< @@ -8560,11 +9391,10 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0; - goto __pyx_L3; } /*else*/ { - /* "datrie.pyx":582 + /* "datrie.pyx":605 * return value * else: * return self._values[index] # lookup # <<<<<<<<<<<<<< @@ -8572,20 +9402,26 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri * def __delitem__(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_v_index, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_v_index, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } - __pyx_L3:; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":597 + * self._values[index] = value # update + * + * def setdefault(self, unicode key, object value): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData next_index = len(self._values) + * cdef cdatrie.TrieData index = self._setdefault(key, next_index) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.Trie.setdefault", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -8596,6 +9432,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_6setdefault(struct __pyx_obj_6datrie_Tri return __pyx_r; } +/* "datrie.pyx":607 + * return self._values[index] # lookup + * + * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< + * # XXX: this could be faster (key is encoded twice here) + * cdef cdatrie.TrieData index = self._getitem(key) + */ + /* Python wrapper */ static int __pyx_pw_6datrie_4Trie_9__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static int __pyx_pw_6datrie_4Trie_9__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -8605,8 +9449,10 @@ static int __pyx_pw_6datrie_4Trie_9__delitem__(PyObject *__pyx_v_self, PyObject int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__delitem__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_8__delitem__(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -8615,14 +9461,6 @@ static int __pyx_pw_6datrie_4Trie_9__delitem__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "datrie.pyx":584 - * return self._values[index] # lookup - * - * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< - * # XXX: this could be faster (key is encoded twice here) - * cdef cdatrie.TrieData index = self._getitem(key) - */ - static int __pyx_pf_6datrie_4Trie_8__delitem__(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { TrieData __pyx_v_index; int __pyx_r; @@ -8636,33 +9474,33 @@ static int __pyx_pf_6datrie_4Trie_8__delitem__(struct __pyx_obj_6datrie_Trie *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__delitem__", 0); - /* "datrie.pyx":586 + /* "datrie.pyx":609 * def __delitem__(self, unicode key): * # XXX: this could be faster (key is encoded twice here) * cdef cdatrie.TrieData index = self._getitem(key) # <<<<<<<<<<<<<< * self._values[index] = DELETED_OBJECT * if not self._delitem(key): */ - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._getitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._getitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_index = __pyx_t_1; - /* "datrie.pyx":587 + /* "datrie.pyx":610 * # XXX: this could be faster (key is encoded twice here) * cdef cdatrie.TrieData index = self._getitem(key) * self._values[index] = DELETED_OBJECT # <<<<<<<<<<<<<< * if not self._delitem(key): * raise KeyError(key) */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DELETED_OBJECT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DELETED_OBJECT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - if (__Pyx_SetItemInt(((PyObject *)__pyx_v_self->_values), __pyx_v_index, __pyx_t_2, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_SetItemInt(__pyx_v_self->_values, __pyx_v_index, __pyx_t_2, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":588 + /* "datrie.pyx":611 * cdef cdatrie.TrieData index = self._getitem(key) * self._values[index] = DELETED_OBJECT * if not self._delitem(key): # <<<<<<<<<<<<<< @@ -8672,28 +9510,35 @@ static int __pyx_pf_6datrie_4Trie_8__delitem__(struct __pyx_obj_6datrie_Trie *__ __pyx_t_3 = ((!(((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._delitem(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, 0) != 0)) != 0); if (__pyx_t_3) { - /* "datrie.pyx":589 + /* "datrie.pyx":612 * self._values[index] = DELETED_OBJECT * if not self._delitem(key): * raise KeyError(key) # <<<<<<<<<<<<<< * * def write(self, f): */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_4 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; + /* "datrie.pyx":607 + * return self._values[index] # lookup + * + * def __delitem__(self, unicode key): # <<<<<<<<<<<<<< + * # XXX: this could be faster (key is encoded twice here) + * cdef cdatrie.TrieData index = self._getitem(key) + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -8706,6 +9551,14 @@ static int __pyx_pf_6datrie_4Trie_8__delitem__(struct __pyx_obj_6datrie_Trie *__ return __pyx_r; } +/* "datrie.pyx":614 + * raise KeyError(key) + * + * def write(self, f): # <<<<<<<<<<<<<< + * """ + * Writes a trie to a file. File-like objects without real + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_11write(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/ static char __pyx_doc_6datrie_4Trie_10write[] = "\n Writes a trie to a file. File-like objects without real\n file descriptors are not supported.\n "; @@ -8714,18 +9567,12 @@ static PyObject *__pyx_pw_6datrie_4Trie_11write(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_4Trie_10write(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject *)__pyx_v_f)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":591 - * raise KeyError(key) - * - * def write(self, f): # <<<<<<<<<<<<<< - * """ - * Writes a trie to a file. File-like objects without real - */ - static PyObject *__pyx_pf_6datrie_4Trie_10write(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_f) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -8738,14 +9585,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_10write(struct __pyx_obj_6datrie_Trie *_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write", 0); - /* "datrie.pyx":596 + /* "datrie.pyx":619 * file descriptors are not supported. * """ * super(Trie, self).write(f) # <<<<<<<<<<<<<< * pickle.dump(self._values, f, protocol=2) * */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); @@ -8753,53 +9600,62 @@ static PyObject *__pyx_pf_6datrie_4Trie_10write(struct __pyx_obj_6datrie_Trie *_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":597 + /* "datrie.pyx":620 * """ * super(Trie, self).write(f) * pickle.dump(self._values, f, protocol=2) # <<<<<<<<<<<<<< * * @classmethod */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__pickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__dump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_self->_values)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->_values)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_values)); + __Pyx_INCREF(__pyx_v_self->_values); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_values); + __Pyx_GIVEREF(__pyx_v_self->_values); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__protocol), __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_protocol, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + /* "datrie.pyx":614 + * raise KeyError(key) + * + * def write(self, f): # <<<<<<<<<<<<<< + * """ + * Writes a trie to a file. File-like objects without real + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -8815,6 +9671,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_10write(struct __pyx_obj_6datrie_Trie *_ return __pyx_r; } +/* "datrie.pyx":623 + * + * @classmethod + * def read(cls, f): # <<<<<<<<<<<<<< + * """ + * Creates a new Trie by reading it from file. + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_13read(PyObject *__pyx_v_cls, PyObject *__pyx_v_f); /*proto*/ static char __pyx_doc_6datrie_4Trie_12read[] = "\n Creates a new Trie by reading it from file.\n File-like objects without real file descriptors are not supported.\n "; @@ -8823,18 +9687,12 @@ static PyObject *__pyx_pw_6datrie_4Trie_13read(PyObject *__pyx_v_cls, PyObject * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_4Trie_12read(((PyObject*)__pyx_v_cls), ((PyObject *)__pyx_v_f)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":600 - * - * @classmethod - * def read(cls, f): # <<<<<<<<<<<<<< - * """ - * Creates a new Trie by reading it from file. - */ - static PyObject *__pyx_pf_6datrie_4Trie_12read(PyObject *__pyx_v_cls, PyObject *__pyx_v_f) { struct __pyx_obj_6datrie_Trie *__pyx_v_trie = 0; PyObject *__pyx_r = NULL; @@ -8847,14 +9705,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_12read(PyObject *__pyx_v_cls, PyObject * int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read", 0); - /* "datrie.pyx":605 + /* "datrie.pyx":628 * File-like objects without real file descriptors are not supported. * """ * cdef Trie trie = super(Trie, cls).read(f) # <<<<<<<<<<<<<< * trie._values = pickle.load(f) * return trie */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); @@ -8862,54 +9720,54 @@ static PyObject *__pyx_pf_6datrie_4Trie_12read(PyObject *__pyx_v_cls, PyObject * __Pyx_INCREF(((PyObject *)__pyx_v_cls)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_cls)); __Pyx_GIVEREF(((PyObject *)__pyx_v_cls)); - __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6datrie_Trie))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_6datrie_Trie))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_trie = ((struct __pyx_obj_6datrie_Trie *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":606 + /* "datrie.pyx":629 * """ * cdef Trie trie = super(Trie, cls).read(f) * trie._values = pickle.load(f) # <<<<<<<<<<<<<< * return trie * */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__pickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_pickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__load); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_load); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_trie->_values); - __Pyx_DECREF(((PyObject *)__pyx_v_trie->_values)); + __Pyx_DECREF(__pyx_v_trie->_values); __pyx_v_trie->_values = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":607 + /* "datrie.pyx":630 * cdef Trie trie = super(Trie, cls).read(f) * trie._values = pickle.load(f) * return trie # <<<<<<<<<<<<<< @@ -8921,8 +9779,15 @@ static PyObject *__pyx_pf_6datrie_4Trie_12read(PyObject *__pyx_v_cls, PyObject * __pyx_r = ((PyObject *)__pyx_v_trie); goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":623 + * + * @classmethod + * def read(cls, f): # <<<<<<<<<<<<<< + * """ + * Creates a new Trie by reading it from file. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -8936,7 +9801,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_12read(PyObject *__pyx_v_cls, PyObject * return __pyx_r; } -/* "datrie.pyx":610 +/* "datrie.pyx":633 * * * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -8973,18 +9838,18 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_4Trie_15items)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -8993,37 +9858,37 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":625 + /* "datrie.pyx":648 * * cdef bint success * cdef list res = [] # <<<<<<<<<<<<<< * cdef BaseState state = BaseState(self) * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_res = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":626 + /* "datrie.pyx":649 * cdef bint success * cdef list res = [] * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< * * if prefix is not None: */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":628 + /* "datrie.pyx":651 * cdef BaseState state = BaseState(self) * * if prefix is not None: # <<<<<<<<<<<<<< @@ -9034,20 +9899,20 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":629 + /* "datrie.pyx":652 * * if prefix is not None: * success = state.walk(prefix) # <<<<<<<<<<<<<< * if not success: * return res */ - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_5; - /* "datrie.pyx":630 + /* "datrie.pyx":653 * if prefix is not None: * success = state.walk(prefix) * if not success: # <<<<<<<<<<<<<< @@ -9057,7 +9922,7 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_5) { - /* "datrie.pyx":631 + /* "datrie.pyx":654 * success = state.walk(prefix) * if not success: * return res # <<<<<<<<<<<<<< @@ -9065,35 +9930,33 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py * cdef BaseIterator iter = BaseIterator(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "datrie.pyx":633 + /* "datrie.pyx":656 * return res * * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< * * if prefix is None: */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":635 + /* "datrie.pyx":658 * cdef BaseIterator iter = BaseIterator(state) * * if prefix is None: # <<<<<<<<<<<<<< @@ -9104,7 +9967,7 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "datrie.pyx":636 + /* "datrie.pyx":659 * * if prefix is None: * while iter.next(): # <<<<<<<<<<<<<< @@ -9115,23 +9978,23 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":637 + /* "datrie.pyx":660 * if prefix is None: * while iter.next(): * res.append((iter.key(), self._values[iter.data()])) # <<<<<<<<<<<<<< * else: * while iter.next(): */ - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_6 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0); - __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_t_6, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_t_6, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -9139,14 +10002,14 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __Pyx_GIVEREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } goto __pyx_L5; } /*else*/ { - /* "datrie.pyx":639 + /* "datrie.pyx":662 * res.append((iter.key(), self._values[iter.data()])) * else: * while iter.next(): # <<<<<<<<<<<<<< @@ -9157,40 +10020,40 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py __pyx_t_4 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_4) break; - /* "datrie.pyx":640 + /* "datrie.pyx":663 * else: * while iter.next(): * res.append((prefix+iter.key(), self._values[iter.data()])) # <<<<<<<<<<<<<< * * return res */ - __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_prefix), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_prefix, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_6 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0); - __pyx_t_2 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_t_6, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_t_6, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_2 = 0; - __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } __pyx_L5:; - /* "datrie.pyx":642 + /* "datrie.pyx":665 * res.append((prefix+iter.key(), self._values[iter.data()])) * * return res # <<<<<<<<<<<<<< @@ -9198,12 +10061,19 @@ static PyObject *__pyx_f_6datrie_4Trie_items(struct __pyx_obj_6datrie_Trie *__py * cpdef values(self, unicode prefix=None): */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":633 + * + * + * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's items (``(key,value)`` tuples). + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -9231,16 +10101,8 @@ static PyObject *__pyx_pw_6datrie_4Trie_15items(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("items (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__prefix,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; PyObject* values[1] = {0}; - - /* "datrie.pyx":610 - * - * - * cpdef items(self, unicode prefix=None): # <<<<<<<<<<<<<< - * """ - * Returns a list of this trie's items (``(key,value)`` tuples). - */ values[0] = ((PyObject*)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -9254,12 +10116,12 @@ static PyObject *__pyx_pw_6datrie_4Trie_15items(PyObject *__pyx_v_self, PyObject switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "items") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "items") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9272,14 +10134,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_15items(PyObject *__pyx_v_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("items", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("items", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.items", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_14items(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -9300,14 +10164,13 @@ static PyObject *__pyx_pf_6datrie_4Trie_14items(struct __pyx_obj_6datrie_Trie *_ __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.prefix = __pyx_v_prefix; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.Trie.items", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -9318,7 +10181,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_14items(struct __pyx_obj_6datrie_Trie *_ return __pyx_r; } -/* "datrie.pyx":644 +/* "datrie.pyx":667 * return res * * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< @@ -9355,18 +10218,18 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_4Trie_17values)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_prefix)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_prefix)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix); + __Pyx_GIVEREF(__pyx_v_prefix); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -9375,37 +10238,37 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":658 + /* "datrie.pyx":681 * # but inlined for speed. * * cdef list res = [] # <<<<<<<<<<<<<< * cdef BaseState state = BaseState(self) * cdef bint success */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_res = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":659 + /* "datrie.pyx":682 * * cdef list res = [] * cdef BaseState state = BaseState(self) # <<<<<<<<<<<<<< * cdef bint success * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseState)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_state = ((struct __pyx_obj_6datrie_BaseState *)__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":662 + /* "datrie.pyx":685 * cdef bint success * * if prefix is not None: # <<<<<<<<<<<<<< @@ -9416,20 +10279,20 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":663 + /* "datrie.pyx":686 * * if prefix is not None: * success = state.walk(prefix) # <<<<<<<<<<<<<< * if not success: * return res */ - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_state->__pyx_base.__pyx_vtab)->__pyx_base.walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state), __pyx_v_prefix, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_success = __pyx_t_5; - /* "datrie.pyx":664 + /* "datrie.pyx":687 * if prefix is not None: * success = state.walk(prefix) * if not success: # <<<<<<<<<<<<<< @@ -9439,7 +10302,7 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p __pyx_t_5 = ((!(__pyx_v_success != 0)) != 0); if (__pyx_t_5) { - /* "datrie.pyx":665 + /* "datrie.pyx":688 * success = state.walk(prefix) * if not success: * return res # <<<<<<<<<<<<<< @@ -9447,35 +10310,33 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p * cdef BaseIterator iter = BaseIterator(state) */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - goto __pyx_L4; } - __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "datrie.pyx":667 + /* "datrie.pyx":690 * return res * * cdef BaseIterator iter = BaseIterator(state) # <<<<<<<<<<<<<< * * while iter.next(): */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_BaseIterator)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_iter = ((struct __pyx_obj_6datrie_BaseIterator *)__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":669 + /* "datrie.pyx":692 * cdef BaseIterator iter = BaseIterator(state) * * while iter.next(): # <<<<<<<<<<<<<< @@ -9486,25 +10347,25 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p __pyx_t_5 = (((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->__pyx_base.next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_iter), 0) != 0); if (!__pyx_t_5) break; - /* "datrie.pyx":670 + /* "datrie.pyx":693 * * while iter.next(): * res.append(self._values[iter.data()]) # <<<<<<<<<<<<<< * * return res */ - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_6 = ((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_iter->__pyx_base.__pyx_vtab)->data(__pyx_v_iter, 0); - __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_t_6, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_t_6, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_res, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":672 + /* "datrie.pyx":695 * res.append(self._values[iter.data()]) * * return res # <<<<<<<<<<<<<< @@ -9512,12 +10373,19 @@ static PyObject *__pyx_f_6datrie_4Trie_values(struct __pyx_obj_6datrie_Trie *__p * */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_res)); - __pyx_r = ((PyObject *)__pyx_v_res); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":667 + * return res + * + * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< + * """ + * Returns a list of this trie's values. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -9545,16 +10413,8 @@ static PyObject *__pyx_pw_6datrie_4Trie_17values(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("values (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__prefix,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_prefix,0}; PyObject* values[1] = {0}; - - /* "datrie.pyx":644 - * return res - * - * cpdef values(self, unicode prefix=None): # <<<<<<<<<<<<<< - * """ - * Returns a list of this trie's values. - */ values[0] = ((PyObject*)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -9568,12 +10428,12 @@ static PyObject *__pyx_pw_6datrie_4Trie_17values(PyObject *__pyx_v_self, PyObjec switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prefix); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "values") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "values") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9586,14 +10446,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_17values(PyObject *__pyx_v_self, PyObjec } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("values", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("values", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.values", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyUnicode_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_16values(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_prefix); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -9614,14 +10476,13 @@ static PyObject *__pyx_pf_6datrie_4Trie_16values(struct __pyx_obj_6datrie_Trie * __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.prefix = __pyx_v_prefix; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.Trie.values", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -9632,6 +10493,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_16values(struct __pyx_obj_6datrie_Trie * return __pyx_r; } +/* "datrie.pyx":698 + * + * + * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the item (``(key,value)`` tuple) associated with the longest + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_19longest_prefix_item(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6datrie_4Trie_18longest_prefix_item[] = "\n Returns the item (``(key,value)`` tuple) associated with the longest\n key in this trie that is a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, returns it,\n - otherwise raises ``KeyError``.\n "; @@ -9645,9 +10514,9 @@ static PyObject *__pyx_pw_6datrie_4Trie_19longest_prefix_item(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("longest_prefix_item (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__default,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; - values[1] = __pyx_k_16; + values[1] = __pyx_k__13; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -9660,16 +10529,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_19longest_prefix_item(PyObject *__pyx_v_ kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_item") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_item") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9684,14 +10553,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_19longest_prefix_item(PyObject *__pyx_v_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("longest_prefix_item", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("longest_prefix_item", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.longest_prefix_item", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_18longest_prefix_item(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -9700,14 +10571,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_19longest_prefix_item(PyObject *__pyx_v_ return __pyx_r; } -/* "datrie.pyx":675 - * - * - * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< - * """ - * Returns the item (``(key,value)`` tuple) associated with the longest - */ - static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { PyObject *__pyx_v_res = 0; PyObject *__pyx_r = NULL; @@ -9723,74 +10586,72 @@ static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("longest_prefix_item", 0); - /* "datrie.pyx":684 + /* "datrie.pyx":707 * - otherwise raises ``KeyError``. * """ * cdef res = self._longest_prefix_item(key, RERAISE_KEY_ERROR) # <<<<<<<<<<<<<< * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3.__pyx_n = 1; __pyx_t_3.__pyx_default = __pyx_t_1; - __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._longest_prefix_item(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._longest_prefix_item(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_res = __pyx_t_2; __pyx_t_2 = 0; - /* "datrie.pyx":685 + /* "datrie.pyx":708 * """ * cdef res = self._longest_prefix_item(key, RERAISE_KEY_ERROR) * if res is RERAISE_KEY_ERROR: # error # <<<<<<<<<<<<<< * if default is RAISE_KEY_ERROR: * raise KeyError(key) */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__pyx_v_res == __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":686 + /* "datrie.pyx":709 * cdef res = self._longest_prefix_item(key, RERAISE_KEY_ERROR) * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: # <<<<<<<<<<<<<< * raise KeyError(key) * return default */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = (__pyx_v_default == __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "datrie.pyx":687 + /* "datrie.pyx":710 * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: * raise KeyError(key) # <<<<<<<<<<<<<< * return default * */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L4:; - /* "datrie.pyx":688 + /* "datrie.pyx":711 * if default is RAISE_KEY_ERROR: * raise KeyError(key) * return default # <<<<<<<<<<<<<< @@ -9801,11 +10662,9 @@ static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6 __Pyx_INCREF(__pyx_v_default); __pyx_r = __pyx_v_default; goto __pyx_L0; - goto __pyx_L3; } - __pyx_L3:; - /* "datrie.pyx":690 + /* "datrie.pyx":713 * return default * * return res[0], self._values[res[1]] # <<<<<<<<<<<<<< @@ -9813,18 +10672,18 @@ static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6 * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_res, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_res, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_res, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_res, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_self->_values), __pyx_t_2); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetItem(__pyx_v_self->_values, __pyx_t_2); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -9832,12 +10691,19 @@ static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6 __Pyx_GIVEREF(__pyx_t_6); __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":698 + * + * + * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the item (``(key,value)`` tuple) associated with the longest + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -9851,6 +10717,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_18longest_prefix_item(struct __pyx_obj_6 return __pyx_r; } +/* "datrie.pyx":715 + * return res[0], self._values[res[1]] + * + * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the value associated with the longest key in this trie that is + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_21longest_prefix_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6datrie_4Trie_20longest_prefix_value[] = "\n Returns the value associated with the longest key in this trie that is\n a prefix of ``key``.\n\n If the trie doesn't contain any prefix of ``key``:\n - if ``default`` is given, return it\n - otherwise raise ``KeyError``\n "; @@ -9864,9 +10738,9 @@ static PyObject *__pyx_pw_6datrie_4Trie_21longest_prefix_value(PyObject *__pyx_v __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("longest_prefix_value (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__default,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_key,&__pyx_n_s_default,0}; PyObject* values[2] = {0,0}; - values[1] = __pyx_k_17; + values[1] = __pyx_k__14; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -9879,16 +10753,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_21longest_prefix_value(PyObject *__pyx_v kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "longest_prefix_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9903,14 +10777,16 @@ static PyObject *__pyx_pw_6datrie_4Trie_21longest_prefix_value(PyObject *__pyx_v } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("longest_prefix_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("longest_prefix_value", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Trie.longest_prefix_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_20longest_prefix_value(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), __pyx_v_key, __pyx_v_default); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -9919,14 +10795,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_21longest_prefix_value(PyObject *__pyx_v return __pyx_r; } -/* "datrie.pyx":692 - * return res[0], self._values[res[1]] - * - * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< - * """ - * Returns the value associated with the longest key in this trie that is - */ - static PyObject *__pyx_pf_6datrie_4Trie_20longest_prefix_value(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_default) { PyObject *__pyx_v_res = 0; PyObject *__pyx_r = NULL; @@ -9941,74 +10809,72 @@ static PyObject *__pyx_pf_6datrie_4Trie_20longest_prefix_value(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("longest_prefix_value", 0); - /* "datrie.pyx":701 + /* "datrie.pyx":724 * - otherwise raise ``KeyError`` * """ * cdef res = self._longest_prefix_value(key, RERAISE_KEY_ERROR) # <<<<<<<<<<<<<< * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3.__pyx_n = 1; __pyx_t_3.__pyx_default = __pyx_t_1; - __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._longest_prefix_value(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._longest_prefix_value(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_res = __pyx_t_2; __pyx_t_2 = 0; - /* "datrie.pyx":702 + /* "datrie.pyx":725 * """ * cdef res = self._longest_prefix_value(key, RERAISE_KEY_ERROR) * if res is RERAISE_KEY_ERROR: # error # <<<<<<<<<<<<<< * if default is RAISE_KEY_ERROR: * raise KeyError(key) */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_RERAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__pyx_v_res == __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "datrie.pyx":703 + /* "datrie.pyx":726 * cdef res = self._longest_prefix_value(key, RERAISE_KEY_ERROR) * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: # <<<<<<<<<<<<<< * raise KeyError(key) * return default */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = (__pyx_v_default == __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "datrie.pyx":704 + /* "datrie.pyx":727 * if res is RERAISE_KEY_ERROR: # error * if default is RAISE_KEY_ERROR: * raise KeyError(key) # <<<<<<<<<<<<<< * return default * */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_key)); - __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key); + __Pyx_GIVEREF(__pyx_v_key); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L4:; - /* "datrie.pyx":705 + /* "datrie.pyx":728 * if default is RAISE_KEY_ERROR: * raise KeyError(key) * return default # <<<<<<<<<<<<<< @@ -10019,11 +10885,9 @@ static PyObject *__pyx_pf_6datrie_4Trie_20longest_prefix_value(struct __pyx_obj_ __Pyx_INCREF(__pyx_v_default); __pyx_r = __pyx_v_default; goto __pyx_L0; - goto __pyx_L3; } - __pyx_L3:; - /* "datrie.pyx":707 + /* "datrie.pyx":730 * return default * * return self._values[res] # <<<<<<<<<<<<<< @@ -10031,18 +10895,25 @@ static PyObject *__pyx_pf_6datrie_4Trie_20longest_prefix_value(struct __pyx_obj_ * def prefix_items(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->_values), __pyx_v_res); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetItem(__pyx_v_self->_values, __pyx_v_res); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":715 + * return res[0], self._values[res[1]] + * + * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< + * """ + * Returns the value associated with the longest key in this trie that is + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -10055,6 +10926,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_20longest_prefix_value(struct __pyx_obj_ return __pyx_r; } +/* "datrie.pyx":732 + * return self._values[res] + * + * def prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the items (``(key,value)`` tuples) + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_23prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_4Trie_22prefix_items[] = "\n Returns a list of the items (``(key,value)`` tuples)\n of this trie that are associated with keys that are\n prefixes of ``key``.\n "; @@ -10065,8 +10944,10 @@ static PyObject *__pyx_pw_6datrie_4Trie_23prefix_items(PyObject *__pyx_v_self, P PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("prefix_items (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_22prefix_items(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -10075,14 +10956,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_23prefix_items(PyObject *__pyx_v_self, P return __pyx_r; } -/* "datrie.pyx":709 - * return self._values[res] - * - * def prefix_items(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns a list of the items (``(key,value)`` tuples) - */ - static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_v_k = NULL; PyObject *__pyx_v_v = NULL; @@ -10101,7 +10974,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prefix_items", 0); - /* "datrie.pyx":715 + /* "datrie.pyx":738 * prefixes of ``key``. * ''' * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] # <<<<<<<<<<<<<< @@ -10109,22 +10982,22 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ * def iter_prefix_items(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._prefix_items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._prefix_items(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (unlikely(__pyx_t_2 == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; @@ -10136,7 +11009,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -10149,16 +11022,15 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - { + } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -10166,7 +11038,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; @@ -10174,22 +11046,20 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __Pyx_XDECREF(__pyx_v_k); - __pyx_v_k = __pyx_t_5; + __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF(__pyx_v_v); - __pyx_v_v = __pyx_t_6; + __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6); __pyx_t_6 = 0; - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->_values), __pyx_v_v); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetItem(__pyx_v_self->_values, __pyx_v_v); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_k); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_k); @@ -10197,16 +11067,23 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":732 + * return self._values[res] + * + * def prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the items (``(key,value)`` tuples) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -10225,6 +11102,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_22prefix_items(struct __pyx_obj_6datrie_ } static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":740 + * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] + * + * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * for k, v in super(Trie, self).iter_prefix_items(key): + * yield k, self._values[v] + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_25iter_prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static PyObject *__pyx_pw_6datrie_4Trie_25iter_prefix_items(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -10234,8 +11119,10 @@ static PyObject *__pyx_pw_6datrie_4Trie_25iter_prefix_items(PyObject *__pyx_v_se PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("iter_prefix_items (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_24iter_prefix_items(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -10244,14 +11131,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_25iter_prefix_items(PyObject *__pyx_v_se return __pyx_r; } -/* "datrie.pyx":717 - * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] - * - * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< - * for k, v in super(Trie, self).iter_prefix_items(key): - * yield k, self._values[v] - */ - static PyObject *__pyx_pf_6datrie_4Trie_24iter_prefix_items(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -10273,12 +11152,13 @@ static PyObject *__pyx_pf_6datrie_4Trie_24iter_prefix_items(struct __pyx_obj_6da __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_4Trie_26generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_4Trie_26generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -10316,16 +11196,16 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":718 + /* "datrie.pyx":741 * * def iter_prefix_items(self, unicode key): * for k, v in super(Trie, self).iter_prefix_items(key): # <<<<<<<<<<<<<< * yield k, self._values[v] * */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); @@ -10333,26 +11213,26 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self)); - __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__iter_prefix_items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iter_prefix_items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_key); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -10361,23 +11241,24 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -10393,7 +11274,7 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -10406,16 +11287,15 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - { + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -10423,7 +11303,7 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; @@ -10431,34 +11311,32 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_k); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); - __pyx_cur_scope->__pyx_v_k = __pyx_t_1; __pyx_t_1 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_v); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); - __pyx_cur_scope->__pyx_v_v = __pyx_t_6; __pyx_t_6 = 0; - /* "datrie.pyx":719 + /* "datrie.pyx":742 * def iter_prefix_items(self, unicode key): * for k, v in super(Trie, self).iter_prefix_items(key): * yield k, self._values[v] # <<<<<<<<<<<<<< * * def prefix_values(self, unicode key): */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self->_values), __pyx_cur_scope->__pyx_v_v); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_self->_values, __pyx_cur_scope->__pyx_v_v); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_k); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_k); @@ -10466,7 +11344,7 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = ((PyObject *)__pyx_t_6); + __pyx_r = __pyx_t_6; __pyx_t_6 = 0; __Pyx_XGIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; @@ -10483,9 +11361,19 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py __Pyx_XGOTREF(__pyx_t_2); __pyx_t_4 = __pyx_cur_scope->__pyx_t_1; __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "datrie.pyx":740 + * return [(k, self._values[v]) for (k, v) in self._prefix_items(key)] + * + * def iter_prefix_items(self, unicode key): # <<<<<<<<<<<<<< + * for k, v in super(Trie, self).iter_prefix_items(key): + * yield k, self._values[v] + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -10503,6 +11391,14 @@ static PyObject *__pyx_gb_6datrie_4Trie_26generator3(__pyx_GeneratorObject *__py return NULL; } +/* "datrie.pyx":744 + * yield k, self._values[v] + * + * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the values of this trie that are associated + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_28prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static char __pyx_doc_6datrie_4Trie_27prefix_values[] = "\n Returns a list of the values of this trie that are associated\n with keys that are prefixes of ``key``.\n "; @@ -10513,8 +11409,10 @@ static PyObject *__pyx_pw_6datrie_4Trie_28prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("prefix_values (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_27prefix_values(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -10523,14 +11421,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_28prefix_values(PyObject *__pyx_v_self, return __pyx_r; } -/* "datrie.pyx":721 - * yield k, self._values[v] - * - * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * ''' - * Returns a list of the values of this trie that are associated - */ - static PyObject *__pyx_pf_6datrie_4Trie_27prefix_values(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { PyObject *__pyx_v_v = NULL; PyObject *__pyx_r = NULL; @@ -10544,7 +11434,7 @@ static PyObject *__pyx_pf_6datrie_4Trie_27prefix_values(struct __pyx_obj_6datrie int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prefix_values", 0); - /* "datrie.pyx":726 + /* "datrie.pyx":749 * with keys that are prefixes of ``key``. * ''' * return [self._values[v] for v in self._prefix_values(key)] # <<<<<<<<<<<<<< @@ -10552,42 +11442,48 @@ static PyObject *__pyx_pf_6datrie_4Trie_27prefix_values(struct __pyx_obj_6datrie * def iter_prefix_values(self, unicode key): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._prefix_values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_6datrie_Trie *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._prefix_values(((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_self), __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); if (unlikely(__pyx_t_2 == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - __Pyx_XDECREF(__pyx_v_v); - __pyx_v_v = __pyx_t_2; + __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2); __pyx_t_2 = 0; - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->_values), __pyx_v_v); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetItem(__pyx_v_self->_values, __pyx_v_v); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":744 + * yield k, self._values[v] + * + * def prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * ''' + * Returns a list of the values of this trie that are associated + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -10602,6 +11498,14 @@ static PyObject *__pyx_pf_6datrie_4Trie_27prefix_values(struct __pyx_obj_6datrie } static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":751 + * return [self._values[v] for v in self._prefix_values(key)] + * + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * for v in super(Trie, self).iter_prefix_values(key): + * yield self._values[v] + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4Trie_30iter_prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/ static PyObject *__pyx_pw_6datrie_4Trie_30iter_prefix_values(PyObject *__pyx_v_self, PyObject *__pyx_v_key) { @@ -10611,8 +11515,10 @@ static PyObject *__pyx_pw_6datrie_4Trie_30iter_prefix_values(PyObject *__pyx_v_s PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("iter_prefix_values (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_4Trie_29iter_prefix_values(((struct __pyx_obj_6datrie_Trie *)__pyx_v_self), ((PyObject*)__pyx_v_key)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -10621,14 +11527,6 @@ static PyObject *__pyx_pw_6datrie_4Trie_30iter_prefix_values(PyObject *__pyx_v_s return __pyx_r; } -/* "datrie.pyx":728 - * return [self._values[v] for v in self._prefix_values(key)] - * - * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< - * for v in super(Trie, self).iter_prefix_values(key): - * yield self._values[v] - */ - static PyObject *__pyx_pf_6datrie_4Trie_29iter_prefix_values(struct __pyx_obj_6datrie_Trie *__pyx_v_self, PyObject *__pyx_v_key) { struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -10650,12 +11548,13 @@ static PyObject *__pyx_pf_6datrie_4Trie_29iter_prefix_values(struct __pyx_obj_6d __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_4Trie_31generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_4Trie_31generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -10690,16 +11589,16 @@ static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__py return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":729 + /* "datrie.pyx":752 * * def iter_prefix_values(self, unicode key): * for v in super(Trie, self).iter_prefix_values(key): # <<<<<<<<<<<<<< * yield self._values[v] * */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie))); @@ -10707,26 +11606,26 @@ static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__py __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self)); - __pyx_t_2 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__iter_prefix_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_iter_prefix_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_key); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -10735,46 +11634,46 @@ static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__py if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_v); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_v = __pyx_t_3; __pyx_t_3 = 0; - /* "datrie.pyx":730 + /* "datrie.pyx":753 * def iter_prefix_values(self, unicode key): * for v in super(Trie, self).iter_prefix_values(key): * yield self._values[v] # <<<<<<<<<<<<<< * * cdef _index_to_value(self, cdatrie.TrieData index): */ - if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_cur_scope->__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self->_values), __pyx_cur_scope->__pyx_v_v); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_self->_values, __pyx_cur_scope->__pyx_v_v); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -10793,9 +11692,19 @@ static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__py __Pyx_XGOTREF(__pyx_t_2); __pyx_t_4 = __pyx_cur_scope->__pyx_t_1; __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "datrie.pyx":751 + * return [self._values[v] for v in self._prefix_values(key)] + * + * def iter_prefix_values(self, unicode key): # <<<<<<<<<<<<<< + * for v in super(Trie, self).iter_prefix_values(key): + * yield self._values[v] + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -10811,7 +11720,7 @@ static PyObject *__pyx_gb_6datrie_4Trie_31generator4(__pyx_GeneratorObject *__py return NULL; } -/* "datrie.pyx":732 +/* "datrie.pyx":755 * yield self._values[v] * * cdef _index_to_value(self, cdatrie.TrieData index): # <<<<<<<<<<<<<< @@ -10828,7 +11737,7 @@ static PyObject *__pyx_f_6datrie_4Trie__index_to_value(struct __pyx_obj_6datrie_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_index_to_value", 0); - /* "datrie.pyx":733 + /* "datrie.pyx":756 * * cdef _index_to_value(self, cdatrie.TrieData index): * return self._values[index] # <<<<<<<<<<<<<< @@ -10836,18 +11745,25 @@ static PyObject *__pyx_f_6datrie_4Trie__index_to_value(struct __pyx_obj_6datrie_ * */ __Pyx_XDECREF(__pyx_r); - if (unlikely(((PyObject *)__pyx_v_self->_values) == Py_None)) { + if (unlikely(__pyx_v_self->_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->_values), __pyx_v_index, sizeof(TrieData), __Pyx_PyInt_to_py_TrieData, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_values, __pyx_v_index, TrieData, 1, __Pyx_PyInt_From_TrieData, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":755 + * yield self._values[v] + * + * cdef _index_to_value(self, cdatrie.TrieData index): # <<<<<<<<<<<<<< + * return self._values[index] + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.Trie._index_to_value", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -10858,6 +11774,14 @@ static PyObject *__pyx_f_6datrie_4Trie__index_to_value(struct __pyx_obj_6datrie_ return __pyx_r; } +/* "datrie.pyx":763 + * cdef BaseTrie _trie + * + * def __cinit__(self, BaseTrie trie): # <<<<<<<<<<<<<< + * self._state = cdatrie.trie_root(trie._c_trie) + * if self._state is NULL: + */ + /* Python wrapper */ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -10869,7 +11793,7 @@ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__trie,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_trie,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -10882,11 +11806,11 @@ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyOb kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trie)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trie)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -10897,14 +11821,16 @@ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie._TrieState.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trie), __pyx_ptype_6datrie_BaseTrie, 1, "trie", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trie), __pyx_ptype_6datrie_BaseTrie, 1, "trie", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_10_TrieState___cinit__(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self), __pyx_v_trie); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -10913,14 +11839,6 @@ static int __pyx_pw_6datrie_10_TrieState_1__cinit__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "datrie.pyx":740 - * cdef BaseTrie _trie - * - * def __cinit__(self, BaseTrie trie): # <<<<<<<<<<<<<< - * self._state = cdatrie.trie_root(trie._c_trie) - * if self._state is NULL: - */ - static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__TrieState *__pyx_v_self, struct __pyx_obj_6datrie_BaseTrie *__pyx_v_trie) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -10930,7 +11848,7 @@ static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__Tri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "datrie.pyx":741 + /* "datrie.pyx":764 * * def __cinit__(self, BaseTrie trie): * self._state = cdatrie.trie_root(trie._c_trie) # <<<<<<<<<<<<<< @@ -10939,7 +11857,7 @@ static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__Tri */ __pyx_v_self->_state = trie_root(__pyx_v_trie->_c_trie); - /* "datrie.pyx":742 + /* "datrie.pyx":765 * def __cinit__(self, BaseTrie trie): * self._state = cdatrie.trie_root(trie._c_trie) * if self._state is NULL: # <<<<<<<<<<<<<< @@ -10949,19 +11867,17 @@ static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__Tri __pyx_t_1 = ((__pyx_v_self->_state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":743 + /* "datrie.pyx":766 * self._state = cdatrie.trie_root(trie._c_trie) * if self._state is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * self._trie = trie * */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":744 + /* "datrie.pyx":767 * if self._state is NULL: * raise MemoryError() * self._trie = trie # <<<<<<<<<<<<<< @@ -10974,6 +11890,15 @@ static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__Tri __Pyx_DECREF(((PyObject *)__pyx_v_self->_trie)); __pyx_v_self->_trie = __pyx_v_trie; + /* "datrie.pyx":763 + * cdef BaseTrie _trie + * + * def __cinit__(self, BaseTrie trie): # <<<<<<<<<<<<<< + * self._state = cdatrie.trie_root(trie._c_trie) + * if self._state is NULL: + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -10984,29 +11909,31 @@ static int __pyx_pf_6datrie_10_TrieState___cinit__(struct __pyx_obj_6datrie__Tri return __pyx_r; } +/* "datrie.pyx":769 + * self._trie = trie + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._state is not NULL: + * cdatrie.trie_state_free(self._state) + */ + /* Python wrapper */ static void __pyx_pw_6datrie_10_TrieState_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6datrie_10_TrieState_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6datrie_10_TrieState_2__dealloc__(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":746 - * self._trie = trie - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._state is not NULL: - * cdatrie.trie_state_free(self._state) - */ - static void __pyx_pf_6datrie_10_TrieState_2__dealloc__(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "datrie.pyx":747 + /* "datrie.pyx":770 * * def __dealloc__(self): * if self._state is not NULL: # <<<<<<<<<<<<<< @@ -11016,7 +11943,7 @@ static void __pyx_pf_6datrie_10_TrieState_2__dealloc__(struct __pyx_obj_6datrie_ __pyx_t_1 = ((__pyx_v_self->_state != NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":748 + /* "datrie.pyx":771 * def __dealloc__(self): * if self._state is not NULL: * cdatrie.trie_state_free(self._state) # <<<<<<<<<<<<<< @@ -11028,10 +11955,19 @@ static void __pyx_pf_6datrie_10_TrieState_2__dealloc__(struct __pyx_obj_6datrie_ } __pyx_L3:; + /* "datrie.pyx":769 + * self._trie = trie + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._state is not NULL: + * cdatrie.trie_state_free(self._state) + */ + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":750 +/* "datrie.pyx":773 * cdatrie.trie_state_free(self._state) * * cpdef walk(self, unicode to): # <<<<<<<<<<<<<< @@ -11063,18 +11999,18 @@ static PyObject *__pyx_f_6datrie_10_TrieState_walk(struct __pyx_obj_6datrie__Tri if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__walk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_walk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_5walk)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_to)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_to)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_to)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_to); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_to); + __Pyx_GIVEREF(__pyx_v_to); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -11083,25 +12019,25 @@ static PyObject *__pyx_f_6datrie_10_TrieState_walk(struct __pyx_obj_6datrie__Tri __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":752 + /* "datrie.pyx":775 * cpdef walk(self, unicode to): * cdef bint res * for ch in to: # <<<<<<<<<<<<<< * if not self.walk_char( ch): * return False */ - if (unlikely(((PyObject *)__pyx_v_to) == Py_None)) { + if (unlikely(__pyx_v_to == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_to)); + __Pyx_INCREF(__pyx_v_to); __pyx_t_4 = __pyx_v_to; - __pyx_t_9 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_4), (&__pyx_t_6), (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_init_unicode_iteration(__pyx_t_4, (&__pyx_t_6), (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_6; __pyx_t_10++) { __pyx_t_5 = __pyx_t_10; __pyx_v_ch = __Pyx_PyUnicode_READ(__pyx_t_8, __pyx_t_7, __pyx_t_5); - /* "datrie.pyx":753 + /* "datrie.pyx":776 * cdef bint res * for ch in to: * if not self.walk_char( ch): # <<<<<<<<<<<<<< @@ -11111,7 +12047,7 @@ static PyObject *__pyx_f_6datrie_10_TrieState_walk(struct __pyx_obj_6datrie__Tri __pyx_t_11 = ((!(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->walk_char(__pyx_v_self, ((AlphaChar)__pyx_v_ch)) != 0)) != 0); if (__pyx_t_11) { - /* "datrie.pyx":754 + /* "datrie.pyx":777 * for ch in to: * if not self.walk_char( ch): * return False # <<<<<<<<<<<<<< @@ -11119,19 +12055,15 @@ static PyObject *__pyx_f_6datrie_10_TrieState_walk(struct __pyx_obj_6datrie__Tri * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_INCREF(Py_False); + __pyx_r = Py_False; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0; - goto __pyx_L5; } - __pyx_L5:; } - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "datrie.pyx":755 + /* "datrie.pyx":778 * if not self.walk_char( ch): * return False * return True # <<<<<<<<<<<<<< @@ -11139,19 +12071,24 @@ static PyObject *__pyx_f_6datrie_10_TrieState_walk(struct __pyx_obj_6datrie__Tri * cdef bint walk_char(self, cdatrie.AlphaChar char): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_INCREF(Py_True); + __pyx_r = Py_True; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":773 + * cdatrie.trie_state_free(self._state) + * + * cpdef walk(self, unicode to): # <<<<<<<<<<<<<< + * cdef bint res + * for ch in to: + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(((PyObject *)__pyx_t_4)); + __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("datrie._TrieState.walk", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -11169,8 +12106,10 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_5walk(PyObject *__pyx_v_self, PyO PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("walk (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_to), (&PyUnicode_Type), 1, "to", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_to), (&PyUnicode_Type), 1, "to", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_10_TrieState_4walk(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self), ((PyObject*)__pyx_v_to)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -11179,14 +12118,6 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_5walk(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "datrie.pyx":750 - * cdatrie.trie_state_free(self._state) - * - * cpdef walk(self, unicode to): # <<<<<<<<<<<<<< - * cdef bint res - * for ch in to: - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_4walk(struct __pyx_obj_6datrie__TrieState *__pyx_v_self, PyObject *__pyx_v_to) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11196,14 +12127,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_4walk(struct __pyx_obj_6datrie__T int __pyx_clineno = 0; __Pyx_RefNannySetupContext("walk", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->walk(__pyx_v_self, __pyx_v_to, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->walk(__pyx_v_self, __pyx_v_to, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.walk", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11214,7 +12144,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_4walk(struct __pyx_obj_6datrie__T return __pyx_r; } -/* "datrie.pyx":757 +/* "datrie.pyx":780 * return True * * cdef bint walk_char(self, cdatrie.AlphaChar char): # <<<<<<<<<<<<<< @@ -11227,7 +12157,7 @@ static int __pyx_f_6datrie_10_TrieState_walk_char(struct __pyx_obj_6datrie__Trie __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("walk_char", 0); - /* "datrie.pyx":763 + /* "datrie.pyx":786 * Returns boolean value indicating the success of the walk. * """ * return cdatrie.trie_state_walk(self._state, char) # <<<<<<<<<<<<<< @@ -11237,13 +12167,21 @@ static int __pyx_f_6datrie_10_TrieState_walk_char(struct __pyx_obj_6datrie__Trie __pyx_r = trie_state_walk(__pyx_v_self->_state, __pyx_v_char); goto __pyx_L0; - __pyx_r = 0; + /* "datrie.pyx":780 + * return True + * + * cdef bint walk_char(self, cdatrie.AlphaChar char): # <<<<<<<<<<<<<< + * """ + * Walks the trie stepwise, using a given character ``char``. + */ + + /* function exit code */ __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":765 +/* "datrie.pyx":788 * return cdatrie.trie_state_walk(self._state, char) * * cpdef copy_to(self, _TrieState state): # <<<<<<<<<<<<<< @@ -11266,18 +12204,18 @@ static PyObject *__pyx_f_6datrie_10_TrieState_copy_to(struct __pyx_obj_6datrie__ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__copy_to); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy_to); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_7copy_to)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_state)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_state)); __Pyx_GIVEREF(((PyObject *)__pyx_v_state)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -11286,7 +12224,7 @@ static PyObject *__pyx_f_6datrie_10_TrieState_copy_to(struct __pyx_obj_6datrie__ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":767 + /* "datrie.pyx":790 * cpdef copy_to(self, _TrieState state): * """ Copies trie state to another """ * cdatrie.trie_state_copy(state._state, self._state) # <<<<<<<<<<<<<< @@ -11295,6 +12233,15 @@ static PyObject *__pyx_f_6datrie_10_TrieState_copy_to(struct __pyx_obj_6datrie__ */ trie_state_copy(__pyx_v_state->_state, __pyx_v_self->_state); + /* "datrie.pyx":788 + * return cdatrie.trie_state_walk(self._state, char) + * + * cpdef copy_to(self, _TrieState state): # <<<<<<<<<<<<<< + * """ Copies trie state to another """ + * cdatrie.trie_state_copy(state._state, self._state) + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -11319,8 +12266,10 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_7copy_to(PyObject *__pyx_v_self, PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("copy_to (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie__TrieState, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie__TrieState, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_10_TrieState_6copy_to(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self), ((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state)); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -11329,14 +12278,6 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_7copy_to(PyObject *__pyx_v_self, return __pyx_r; } -/* "datrie.pyx":765 - * return cdatrie.trie_state_walk(self._state, char) - * - * cpdef copy_to(self, _TrieState state): # <<<<<<<<<<<<<< - * """ Copies trie state to another """ - * cdatrie.trie_state_copy(state._state, self._state) - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_6copy_to(struct __pyx_obj_6datrie__TrieState *__pyx_v_self, struct __pyx_obj_6datrie__TrieState *__pyx_v_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11346,14 +12287,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_6copy_to(struct __pyx_obj_6datrie int __pyx_clineno = 0; __Pyx_RefNannySetupContext("copy_to", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->copy_to(__pyx_v_self, __pyx_v_state, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->copy_to(__pyx_v_self, __pyx_v_state, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.copy_to", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11364,7 +12304,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_6copy_to(struct __pyx_obj_6datrie return __pyx_r; } -/* "datrie.pyx":769 +/* "datrie.pyx":792 * cdatrie.trie_state_copy(state._state, self._state) * * cpdef rewind(self): # <<<<<<<<<<<<<< @@ -11386,11 +12326,11 @@ static PyObject *__pyx_f_6datrie_10_TrieState_rewind(struct __pyx_obj_6datrie__T if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__rewind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_rewind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_9rewind)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -11400,7 +12340,7 @@ static PyObject *__pyx_f_6datrie_10_TrieState_rewind(struct __pyx_obj_6datrie__T __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":771 + /* "datrie.pyx":794 * cpdef rewind(self): * """ Puts the state at root """ * cdatrie.trie_state_rewind(self._state) # <<<<<<<<<<<<<< @@ -11409,6 +12349,15 @@ static PyObject *__pyx_f_6datrie_10_TrieState_rewind(struct __pyx_obj_6datrie__T */ trie_state_rewind(__pyx_v_self->_state); + /* "datrie.pyx":792 + * cdatrie.trie_state_copy(state._state, self._state) + * + * cpdef rewind(self): # <<<<<<<<<<<<<< + * """ Puts the state at root """ + * cdatrie.trie_state_rewind(self._state) + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -11430,18 +12379,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_9rewind(PyObject *__pyx_v_self, C __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rewind (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_8rewind(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":769 - * cdatrie.trie_state_copy(state._state, self._state) - * - * cpdef rewind(self): # <<<<<<<<<<<<<< - * """ Puts the state at root """ - * cdatrie.trie_state_rewind(self._state) - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_8rewind(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11451,14 +12394,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_8rewind(struct __pyx_obj_6datrie_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("rewind", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->rewind(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->rewind(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.rewind", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11469,7 +12411,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_8rewind(struct __pyx_obj_6datrie_ return __pyx_r; } -/* "datrie.pyx":773 +/* "datrie.pyx":796 * cdatrie.trie_state_rewind(self._state) * * cpdef bint is_terminal(self): # <<<<<<<<<<<<<< @@ -11492,12 +12434,12 @@ static int __pyx_f_6datrie_10_TrieState_is_terminal(struct __pyx_obj_6datrie__Tr if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_terminal); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_terminal); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_11is_terminal)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -11506,7 +12448,7 @@ static int __pyx_f_6datrie_10_TrieState_is_terminal(struct __pyx_obj_6datrie__Tr __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":774 + /* "datrie.pyx":797 * * cpdef bint is_terminal(self): * return cdatrie.trie_state_is_terminal(self._state) # <<<<<<<<<<<<<< @@ -11516,12 +12458,19 @@ static int __pyx_f_6datrie_10_TrieState_is_terminal(struct __pyx_obj_6datrie__Tr __pyx_r = trie_state_is_terminal(__pyx_v_self->_state); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":796 + * cdatrie.trie_state_rewind(self._state) + * + * cpdef bint is_terminal(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_state_is_terminal(self._state) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie._TrieState.is_terminal", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie._TrieState.is_terminal", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -11535,18 +12484,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_11is_terminal(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_terminal (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_10is_terminal(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":773 - * cdatrie.trie_state_rewind(self._state) - * - * cpdef bint is_terminal(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_state_is_terminal(self._state) - * - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_10is_terminal(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11556,14 +12499,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_10is_terminal(struct __pyx_obj_6d int __pyx_clineno = 0; __Pyx_RefNannySetupContext("is_terminal", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_terminal(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_terminal(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.is_terminal", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11574,7 +12516,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_10is_terminal(struct __pyx_obj_6d return __pyx_r; } -/* "datrie.pyx":776 +/* "datrie.pyx":799 * return cdatrie.trie_state_is_terminal(self._state) * * cpdef bint is_single(self): # <<<<<<<<<<<<<< @@ -11597,12 +12539,12 @@ static int __pyx_f_6datrie_10_TrieState_is_single(struct __pyx_obj_6datrie__Trie if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_single); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_single); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_13is_single)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -11611,7 +12553,7 @@ static int __pyx_f_6datrie_10_TrieState_is_single(struct __pyx_obj_6datrie__Trie __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":777 + /* "datrie.pyx":800 * * cpdef bint is_single(self): * return cdatrie.trie_state_is_single(self._state) # <<<<<<<<<<<<<< @@ -11621,12 +12563,19 @@ static int __pyx_f_6datrie_10_TrieState_is_single(struct __pyx_obj_6datrie__Trie __pyx_r = trie_state_is_single(__pyx_v_self->_state); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":799 + * return cdatrie.trie_state_is_terminal(self._state) + * + * cpdef bint is_single(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_state_is_single(self._state) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie._TrieState.is_single", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie._TrieState.is_single", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -11640,18 +12589,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_13is_single(PyObject *__pyx_v_sel __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_single (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_12is_single(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":776 - * return cdatrie.trie_state_is_terminal(self._state) - * - * cpdef bint is_single(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_state_is_single(self._state) - * - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_12is_single(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11661,14 +12604,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_12is_single(struct __pyx_obj_6dat int __pyx_clineno = 0; __Pyx_RefNannySetupContext("is_single", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_single(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_single(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.is_single", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11679,7 +12621,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_12is_single(struct __pyx_obj_6dat return __pyx_r; } -/* "datrie.pyx":779 +/* "datrie.pyx":802 * return cdatrie.trie_state_is_single(self._state) * * cpdef bint is_leaf(self): # <<<<<<<<<<<<<< @@ -11702,12 +12644,12 @@ static int __pyx_f_6datrie_10_TrieState_is_leaf(struct __pyx_obj_6datrie__TrieSt if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__is_leaf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_is_leaf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_10_TrieState_15is_leaf)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -11716,7 +12658,7 @@ static int __pyx_f_6datrie_10_TrieState_is_leaf(struct __pyx_obj_6datrie__TrieSt __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":780 + /* "datrie.pyx":803 * * cpdef bint is_leaf(self): * return cdatrie.trie_state_is_leaf(self._state) # <<<<<<<<<<<<<< @@ -11726,12 +12668,19 @@ static int __pyx_f_6datrie_10_TrieState_is_leaf(struct __pyx_obj_6datrie__TrieSt __pyx_r = trie_state_is_leaf(__pyx_v_self->_state); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":802 + * return cdatrie.trie_state_is_single(self._state) + * + * cpdef bint is_leaf(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_state_is_leaf(self._state) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie._TrieState.is_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie._TrieState.is_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -11745,18 +12694,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_15is_leaf(PyObject *__pyx_v_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_leaf (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_14is_leaf(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":779 - * return cdatrie.trie_state_is_single(self._state) - * - * cpdef bint is_leaf(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_state_is_leaf(self._state) - * - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_14is_leaf(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11766,14 +12709,13 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_14is_leaf(struct __pyx_obj_6datri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("is_leaf", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_leaf(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_leaf(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieState.is_leaf", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -11784,6 +12726,14 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_14is_leaf(struct __pyx_obj_6datri return __pyx_r; } +/* "datrie.pyx":805 + * return cdatrie.trie_state_is_leaf(self._state) + * + * def __unicode__(self): # <<<<<<<<<<<<<< + * + * return u"data:%d, term:%s, leaf:%s, single: %s" % ( + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_10_TrieState_17__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static PyObject *__pyx_pw_6datrie_10_TrieState_17__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { @@ -11791,18 +12741,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_17__unicode__(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__unicode__ (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_16__unicode__(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":782 - * return cdatrie.trie_state_is_leaf(self._state) - * - * def __unicode__(self): # <<<<<<<<<<<<<< - * - * return u"data:%d, term:%s, leaf:%s, single: %s" % ( - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_16__unicode__(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11816,7 +12760,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_16__unicode__(struct __pyx_obj_6d int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__unicode__", 0); - /* "datrie.pyx":784 + /* "datrie.pyx":807 * def __unicode__(self): * * return u"data:%d, term:%s, leaf:%s, single: %s" % ( # <<<<<<<<<<<<<< @@ -11825,49 +12769,57 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_16__unicode__(struct __pyx_obj_6d */ __Pyx_XDECREF(__pyx_r); - /* "datrie.pyx":785 + /* "datrie.pyx":808 * * return u"data:%d, term:%s, leaf:%s, single: %s" % ( * self.data(), # <<<<<<<<<<<<<< * self.is_terminal(), * self.is_leaf(), */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "datrie.pyx":786 + /* "datrie.pyx":809 * return u"data:%d, term:%s, leaf:%s, single: %s" % ( * self.data(), * self.is_terminal(), # <<<<<<<<<<<<<< * self.is_leaf(), * self.is_single(), */ - __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_terminal(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_terminal(__pyx_v_self, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - /* "datrie.pyx":787 + /* "datrie.pyx":810 * self.data(), * self.is_terminal(), * self.is_leaf(), # <<<<<<<<<<<<<< * self.is_single(), * ) */ - __pyx_t_3 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_leaf(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_leaf(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - /* "datrie.pyx":788 + /* "datrie.pyx":811 * self.is_terminal(), * self.is_leaf(), * self.is_single(), # <<<<<<<<<<<<<< * ) * */ - __pyx_t_4 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_single(__pyx_v_self, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieState *)__pyx_v_self->__pyx_vtab)->is_single(__pyx_v_self, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "datrie.pyx":808 + * + * return u"data:%d, term:%s, leaf:%s, single: %s" % ( + * self.data(), # <<<<<<<<<<<<<< + * self.is_terminal(), + * self.is_leaf(), + */ + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -11881,15 +12833,30 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_16__unicode__(struct __pyx_obj_6d __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_18), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_r = ((PyObject *)__pyx_t_4); + + /* "datrie.pyx":807 + * def __unicode__(self): + * + * return u"data:%d, term:%s, leaf:%s, single: %s" % ( # <<<<<<<<<<<<<< + * self.data(), + * self.is_terminal(), + */ + __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_data_d_term_s_leaf_s_single_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":805 + * return cdatrie.trie_state_is_leaf(self._state) + * + * def __unicode__(self): # <<<<<<<<<<<<<< + * + * return u"data:%d, term:%s, leaf:%s, single: %s" % ( + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -11904,6 +12871,14 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_16__unicode__(struct __pyx_obj_6d return __pyx_r; } +/* "datrie.pyx":814 + * ) + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.__unicode__() # XXX: this is incorrect under Python 2.x + * + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_10_TrieState_19__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_6datrie_10_TrieState_19__repr__(PyObject *__pyx_v_self) { @@ -11911,18 +12886,12 @@ static PyObject *__pyx_pw_6datrie_10_TrieState_19__repr__(PyObject *__pyx_v_self __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_10_TrieState_18__repr__(((struct __pyx_obj_6datrie__TrieState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":791 - * ) - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return self.__unicode__() # XXX: this is incorrect under Python 2.x - * - */ - static PyObject *__pyx_pf_6datrie_10_TrieState_18__repr__(struct __pyx_obj_6datrie__TrieState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11933,7 +12902,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_18__repr__(struct __pyx_obj_6datr int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__repr__", 0); - /* "datrie.pyx":792 + /* "datrie.pyx":815 * * def __repr__(self): * return self.__unicode__() # XXX: this is incorrect under Python 2.x # <<<<<<<<<<<<<< @@ -11941,17 +12910,24 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_18__repr__(struct __pyx_obj_6datr * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s____unicode__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":814 + * ) + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.__unicode__() # XXX: this is incorrect under Python 2.x + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -11963,7 +12939,7 @@ static PyObject *__pyx_pf_6datrie_10_TrieState_18__repr__(struct __pyx_obj_6datr return __pyx_r; } -/* "datrie.pyx":799 +/* "datrie.pyx":822 * cdatrie.TrieState wrapper. It can be used for custom trie traversal. * """ * cpdef int data(self): # <<<<<<<<<<<<<< @@ -11986,12 +12962,12 @@ static int __pyx_f_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseState *_ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_9BaseState_1data)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -12000,7 +12976,7 @@ static int __pyx_f_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseState *_ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":800 + /* "datrie.pyx":823 * """ * cpdef int data(self): * return cdatrie.trie_state_get_terminal_data(self._state) # <<<<<<<<<<<<<< @@ -12010,12 +12986,19 @@ static int __pyx_f_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseState *_ __pyx_r = trie_state_get_terminal_data(__pyx_v_self->__pyx_base._state); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":822 + * cdatrie.TrieState wrapper. It can be used for custom trie traversal. + * """ + * cpdef int data(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_state_get_terminal_data(self._state) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie.BaseState.data", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie.BaseState.data", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -12029,18 +13012,12 @@ static PyObject *__pyx_pw_6datrie_9BaseState_1data(PyObject *__pyx_v_self, CYTHO __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("data (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_9BaseState_data(((struct __pyx_obj_6datrie_BaseState *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":799 - * cdatrie.TrieState wrapper. It can be used for custom trie traversal. - * """ - * cpdef int data(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_state_get_terminal_data(self._state) - * - */ - static PyObject *__pyx_pf_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseState *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12050,14 +13027,13 @@ static PyObject *__pyx_pf_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseS int __pyx_clineno = 0; __Pyx_RefNannySetupContext("data", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_int(((struct __pyx_vtabstruct_6datrie_BaseState *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseState.data", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -12068,6 +13044,14 @@ static PyObject *__pyx_pf_6datrie_9BaseState_data(struct __pyx_obj_6datrie_BaseS return __pyx_r; } +/* "datrie.pyx":828 + * cdef class State(_TrieState): + * + * def __cinit__(self, Trie trie): # this is overriden for extra type check # <<<<<<<<<<<<<< + * self._state = cdatrie.trie_root(trie._c_trie) + * if self._state is NULL: + */ + /* Python wrapper */ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -12079,7 +13063,7 @@ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__trie,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_trie,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -12092,11 +13076,11 @@ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject * kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__trie)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_trie)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -12107,14 +13091,16 @@ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.State.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trie), __pyx_ptype_6datrie_Trie, 1, "trie", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trie), __pyx_ptype_6datrie_Trie, 1, "trie", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_5State___cinit__(((struct __pyx_obj_6datrie_State *)__pyx_v_self), __pyx_v_trie); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -12123,14 +13109,6 @@ static int __pyx_pw_6datrie_5State_1__cinit__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "datrie.pyx":805 - * cdef class State(_TrieState): - * - * def __cinit__(self, Trie trie): # this is overriden for extra type check # <<<<<<<<<<<<<< - * self._state = cdatrie.trie_root(trie._c_trie) - * if self._state is NULL: - */ - static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__pyx_v_self, struct __pyx_obj_6datrie_Trie *__pyx_v_trie) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -12140,7 +13118,7 @@ static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "datrie.pyx":806 + /* "datrie.pyx":829 * * def __cinit__(self, Trie trie): # this is overriden for extra type check * self._state = cdatrie.trie_root(trie._c_trie) # <<<<<<<<<<<<<< @@ -12149,7 +13127,7 @@ static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__p */ __pyx_v_self->__pyx_base._state = trie_root(__pyx_v_trie->__pyx_base._c_trie); - /* "datrie.pyx":807 + /* "datrie.pyx":830 * def __cinit__(self, Trie trie): # this is overriden for extra type check * self._state = cdatrie.trie_root(trie._c_trie) * if self._state is NULL: # <<<<<<<<<<<<<< @@ -12159,19 +13137,17 @@ static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__p __pyx_t_1 = ((__pyx_v_self->__pyx_base._state == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":808 + /* "datrie.pyx":831 * self._state = cdatrie.trie_root(trie._c_trie) * if self._state is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * self._trie = trie * */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":809 + /* "datrie.pyx":832 * if self._state is NULL: * raise MemoryError() * self._trie = trie # <<<<<<<<<<<<<< @@ -12184,6 +13160,15 @@ static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__p __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base._trie)); __pyx_v_self->__pyx_base._trie = ((struct __pyx_obj_6datrie_BaseTrie *)__pyx_v_trie); + /* "datrie.pyx":828 + * cdef class State(_TrieState): + * + * def __cinit__(self, Trie trie): # this is overriden for extra type check # <<<<<<<<<<<<<< + * self._state = cdatrie.trie_root(trie._c_trie) + * if self._state is NULL: + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -12194,7 +13179,7 @@ static int __pyx_pf_6datrie_5State___cinit__(struct __pyx_obj_6datrie_State *__p return __pyx_r; } -/* "datrie.pyx":811 +/* "datrie.pyx":834 * self._trie = trie * * cpdef data(self): # <<<<<<<<<<<<<< @@ -12217,11 +13202,11 @@ static PyObject *__pyx_f_6datrie_5State_data(struct __pyx_obj_6datrie_State *__p if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_5State_3data)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -12231,7 +13216,7 @@ static PyObject *__pyx_f_6datrie_5State_data(struct __pyx_obj_6datrie_State *__p __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":812 + /* "datrie.pyx":835 * * cpdef data(self): * cdef cdatrie.TrieData data = cdatrie.trie_state_get_terminal_data(self._state) # <<<<<<<<<<<<<< @@ -12240,7 +13225,7 @@ static PyObject *__pyx_f_6datrie_5State_data(struct __pyx_obj_6datrie_State *__p */ __pyx_v_data = trie_state_get_terminal_data(__pyx_v_self->__pyx_base._state); - /* "datrie.pyx":813 + /* "datrie.pyx":836 * cpdef data(self): * cdef cdatrie.TrieData data = cdatrie.trie_state_get_terminal_data(self._state) * return self._trie._index_to_value(data) # <<<<<<<<<<<<<< @@ -12248,14 +13233,21 @@ static PyObject *__pyx_f_6datrie_5State_data(struct __pyx_obj_6datrie_State *__p * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_base._trie->__pyx_vtab)->_index_to_value(__pyx_v_self->__pyx_base._trie, __pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_base._trie->__pyx_vtab)->_index_to_value(__pyx_v_self->__pyx_base._trie, __pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":834 + * self._trie = trie + * + * cpdef data(self): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData data = cdatrie.trie_state_get_terminal_data(self._state) + * return self._trie._index_to_value(data) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -12274,18 +13266,12 @@ static PyObject *__pyx_pw_6datrie_5State_3data(PyObject *__pyx_v_self, CYTHON_UN __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("data (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_5State_2data(((struct __pyx_obj_6datrie_State *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":811 - * self._trie = trie - * - * cpdef data(self): # <<<<<<<<<<<<<< - * cdef cdatrie.TrieData data = cdatrie.trie_state_get_terminal_data(self._state) - * return self._trie._index_to_value(data) - */ - static PyObject *__pyx_pf_6datrie_5State_2data(struct __pyx_obj_6datrie_State *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12295,14 +13281,13 @@ static PyObject *__pyx_pf_6datrie_5State_2data(struct __pyx_obj_6datrie_State *_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("data", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_State *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_State *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.State.data", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -12313,6 +13298,14 @@ static PyObject *__pyx_pf_6datrie_5State_2data(struct __pyx_obj_6datrie_State *_ return __pyx_r; } +/* "datrie.pyx":843 + * cdef _TrieState _root + * + * def __cinit__(self, _TrieState state): # <<<<<<<<<<<<<< + * self._root = state # prevent garbage collection of state + * self._iter = cdatrie.trie_iterator_new(state._state) + */ + /* Python wrapper */ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -12324,7 +13317,7 @@ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, P __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__state,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -12337,11 +13330,11 @@ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, P kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__state)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -12352,14 +13345,16 @@ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, P } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie._TrieIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie__TrieState, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie__TrieState, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_13_TrieIterator___cinit__(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_self), __pyx_v_state); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -12368,14 +13363,6 @@ static int __pyx_pw_6datrie_13_TrieIterator_1__cinit__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "datrie.pyx":820 - * cdef _TrieState _root - * - * def __cinit__(self, _TrieState state): # <<<<<<<<<<<<<< - * self._root = state # prevent garbage collection of state - * self._iter = cdatrie.trie_iterator_new(state._state) - */ - static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__TrieIterator *__pyx_v_self, struct __pyx_obj_6datrie__TrieState *__pyx_v_state) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -12385,7 +13372,7 @@ static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "datrie.pyx":821 + /* "datrie.pyx":844 * * def __cinit__(self, _TrieState state): * self._root = state # prevent garbage collection of state # <<<<<<<<<<<<<< @@ -12398,7 +13385,7 @@ static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__ __Pyx_DECREF(((PyObject *)__pyx_v_self->_root)); __pyx_v_self->_root = __pyx_v_state; - /* "datrie.pyx":822 + /* "datrie.pyx":845 * def __cinit__(self, _TrieState state): * self._root = state # prevent garbage collection of state * self._iter = cdatrie.trie_iterator_new(state._state) # <<<<<<<<<<<<<< @@ -12407,7 +13394,7 @@ static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__ */ __pyx_v_self->_iter = trie_iterator_new(__pyx_v_state->_state); - /* "datrie.pyx":823 + /* "datrie.pyx":846 * self._root = state # prevent garbage collection of state * self._iter = cdatrie.trie_iterator_new(state._state) * if self._iter is NULL: # <<<<<<<<<<<<<< @@ -12417,18 +13404,25 @@ static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__ __pyx_t_1 = ((__pyx_v_self->_iter == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":824 + /* "datrie.pyx":847 * self._iter = cdatrie.trie_iterator_new(state._state) * if self._iter is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * def __dealloc__(self): */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; + /* "datrie.pyx":843 + * cdef _TrieState _root + * + * def __cinit__(self, _TrieState state): # <<<<<<<<<<<<<< + * self._root = state # prevent garbage collection of state + * self._iter = cdatrie.trie_iterator_new(state._state) + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -12439,29 +13433,31 @@ static int __pyx_pf_6datrie_13_TrieIterator___cinit__(struct __pyx_obj_6datrie__ return __pyx_r; } +/* "datrie.pyx":849 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._iter is not NULL: + * cdatrie.trie_iterator_free(self._iter) + */ + /* Python wrapper */ static void __pyx_pw_6datrie_13_TrieIterator_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6datrie_13_TrieIterator_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6datrie_13_TrieIterator_2__dealloc__(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":826 - * raise MemoryError() - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._iter is not NULL: - * cdatrie.trie_iterator_free(self._iter) - */ - static void __pyx_pf_6datrie_13_TrieIterator_2__dealloc__(struct __pyx_obj_6datrie__TrieIterator *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "datrie.pyx":827 + /* "datrie.pyx":850 * * def __dealloc__(self): * if self._iter is not NULL: # <<<<<<<<<<<<<< @@ -12471,7 +13467,7 @@ static void __pyx_pf_6datrie_13_TrieIterator_2__dealloc__(struct __pyx_obj_6datr __pyx_t_1 = ((__pyx_v_self->_iter != NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":828 + /* "datrie.pyx":851 * def __dealloc__(self): * if self._iter is not NULL: * cdatrie.trie_iterator_free(self._iter) # <<<<<<<<<<<<<< @@ -12483,10 +13479,19 @@ static void __pyx_pf_6datrie_13_TrieIterator_2__dealloc__(struct __pyx_obj_6datr } __pyx_L3:; + /* "datrie.pyx":849 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._iter is not NULL: + * cdatrie.trie_iterator_free(self._iter) + */ + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":830 +/* "datrie.pyx":853 * cdatrie.trie_iterator_free(self._iter) * * cpdef bint next(self): # <<<<<<<<<<<<<< @@ -12509,12 +13514,12 @@ static int __pyx_f_6datrie_13_TrieIterator_next(struct __pyx_obj_6datrie__TrieIt if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__next); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_5next)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -12523,7 +13528,7 @@ static int __pyx_f_6datrie_13_TrieIterator_next(struct __pyx_obj_6datrie__TrieIt __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":831 + /* "datrie.pyx":854 * * cpdef bint next(self): * return cdatrie.trie_iterator_next(self._iter) # <<<<<<<<<<<<<< @@ -12533,12 +13538,19 @@ static int __pyx_f_6datrie_13_TrieIterator_next(struct __pyx_obj_6datrie__TrieIt __pyx_r = trie_iterator_next(__pyx_v_self->_iter); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":853 + * cdatrie.trie_iterator_free(self._iter) + * + * cpdef bint next(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_iterator_next(self._iter) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie._TrieIterator.next", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie._TrieIterator.next", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -12552,18 +13564,12 @@ static PyObject *__pyx_pw_6datrie_13_TrieIterator_5next(PyObject *__pyx_v_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("next (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_13_TrieIterator_4next(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":830 - * cdatrie.trie_iterator_free(self._iter) - * - * cpdef bint next(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_iterator_next(self._iter) - * - */ - static PyObject *__pyx_pf_6datrie_13_TrieIterator_4next(struct __pyx_obj_6datrie__TrieIterator *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12573,14 +13579,13 @@ static PyObject *__pyx_pf_6datrie_13_TrieIterator_4next(struct __pyx_obj_6datrie int __pyx_clineno = 0; __Pyx_RefNannySetupContext("next", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieIterator *)__pyx_v_self->__pyx_vtab)->next(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_6datrie__TrieIterator *)__pyx_v_self->__pyx_vtab)->next(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieIterator.next", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -12591,7 +13596,7 @@ static PyObject *__pyx_pf_6datrie_13_TrieIterator_4next(struct __pyx_obj_6datrie return __pyx_r; } -/* "datrie.pyx":833 +/* "datrie.pyx":856 * return cdatrie.trie_iterator_next(self._iter) * * cpdef unicode key(self): # <<<<<<<<<<<<<< @@ -12606,6 +13611,16 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + char const *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -12614,13 +13629,13 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_7key)) { - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -12629,7 +13644,7 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":834 + /* "datrie.pyx":857 * * cpdef unicode key(self): * cdef cdatrie.AlphaChar* key = cdatrie.trie_iterator_get_key(self._iter) # <<<<<<<<<<<<<< @@ -12638,7 +13653,7 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T */ __pyx_v_key = trie_iterator_get_key(__pyx_v_self->_iter); - /* "datrie.pyx":835 + /* "datrie.pyx":858 * cpdef unicode key(self): * cdef cdatrie.AlphaChar* key = cdatrie.trie_iterator_get_key(self._iter) * try: # <<<<<<<<<<<<<< @@ -12647,22 +13662,22 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T */ /*try:*/ { - /* "datrie.pyx":836 + /* "datrie.pyx":859 * cdef cdatrie.AlphaChar* key = cdatrie.trie_iterator_get_key(self._iter) * try: * return unicode_from_alpha_char(key) # <<<<<<<<<<<<<< * finally: * free(key) */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_1 = ((PyObject *)__pyx_f_6datrie_unicode_from_alpha_char(__pyx_v_key, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L4;} + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_6datrie_unicode_from_alpha_char(__pyx_v_key, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L4_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L3; + goto __pyx_L3_return; } - /* "datrie.pyx":838 + /* "datrie.pyx":861 * return unicode_from_alpha_char(key) * finally: * free(key) # <<<<<<<<<<<<<< @@ -12670,38 +13685,56 @@ static PyObject *__pyx_f_6datrie_13_TrieIterator_key(struct __pyx_obj_6datrie__T * */ /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L5; - __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 3; goto __pyx_L5; - __pyx_L4: { - __pyx_why = 4; + /*exception exit:*/{ + __pyx_L4_error:; + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L5; - } - __pyx_L5:; - free(__pyx_v_key); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_6); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename; + { + free(__pyx_v_key); + } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); } + __Pyx_XGIVEREF(__pyx_t_6); + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8); + __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; + __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5; + goto __pyx_L1_error; + } + __pyx_L3_return: { + __pyx_t_12 = __pyx_r; + __pyx_r = 0; + free(__pyx_v_key); + __pyx_r = __pyx_t_12; + __pyx_t_12 = 0; + goto __pyx_L0; } } - __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":856 + * return cdatrie.trie_iterator_next(self._iter) + * + * cpdef unicode key(self): # <<<<<<<<<<<<<< + * cdef cdatrie.AlphaChar* key = cdatrie.trie_iterator_get_key(self._iter) + * try: + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -12720,18 +13753,12 @@ static PyObject *__pyx_pw_6datrie_13_TrieIterator_7key(PyObject *__pyx_v_self, C __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("key (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_13_TrieIterator_6key(((struct __pyx_obj_6datrie__TrieIterator *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":833 - * return cdatrie.trie_iterator_next(self._iter) - * - * cpdef unicode key(self): # <<<<<<<<<<<<<< - * cdef cdatrie.AlphaChar* key = cdatrie.trie_iterator_get_key(self._iter) - * try: - */ - static PyObject *__pyx_pf_6datrie_13_TrieIterator_6key(struct __pyx_obj_6datrie__TrieIterator *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12741,14 +13768,13 @@ static PyObject *__pyx_pf_6datrie_13_TrieIterator_6key(struct __pyx_obj_6datrie_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("key", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_6datrie__TrieIterator *)__pyx_v_self->__pyx_vtab)->key(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie__TrieIterator *)__pyx_v_self->__pyx_vtab)->key(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie._TrieIterator.key", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -12759,7 +13785,7 @@ static PyObject *__pyx_pf_6datrie_13_TrieIterator_6key(struct __pyx_obj_6datrie_ return __pyx_r; } -/* "datrie.pyx":846 +/* "datrie.pyx":869 * traversal. * """ * cpdef cdatrie.TrieData data(self): # <<<<<<<<<<<<<< @@ -12782,12 +13808,12 @@ static TrieData __pyx_f_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_Bas if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_12BaseIterator_1data)) { - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_from_py_TrieData(__pyx_t_2); if (unlikely((__pyx_t_3 == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_As_TrieData(__pyx_t_2); if (unlikely((__pyx_t_3 == (TrieData)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -12796,7 +13822,7 @@ static TrieData __pyx_f_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_Bas __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":847 + /* "datrie.pyx":870 * """ * cpdef cdatrie.TrieData data(self): * return cdatrie.trie_iterator_get_data(self._iter) # <<<<<<<<<<<<<< @@ -12806,12 +13832,19 @@ static TrieData __pyx_f_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_Bas __pyx_r = trie_iterator_get_data(__pyx_v_self->__pyx_base._iter); goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":869 + * traversal. + * """ + * cpdef cdatrie.TrieData data(self): # <<<<<<<<<<<<<< + * return cdatrie.trie_iterator_get_data(self._iter) + * + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_WriteUnraisable("datrie.BaseIterator.data", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("datrie.BaseIterator.data", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -12825,18 +13858,12 @@ static PyObject *__pyx_pw_6datrie_12BaseIterator_1data(PyObject *__pyx_v_self, C __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("data (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_12BaseIterator_data(((struct __pyx_obj_6datrie_BaseIterator *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":846 - * traversal. - * """ - * cpdef cdatrie.TrieData data(self): # <<<<<<<<<<<<<< - * return cdatrie.trie_iterator_get_data(self._iter) - * - */ - static PyObject *__pyx_pf_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_BaseIterator *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12846,14 +13873,13 @@ static PyObject *__pyx_pf_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_B int __pyx_clineno = 0; __Pyx_RefNannySetupContext("data", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_to_py_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_TrieData(((struct __pyx_vtabstruct_6datrie_BaseIterator *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.BaseIterator.data", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -12864,6 +13890,14 @@ static PyObject *__pyx_pf_6datrie_12BaseIterator_data(struct __pyx_obj_6datrie_B return __pyx_r; } +/* "datrie.pyx":878 + * traversal. + * """ + * def __cinit__(self, State state): # this is overriden for extra type check # <<<<<<<<<<<<<< + * self._root = state # prevent garbage collection of state + * self._iter = cdatrie.trie_iterator_new(state._state) + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -12875,7 +13909,7 @@ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__state,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state,0}; PyObject* values[1] = {0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -12888,11 +13922,11 @@ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObjec kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__state)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -12903,14 +13937,16 @@ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObjec } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.Iterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie_State, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_6datrie_State, 1, "state", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_8Iterator___cinit__(((struct __pyx_obj_6datrie_Iterator *)__pyx_v_self), __pyx_v_state); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -12919,14 +13955,6 @@ static int __pyx_pw_6datrie_8Iterator_1__cinit__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "datrie.pyx":855 - * traversal. - * """ - * def __cinit__(self, State state): # this is overriden for extra type check # <<<<<<<<<<<<<< - * self._root = state # prevent garbage collection of state - * self._iter = cdatrie.trie_iterator_new(state._state) - */ - static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterator *__pyx_v_self, struct __pyx_obj_6datrie_State *__pyx_v_state) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -12936,7 +13964,7 @@ static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterato int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "datrie.pyx":856 + /* "datrie.pyx":879 * """ * def __cinit__(self, State state): # this is overriden for extra type check * self._root = state # prevent garbage collection of state # <<<<<<<<<<<<<< @@ -12949,7 +13977,7 @@ static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterato __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base._root)); __pyx_v_self->__pyx_base._root = ((struct __pyx_obj_6datrie__TrieState *)__pyx_v_state); - /* "datrie.pyx":857 + /* "datrie.pyx":880 * def __cinit__(self, State state): # this is overriden for extra type check * self._root = state # prevent garbage collection of state * self._iter = cdatrie.trie_iterator_new(state._state) # <<<<<<<<<<<<<< @@ -12958,7 +13986,7 @@ static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterato */ __pyx_v_self->__pyx_base._iter = trie_iterator_new(__pyx_v_state->__pyx_base._state); - /* "datrie.pyx":858 + /* "datrie.pyx":881 * self._root = state # prevent garbage collection of state * self._iter = cdatrie.trie_iterator_new(state._state) * if self._iter is NULL: # <<<<<<<<<<<<<< @@ -12968,18 +13996,25 @@ static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterato __pyx_t_1 = ((__pyx_v_self->__pyx_base._iter == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":859 + /* "datrie.pyx":882 * self._iter = cdatrie.trie_iterator_new(state._state) * if self._iter is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * cpdef data(self): */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; + /* "datrie.pyx":878 + * traversal. + * """ + * def __cinit__(self, State state): # this is overriden for extra type check # <<<<<<<<<<<<<< + * self._root = state # prevent garbage collection of state + * self._iter = cdatrie.trie_iterator_new(state._state) + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -12990,7 +14025,7 @@ static int __pyx_pf_6datrie_8Iterator___cinit__(struct __pyx_obj_6datrie_Iterato return __pyx_r; } -/* "datrie.pyx":861 +/* "datrie.pyx":884 * raise MemoryError() * * cpdef data(self): # <<<<<<<<<<<<<< @@ -13013,11 +14048,11 @@ static PyObject *__pyx_f_6datrie_8Iterator_data(struct __pyx_obj_6datrie_Iterato if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8Iterator_3data)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -13027,7 +14062,7 @@ static PyObject *__pyx_f_6datrie_8Iterator_data(struct __pyx_obj_6datrie_Iterato __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":862 + /* "datrie.pyx":885 * * cpdef data(self): * cdef cdatrie.TrieData data = cdatrie.trie_iterator_get_data(self._iter) # <<<<<<<<<<<<<< @@ -13036,7 +14071,7 @@ static PyObject *__pyx_f_6datrie_8Iterator_data(struct __pyx_obj_6datrie_Iterato */ __pyx_v_data = trie_iterator_get_data(__pyx_v_self->__pyx_base._iter); - /* "datrie.pyx":863 + /* "datrie.pyx":886 * cpdef data(self): * cdef cdatrie.TrieData data = cdatrie.trie_iterator_get_data(self._iter) * return self._root._trie._index_to_value(data) # <<<<<<<<<<<<<< @@ -13044,14 +14079,21 @@ static PyObject *__pyx_f_6datrie_8Iterator_data(struct __pyx_obj_6datrie_Iterato * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_base._root->_trie->__pyx_vtab)->_index_to_value(__pyx_v_self->__pyx_base._root->_trie, __pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_BaseTrie *)__pyx_v_self->__pyx_base._root->_trie->__pyx_vtab)->_index_to_value(__pyx_v_self->__pyx_base._root->_trie, __pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":884 + * raise MemoryError() + * + * cpdef data(self): # <<<<<<<<<<<<<< + * cdef cdatrie.TrieData data = cdatrie.trie_iterator_get_data(self._iter) + * return self._root._trie._index_to_value(data) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -13070,18 +14112,12 @@ static PyObject *__pyx_pw_6datrie_8Iterator_3data(PyObject *__pyx_v_self, CYTHON __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("data (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8Iterator_2data(((struct __pyx_obj_6datrie_Iterator *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":861 - * raise MemoryError() - * - * cpdef data(self): # <<<<<<<<<<<<<< - * cdef cdatrie.TrieData data = cdatrie.trie_iterator_get_data(self._iter) - * return self._root._trie._index_to_value(data) - */ - static PyObject *__pyx_pf_6datrie_8Iterator_2data(struct __pyx_obj_6datrie_Iterator *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -13091,14 +14127,13 @@ static PyObject *__pyx_pf_6datrie_8Iterator_2data(struct __pyx_obj_6datrie_Itera int __pyx_clineno = 0; __Pyx_RefNannySetupContext("data", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Iterator *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_Iterator *)__pyx_v_self->__pyx_base.__pyx_vtab)->data(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.Iterator.data", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -13109,7 +14144,7 @@ static PyObject *__pyx_pf_6datrie_8Iterator_2data(struct __pyx_obj_6datrie_Itera return __pyx_r; } -/* "datrie.pyx":866 +/* "datrie.pyx":889 * * * cdef (cdatrie.Trie* ) _load_from_file(f) except NULL: # <<<<<<<<<<<<<< @@ -13134,32 +14169,32 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_load_from_file", 0); - /* "datrie.pyx":867 + /* "datrie.pyx":890 * * cdef (cdatrie.Trie* ) _load_from_file(f) except NULL: * cdef int fd = f.fileno() # <<<<<<<<<<<<<< * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(fd, "r") * if f_ptr == NULL: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s__fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_fd = __pyx_t_3; - /* "datrie.pyx":868 + /* "datrie.pyx":891 * cdef (cdatrie.Trie* ) _load_from_file(f) except NULL: * cdef int fd = f.fileno() * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(fd, "r") # <<<<<<<<<<<<<< * if f_ptr == NULL: * raise IOError() */ - __pyx_v_f_ptr = fdopen(__pyx_v_fd, __pyx_k__r); + __pyx_v_f_ptr = fdopen(__pyx_v_fd, __pyx_k_r); - /* "datrie.pyx":869 + /* "datrie.pyx":892 * cdef int fd = f.fileno() * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(fd, "r") * if f_ptr == NULL: # <<<<<<<<<<<<<< @@ -13169,23 +14204,21 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { __pyx_t_4 = ((__pyx_v_f_ptr == NULL) != 0); if (__pyx_t_4) { - /* "datrie.pyx":870 + /* "datrie.pyx":893 * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(fd, "r") * if f_ptr == NULL: * raise IOError() # <<<<<<<<<<<<<< * cdef cdatrie.Trie* trie = cdatrie.trie_fread(f_ptr) * if trie == NULL: */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":871 + /* "datrie.pyx":894 * if f_ptr == NULL: * raise IOError() * cdef cdatrie.Trie* trie = cdatrie.trie_fread(f_ptr) # <<<<<<<<<<<<<< @@ -13194,7 +14227,7 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { */ __pyx_v_trie = trie_fread(__pyx_v_f_ptr); - /* "datrie.pyx":872 + /* "datrie.pyx":895 * raise IOError() * cdef cdatrie.Trie* trie = cdatrie.trie_fread(f_ptr) * if trie == NULL: # <<<<<<<<<<<<<< @@ -13204,26 +14237,24 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { __pyx_t_4 = ((__pyx_v_trie == NULL) != 0); if (__pyx_t_4) { - /* "datrie.pyx":873 + /* "datrie.pyx":896 * cdef cdatrie.Trie* trie = cdatrie.trie_fread(f_ptr) * if trie == NULL: * raise DatrieError("Can't load trie from stream") # <<<<<<<<<<<<<< * * cdef int f_pos = stdio.ftell(f_ptr) */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DatrieError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DatrieError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L4:; - /* "datrie.pyx":875 + /* "datrie.pyx":898 * raise DatrieError("Can't load trie from stream") * * cdef int f_pos = stdio.ftell(f_ptr) # <<<<<<<<<<<<<< @@ -13232,29 +14263,29 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { */ __pyx_v_f_pos = ftell(__pyx_v_f_ptr); - /* "datrie.pyx":876 + /* "datrie.pyx":899 * * cdef int f_pos = stdio.ftell(f_ptr) * f.seek(f_pos) # <<<<<<<<<<<<<< * * return trie */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_f_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_f_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "datrie.pyx":878 + /* "datrie.pyx":901 * f.seek(f_pos) * * return trie # <<<<<<<<<<<<<< @@ -13264,8 +14295,15 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { __pyx_r = __pyx_v_trie; goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":889 + * + * + * cdef (cdatrie.Trie* ) _load_from_file(f) except NULL: # <<<<<<<<<<<<<< + * cdef int fd = f.fileno() + * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(fd, "r") + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -13277,6 +14315,14 @@ static Trie *__pyx_f_6datrie__load_from_file(PyObject *__pyx_v_f) { return __pyx_r; } +/* "datrie.pyx":931 + * cdef cdatrie.AlphaMap *_c_alpha_map + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._c_alpha_map = cdatrie.alpha_map_new() + * if self._c_alpha_map is NULL: + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8AlphaMap_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_8AlphaMap_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -13287,18 +14333,12 @@ static int __pyx_pw_6datrie_8AlphaMap_1__cinit__(PyObject *__pyx_v_self, PyObjec __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_6datrie_8AlphaMap___cinit__(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":908 - * cdef cdatrie.AlphaMap *_c_alpha_map - * - * def __cinit__(self): # <<<<<<<<<<<<<< - * self._c_alpha_map = cdatrie.alpha_map_new() - * if self._c_alpha_map is NULL: - */ - static int __pyx_pf_6datrie_8AlphaMap___cinit__(struct __pyx_obj_6datrie_AlphaMap *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -13308,7 +14348,7 @@ static int __pyx_pf_6datrie_8AlphaMap___cinit__(struct __pyx_obj_6datrie_AlphaMa int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "datrie.pyx":909 + /* "datrie.pyx":932 * * def __cinit__(self): * self._c_alpha_map = cdatrie.alpha_map_new() # <<<<<<<<<<<<<< @@ -13317,7 +14357,7 @@ static int __pyx_pf_6datrie_8AlphaMap___cinit__(struct __pyx_obj_6datrie_AlphaMa */ __pyx_v_self->_c_alpha_map = alpha_map_new(); - /* "datrie.pyx":910 + /* "datrie.pyx":933 * def __cinit__(self): * self._c_alpha_map = cdatrie.alpha_map_new() * if self._c_alpha_map is NULL: # <<<<<<<<<<<<<< @@ -13327,18 +14367,25 @@ static int __pyx_pf_6datrie_8AlphaMap___cinit__(struct __pyx_obj_6datrie_AlphaMa __pyx_t_1 = ((__pyx_v_self->_c_alpha_map == NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":911 + /* "datrie.pyx":934 * self._c_alpha_map = cdatrie.alpha_map_new() * if self._c_alpha_map is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * def __dealloc__(self): */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; + /* "datrie.pyx":931 + * cdef cdatrie.AlphaMap *_c_alpha_map + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self._c_alpha_map = cdatrie.alpha_map_new() + * if self._c_alpha_map is NULL: + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -13349,29 +14396,31 @@ static int __pyx_pf_6datrie_8AlphaMap___cinit__(struct __pyx_obj_6datrie_AlphaMa return __pyx_r; } +/* "datrie.pyx":936 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._c_alpha_map is not NULL: + * cdatrie.alpha_map_free(self._c_alpha_map) + */ + /* Python wrapper */ static void __pyx_pw_6datrie_8AlphaMap_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_6datrie_8AlphaMap_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_pf_6datrie_8AlphaMap_2__dealloc__(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); } -/* "datrie.pyx":913 - * raise MemoryError() - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self._c_alpha_map is not NULL: - * cdatrie.alpha_map_free(self._c_alpha_map) - */ - static void __pyx_pf_6datrie_8AlphaMap_2__dealloc__(struct __pyx_obj_6datrie_AlphaMap *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "datrie.pyx":914 + /* "datrie.pyx":937 * * def __dealloc__(self): * if self._c_alpha_map is not NULL: # <<<<<<<<<<<<<< @@ -13381,7 +14430,7 @@ static void __pyx_pf_6datrie_8AlphaMap_2__dealloc__(struct __pyx_obj_6datrie_Alp __pyx_t_1 = ((__pyx_v_self->_c_alpha_map != NULL) != 0); if (__pyx_t_1) { - /* "datrie.pyx":915 + /* "datrie.pyx":938 * def __dealloc__(self): * if self._c_alpha_map is not NULL: * cdatrie.alpha_map_free(self._c_alpha_map) # <<<<<<<<<<<<<< @@ -13393,9 +14442,26 @@ static void __pyx_pf_6datrie_8AlphaMap_2__dealloc__(struct __pyx_obj_6datrie_Alp } __pyx_L3:; + /* "datrie.pyx":936 + * raise MemoryError() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * if self._c_alpha_map is not NULL: + * cdatrie.alpha_map_free(self._c_alpha_map) + */ + + /* function exit code */ __Pyx_RefNannyFinishContext(); } +/* "datrie.pyx":940 + * cdatrie.alpha_map_free(self._c_alpha_map) + * + * def __init__(self, alphabet=None, ranges=None): # <<<<<<<<<<<<<< + * if ranges is not None: + * for range in ranges: + */ + /* Python wrapper */ static int __pyx_pw_6datrie_8AlphaMap_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_6datrie_8AlphaMap_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -13408,16 +14474,8 @@ static int __pyx_pw_6datrie_8AlphaMap_5__init__(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alphabet,&__pyx_n_s__ranges,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alphabet,&__pyx_n_s_ranges,0}; PyObject* values[2] = {0,0}; - - /* "datrie.pyx":917 - * cdatrie.alpha_map_free(self._c_alpha_map) - * - * def __init__(self, alphabet=None, ranges=None): # <<<<<<<<<<<<<< - * if ranges is not None: - * for range in ranges: - */ values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -13433,17 +14491,17 @@ static int __pyx_pw_6datrie_8AlphaMap_5__init__(PyObject *__pyx_v_self, PyObject switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alphabet); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ranges); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ranges); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -13458,13 +14516,15 @@ static int __pyx_pw_6datrie_8AlphaMap_5__init__(PyObject *__pyx_v_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.AlphaMap.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6datrie_8AlphaMap_4__init__(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self), __pyx_v_alphabet, __pyx_v_ranges); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -13486,7 +14546,7 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "datrie.pyx":918 + /* "datrie.pyx":941 * * def __init__(self, alphabet=None, ranges=None): * if ranges is not None: # <<<<<<<<<<<<<< @@ -13497,7 +14557,7 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "datrie.pyx":919 + /* "datrie.pyx":942 * def __init__(self, alphabet=None, ranges=None): * if ranges is not None: * for range in ranges: # <<<<<<<<<<<<<< @@ -13508,7 +14568,7 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa __pyx_t_3 = __pyx_v_ranges; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ranges); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ranges); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } @@ -13516,47 +14576,47 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_6)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_6); } - __Pyx_XDECREF(__pyx_v_range); - __pyx_v_range = __pyx_t_6; + __Pyx_XDECREF_SET(__pyx_v_range, __pyx_t_6); __pyx_t_6 = 0; - /* "datrie.pyx":920 + /* "datrie.pyx":943 * if ranges is not None: * for range in ranges: * self.add_range(*range) # <<<<<<<<<<<<<< * * if alphabet is not None: */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__add_range); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_range); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PySequence_Tuple(__pyx_v_range); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_7)); - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PySequence_Tuple(__pyx_v_range); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -13564,7 +14624,7 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa } __pyx_L3:; - /* "datrie.pyx":922 + /* "datrie.pyx":945 * self.add_range(*range) * * if alphabet is not None: # <<<<<<<<<<<<<< @@ -13575,29 +14635,38 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { - /* "datrie.pyx":923 + /* "datrie.pyx":946 * * if alphabet is not None: * self.add_alphabet(alphabet) # <<<<<<<<<<<<<< * * def add_alphabet(self, alphabet): */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__add_alphabet); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_alphabet); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_alphabet); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_alphabet); __Pyx_GIVEREF(__pyx_v_alphabet); - __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6; } __pyx_L6:; + /* "datrie.pyx":940 + * cdatrie.alpha_map_free(self._c_alpha_map) + * + * def __init__(self, alphabet=None, ranges=None): # <<<<<<<<<<<<<< + * if ranges is not None: + * for range in ranges: + */ + + /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; @@ -13613,6 +14682,14 @@ static int __pyx_pf_6datrie_8AlphaMap_4__init__(struct __pyx_obj_6datrie_AlphaMa return __pyx_r; } +/* "datrie.pyx":948 + * self.add_alphabet(alphabet) + * + * def add_alphabet(self, alphabet): # <<<<<<<<<<<<<< + * """ + * Adds all chars from iterable to the alphabet set. + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8AlphaMap_7add_alphabet(PyObject *__pyx_v_self, PyObject *__pyx_v_alphabet); /*proto*/ static char __pyx_doc_6datrie_8AlphaMap_6add_alphabet[] = "\n Adds all chars from iterable to the alphabet set.\n "; @@ -13621,18 +14698,12 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_7add_alphabet(PyObject *__pyx_v_self __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_alphabet (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_8AlphaMap_6add_alphabet(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self), ((PyObject *)__pyx_v_alphabet)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":925 - * self.add_alphabet(alphabet) - * - * def add_alphabet(self, alphabet): # <<<<<<<<<<<<<< - * """ - * Adds all chars from iterable to the alphabet set. - */ - static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datrie_AlphaMap *__pyx_v_self, PyObject *__pyx_v_alphabet) { PyObject *__pyx_v_begin = NULL; PyObject *__pyx_v_end = NULL; @@ -13653,29 +14724,29 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_alphabet", 0); - /* "datrie.pyx":929 + /* "datrie.pyx":952 * Adds all chars from iterable to the alphabet set. * """ * for begin, end in alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< * self._add_range(begin, end) * */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__alphabet_to_ranges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_alphabet_to_ranges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_alphabet); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_alphabet); __Pyx_GIVEREF(__pyx_v_alphabet); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -13684,23 +14755,24 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -13716,7 +14788,7 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -13729,16 +14801,15 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - { + } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -13746,7 +14817,7 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; @@ -13754,31 +14825,38 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __Pyx_XDECREF(__pyx_v_begin); - __pyx_v_begin = __pyx_t_1; + __Pyx_XDECREF_SET(__pyx_v_begin, __pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_v_end); - __pyx_v_end = __pyx_t_6; + __Pyx_XDECREF_SET(__pyx_v_end, __pyx_t_6); __pyx_t_6 = 0; - /* "datrie.pyx":930 + /* "datrie.pyx":953 * """ * for begin, end in alphabet_to_ranges(alphabet): * self._add_range(begin, end) # <<<<<<<<<<<<<< * * def add_range(self, begin, end): */ - __pyx_t_9 = __Pyx_PyInt_from_py_AlphaChar(__pyx_v_begin); if (unlikely((__pyx_t_9 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_10 = __Pyx_PyInt_from_py_AlphaChar(__pyx_v_end); if (unlikely((__pyx_t_10 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_t_9, __pyx_t_10, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyInt_As_AlphaChar(__pyx_v_begin); if (unlikely((__pyx_t_9 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_PyInt_As_AlphaChar(__pyx_v_end); if (unlikely((__pyx_t_10 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_t_9, __pyx_t_10, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + /* "datrie.pyx":948 + * self.add_alphabet(alphabet) + * + * def add_alphabet(self, alphabet): # <<<<<<<<<<<<<< + * """ + * Adds all chars from iterable to the alphabet set. + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -13797,6 +14875,14 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_6add_alphabet(struct __pyx_obj_6datr return __pyx_r; } +/* "datrie.pyx":955 + * self._add_range(begin, end) + * + * def add_range(self, begin, end): # <<<<<<<<<<<<<< + * """ + * Add a range of character codes from ``begin`` to ``end`` + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_8AlphaMap_9add_range(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6datrie_8AlphaMap_8add_range[] = "\n Add a range of character codes from ``begin`` to ``end``\n to the alphabet set.\n\n ``begin`` - the first character of the range;\n ``end`` - the last character of the range.\n "; @@ -13810,7 +14896,7 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_9add_range(PyObject *__pyx_v_self, P __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_range (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__begin,&__pyx_n_s__end,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_begin,&__pyx_n_s_end,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -13824,16 +14910,16 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_9add_range(PyObject *__pyx_v_self, P kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__begin)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_begin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("add_range", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("add_range", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_range") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_range") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -13846,25 +14932,19 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_9add_range(PyObject *__pyx_v_self, P } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("add_range", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("add_range", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.AlphaMap.add_range", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6datrie_8AlphaMap_8add_range(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self), __pyx_v_begin, __pyx_v_end); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":932 - * self._add_range(begin, end) - * - * def add_range(self, begin, end): # <<<<<<<<<<<<<< - * """ - * Add a range of character codes from ``begin`` to ``end`` - */ - static PyObject *__pyx_pf_6datrie_8AlphaMap_8add_range(struct __pyx_obj_6datrie_AlphaMap *__pyx_v_self, PyObject *__pyx_v_begin, PyObject *__pyx_v_end) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -13877,37 +14957,46 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_8add_range(struct __pyx_obj_6datrie_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_range", 0); - /* "datrie.pyx":940 + /* "datrie.pyx":963 * ``end`` - the last character of the range. * """ * self._add_range(ord(begin), ord(end)) # <<<<<<<<<<<<<< * * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_begin); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_begin); __Pyx_GIVEREF(__pyx_v_begin); - __pyx_t_2 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyInt_from_py_AlphaChar(__pyx_t_2); if (unlikely((__pyx_t_3 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyInt_As_AlphaChar(__pyx_t_2); if (unlikely((__pyx_t_3 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_end); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_end); __Pyx_GIVEREF(__pyx_v_end); - __pyx_t_1 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyInt_from_py_AlphaChar(__pyx_t_1); if (unlikely((__pyx_t_4 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyInt_As_AlphaChar(__pyx_t_1); if (unlikely((__pyx_t_4 == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_t_3, __pyx_t_4, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_t_3, __pyx_t_4, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /* "datrie.pyx":955 + * self._add_range(begin, end) + * + * def add_range(self, begin, end): # <<<<<<<<<<<<<< + * """ + * Add a range of character codes from ``begin`` to ``end`` + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -13921,7 +15010,7 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_8add_range(struct __pyx_obj_6datrie_ return __pyx_r; } -/* "datrie.pyx":942 +/* "datrie.pyx":965 * self._add_range(ord(begin), ord(end)) * * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): # <<<<<<<<<<<<<< @@ -13947,15 +15036,15 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s___add_range); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_add_range_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6datrie_8AlphaMap_11_add_range)) { __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_to_py_AlphaChar(__pyx_v_begin); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_AlphaChar(__pyx_v_begin); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_to_py_AlphaChar(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_AlphaChar(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -13963,9 +15052,9 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A __Pyx_GIVEREF(__pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -13974,7 +15063,7 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "datrie.pyx":943 + /* "datrie.pyx":966 * * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): * if begin > end: # <<<<<<<<<<<<<< @@ -13984,26 +15073,24 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A __pyx_t_5 = ((__pyx_v_begin > __pyx_v_end) != 0); if (__pyx_t_5) { - /* "datrie.pyx":944 + /* "datrie.pyx":967 * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): * if begin > end: * raise DatrieError('range begin > end') # <<<<<<<<<<<<<< * code = cdatrie.alpha_map_add_range(self._c_alpha_map, begin, end) * if code != 0: */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DatrieError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DatrieError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":945 + /* "datrie.pyx":968 * if begin > end: * raise DatrieError('range begin > end') * code = cdatrie.alpha_map_add_range(self._c_alpha_map, begin, end) # <<<<<<<<<<<<<< @@ -14012,7 +15099,7 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A */ __pyx_v_code = alpha_map_add_range(__pyx_v_self->_c_alpha_map, __pyx_v_begin, __pyx_v_end); - /* "datrie.pyx":946 + /* "datrie.pyx":969 * raise DatrieError('range begin > end') * code = cdatrie.alpha_map_add_range(self._c_alpha_map, begin, end) * if code != 0: # <<<<<<<<<<<<<< @@ -14022,18 +15109,25 @@ static PyObject *__pyx_f_6datrie_8AlphaMap__add_range(struct __pyx_obj_6datrie_A __pyx_t_5 = ((__pyx_v_code != 0) != 0); if (__pyx_t_5) { - /* "datrie.pyx":947 + /* "datrie.pyx":970 * code = cdatrie.alpha_map_add_range(self._c_alpha_map, begin, end) * if code != 0: * raise MemoryError() # <<<<<<<<<<<<<< * * cdef cdatrie.AlphaChar* new_alpha_char_from_unicode(unicode txt): */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L4; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L4:; + /* "datrie.pyx":965 + * self._add_range(ord(begin), ord(end)) + * + * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): # <<<<<<<<<<<<<< + * if begin > end: + * raise DatrieError('range begin > end') + */ + + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -14061,7 +15155,7 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_11_add_range(PyObject *__pyx_v_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_add_range (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__begin,&__pyx_n_s__end,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_begin,&__pyx_n_s_end,0}; PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -14075,16 +15169,16 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_11_add_range(PyObject *__pyx_v_self, kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__begin)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_begin)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_add_range", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_add_range", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_range") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_add_range") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -14092,30 +15186,24 @@ static PyObject *__pyx_pw_6datrie_8AlphaMap_11_add_range(PyObject *__pyx_v_self, values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_begin = __Pyx_PyInt_from_py_AlphaChar(values[0]); if (unlikely((__pyx_v_begin == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_end = __Pyx_PyInt_from_py_AlphaChar(values[1]); if (unlikely((__pyx_v_end == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_begin = __Pyx_PyInt_As_AlphaChar(values[0]); if (unlikely((__pyx_v_begin == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_end = __Pyx_PyInt_As_AlphaChar(values[1]); if (unlikely((__pyx_v_end == (AlphaChar)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_add_range", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_add_range", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.AlphaMap._add_range", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6datrie_8AlphaMap_10_add_range(((struct __pyx_obj_6datrie_AlphaMap *)__pyx_v_self), __pyx_v_begin, __pyx_v_end); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":942 - * self._add_range(ord(begin), ord(end)) - * - * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): # <<<<<<<<<<<<<< - * if begin > end: - * raise DatrieError('range begin > end') - */ - static PyObject *__pyx_pf_6datrie_8AlphaMap_10_add_range(struct __pyx_obj_6datrie_AlphaMap *__pyx_v_self, AlphaChar __pyx_v_begin, AlphaChar __pyx_v_end) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -14125,14 +15213,13 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_10_add_range(struct __pyx_obj_6datri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_add_range", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_v_begin, __pyx_v_end, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_6datrie_AlphaMap *)__pyx_v_self->__pyx_vtab)->_add_range(__pyx_v_self, __pyx_v_begin, __pyx_v_end, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datrie.AlphaMap._add_range", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -14143,7 +15230,7 @@ static PyObject *__pyx_pf_6datrie_8AlphaMap_10_add_range(struct __pyx_obj_6datri return __pyx_r; } -/* "datrie.pyx":949 +/* "datrie.pyx":972 * raise MemoryError() * * cdef cdatrie.AlphaChar* new_alpha_char_from_unicode(unicode txt): # <<<<<<<<<<<<<< @@ -14172,21 +15259,21 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("new_alpha_char_from_unicode", 0); - /* "datrie.pyx":956 + /* "datrie.pyx":979 * The caller should free the result of this function. * """ * cdef int txt_len = len(txt) # <<<<<<<<<<<<<< * cdef int size = (txt_len + 1) * sizeof(cdatrie.AlphaChar) * */ - if (unlikely(((PyObject *)__pyx_v_txt) == Py_None)) { + if (unlikely(__pyx_v_txt == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(((PyObject *)__pyx_v_txt)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_txt); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_txt_len = __pyx_t_1; - /* "datrie.pyx":957 + /* "datrie.pyx":980 * """ * cdef int txt_len = len(txt) * cdef int size = (txt_len + 1) * sizeof(cdatrie.AlphaChar) # <<<<<<<<<<<<<< @@ -14195,7 +15282,7 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ __pyx_v_size = ((__pyx_v_txt_len + 1) * (sizeof(AlphaChar))); - /* "datrie.pyx":960 + /* "datrie.pyx":983 * * # allocate buffer * cdef cdatrie.AlphaChar* data = malloc(size) # <<<<<<<<<<<<<< @@ -14204,7 +15291,7 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ __pyx_v_data = ((AlphaChar *)malloc(__pyx_v_size)); - /* "datrie.pyx":961 + /* "datrie.pyx":984 * # allocate buffer * cdef cdatrie.AlphaChar* data = malloc(size) * if data is NULL: # <<<<<<<<<<<<<< @@ -14214,19 +15301,17 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ __pyx_t_2 = ((__pyx_v_data == NULL) != 0); if (__pyx_t_2) { - /* "datrie.pyx":962 + /* "datrie.pyx":985 * cdef cdatrie.AlphaChar* data = malloc(size) * if data is NULL: * raise MemoryError() # <<<<<<<<<<<<<< * * # Copy text contents to buffer. */ - PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; + PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L3:; - /* "datrie.pyx":974 + /* "datrie.pyx":997 * # but the following is much (say 10x) faster and this * # function is really in a hot spot. * cdef int i = 0 # <<<<<<<<<<<<<< @@ -14235,25 +15320,25 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ __pyx_v_i = 0; - /* "datrie.pyx":975 + /* "datrie.pyx":998 * # function is really in a hot spot. * cdef int i = 0 * for char in txt: # <<<<<<<<<<<<<< * data[i] = char * i+=1 */ - if (unlikely(((PyObject *)__pyx_v_txt) == Py_None)) { + if (unlikely(__pyx_v_txt == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_INCREF(((PyObject *)__pyx_v_txt)); + __Pyx_INCREF(__pyx_v_txt); __pyx_t_3 = __pyx_v_txt; - __pyx_t_7 = __Pyx_init_unicode_iteration(((PyObject *)__pyx_t_3), (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_init_unicode_iteration(__pyx_t_3, (&__pyx_t_4), (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8++) { __pyx_t_1 = __pyx_t_8; __pyx_v_char = __Pyx_PyUnicode_READ(__pyx_t_6, __pyx_t_5, __pyx_t_1); - /* "datrie.pyx":976 + /* "datrie.pyx":999 * cdef int i = 0 * for char in txt: * data[i] = char # <<<<<<<<<<<<<< @@ -14262,7 +15347,7 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ (__pyx_v_data[__pyx_v_i]) = ((AlphaChar)__pyx_v_char); - /* "datrie.pyx":977 + /* "datrie.pyx":1000 * for char in txt: * data[i] = char * i+=1 # <<<<<<<<<<<<<< @@ -14271,9 +15356,9 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ __pyx_v_i = (__pyx_v_i + 1); } - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":980 + /* "datrie.pyx":1003 * * # Buffer must be null-terminated (last 4 bytes must be zero). * data[txt_len] = 0 # <<<<<<<<<<<<<< @@ -14282,7 +15367,7 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ */ (__pyx_v_data[__pyx_v_txt_len]) = 0; - /* "datrie.pyx":981 + /* "datrie.pyx":1004 * # Buffer must be null-terminated (last 4 bytes must be zero). * data[txt_len] = 0 * return data # <<<<<<<<<<<<<< @@ -14292,18 +15377,25 @@ static AlphaChar *__pyx_f_6datrie_new_alpha_char_from_unicode(PyObject *__pyx_v_ __pyx_r = __pyx_v_data; goto __pyx_L0; - __pyx_r = 0; - goto __pyx_L0; + /* "datrie.pyx":972 + * raise MemoryError() + * + * cdef cdatrie.AlphaChar* new_alpha_char_from_unicode(unicode txt): # <<<<<<<<<<<<<< + * """ + * Converts Python unicode string to libdatrie's AlphaChar* format. + */ + + /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(((PyObject *)__pyx_t_3)); - __Pyx_WriteUnraisable("datrie.new_alpha_char_from_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("datrie.new_alpha_char_from_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":983 +/* "datrie.pyx":1006 * return data * * cdef unicode unicode_from_alpha_char(cdatrie.AlphaChar* key, int len=0): # <<<<<<<<<<<<<< @@ -14329,7 +15421,7 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, } } - /* "datrie.pyx":987 + /* "datrie.pyx":1010 * Converts libdatrie's AlphaChar* to Python unicode. * """ * cdef int length = len # <<<<<<<<<<<<<< @@ -14338,7 +15430,7 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, */ __pyx_v_length = __pyx_v_len; - /* "datrie.pyx":988 + /* "datrie.pyx":1011 * """ * cdef int length = len * if length == 0: # <<<<<<<<<<<<<< @@ -14348,7 +15440,7 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, __pyx_t_1 = ((__pyx_v_length == 0) != 0); if (__pyx_t_1) { - /* "datrie.pyx":989 + /* "datrie.pyx":1012 * cdef int length = len * if length == 0: * length = cdatrie.alpha_char_strlen(key)*sizeof(cdatrie.AlphaChar) # <<<<<<<<<<<<<< @@ -14360,7 +15452,7 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, } __pyx_L3:; - /* "datrie.pyx":990 + /* "datrie.pyx":1013 * if length == 0: * length = cdatrie.alpha_char_strlen(key)*sizeof(cdatrie.AlphaChar) * cdef char* c_str = key # <<<<<<<<<<<<<< @@ -14369,23 +15461,30 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, */ __pyx_v_c_str = ((char *)__pyx_v_key); - /* "datrie.pyx":991 + /* "datrie.pyx":1014 * length = cdatrie.alpha_char_strlen(key)*sizeof(cdatrie.AlphaChar) * cdef char* c_str = key * return c_str[:length].decode('utf_32_le') # <<<<<<<<<<<<<< * * */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = ((PyObject *)__Pyx_decode_c_string(__pyx_v_c_str, 0, __pyx_v_length, __pyx_k__utf_32_le, NULL, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - if (!(likely(PyUnicode_CheckExact(((PyObject *)__pyx_t_2)))||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(((PyObject *)__pyx_t_2))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_c_str, 0, __pyx_v_length, __pyx_k_utf_32_le, NULL, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":1006 + * return data + * + * cdef unicode unicode_from_alpha_char(cdatrie.AlphaChar* key, int len=0): # <<<<<<<<<<<<<< + * """ + * Converts libdatrie's AlphaChar* to Python unicode. + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("datrie.unicode_from_alpha_char", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -14397,6 +15496,14 @@ static PyObject *__pyx_f_6datrie_unicode_from_alpha_char(AlphaChar *__pyx_v_key, } static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":1017 + * + * + * def to_ranges(lst): # <<<<<<<<<<<<<< + * """ + * Converts a list of numbers to a list of ranges:: + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_1to_ranges(PyObject *__pyx_self, PyObject *__pyx_v_lst); /*proto*/ static char __pyx_doc_6datrie_to_ranges[] = "\n Converts a list of numbers to a list of ranges::\n\n >>> numbers = [1,2,3,5,6]\n >>> list(to_ranges(numbers))\n [(1, 3), (5, 6)]\n "; @@ -14406,10 +15513,20 @@ static PyObject *__pyx_pw_6datrie_1to_ranges(PyObject *__pyx_self, PyObject *__p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_ranges (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_to_ranges(__pyx_self, ((PyObject *)__pyx_v_lst)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } +/* "datrie.pyx":1025 + * [(1, 3), (5, 6)] + * """ + * for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]): # <<<<<<<<<<<<<< + * b = list(b) + * yield b[0][1], b[-1][1] + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_9to_ranges_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_t); /*proto*/ static PyMethodDef __pyx_mdef_6datrie_9to_ranges_lambda1 = {__Pyx_NAMESTR("lambda1"), (PyCFunction)__pyx_pw_6datrie_9to_ranges_lambda1, METH_O, __Pyx_DOCSTR(0)}; @@ -14418,18 +15535,12 @@ static PyObject *__pyx_pw_6datrie_9to_ranges_lambda1(PyObject *__pyx_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0); __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_t)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":1002 - * [(1, 3), (5, 6)] - * """ - * for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]): # <<<<<<<<<<<<<< - * b = list(b) - * yield b[0][1], b[-1][1] - */ - static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_t) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -14441,11 +15552,11 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self int __pyx_clineno = 0; __Pyx_RefNannySetupContext("lambda1", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -14453,8 +15564,7 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -14467,7 +15577,7 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "datrie.pyx":994 +/* "datrie.pyx":1017 * * * def to_ranges(lst): # <<<<<<<<<<<<<< @@ -14493,12 +15603,13 @@ static PyObject *__pyx_pf_6datrie_to_ranges(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_INCREF(__pyx_cur_scope->__pyx_v_lst); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_lst); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_2generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_2generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -14536,31 +15647,31 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":1002 + /* "datrie.pyx":1025 * [(1, 3), (5, 6)] * """ * for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]): # <<<<<<<<<<<<<< * b = list(b) * yield b[0][1], b[-1][1] */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__itertools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_itertools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__groupby); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_groupby); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_lst); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_lst); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_lst); - __pyx_t_3 = PyObject_Call(__pyx_builtin_enumerate, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_enumerate, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6datrie_9to_ranges_lambda1, 0, __pyx_n_s_23, NULL, __pyx_n_s__datrie, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6datrie_9to_ranges_lambda1, 0, __pyx_n_s_to_ranges_locals_lambda, NULL, __pyx_n_s_datrie, PyModule_GetDict(__pyx_m), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -14568,15 +15679,15 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_GIVEREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { - __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -14585,23 +15696,24 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) { if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_1)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -14617,7 +15729,7 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -14630,16 +15742,15 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - { + } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -14647,7 +15758,7 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; @@ -14655,59 +15766,56 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_a); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_a); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_a, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_a = __pyx_t_2; __pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_b); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_b); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_b, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_b = __pyx_t_3; __pyx_t_3 = 0; - /* "datrie.pyx":1003 + /* "datrie.pyx":1026 * """ * for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]): * b = list(b) # <<<<<<<<<<<<<< * yield b[0][1], b[-1][1] * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_b); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_b); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_b); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_b); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_b); + __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_b, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_b = __pyx_t_3; __pyx_t_3 = 0; - /* "datrie.pyx":1004 + /* "datrie.pyx":1027 * for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]): * b = list(b) * yield b[0][1], b[-1][1] # <<<<<<<<<<<<<< * * def alphabet_to_ranges(alphabet): */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_b, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_b, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_b, -1, sizeof(long), PyInt_FromLong, 0, 1, 1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_b, -1, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -14715,7 +15823,7 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_r = ((PyObject *)__pyx_t_3); + __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_t_4); __pyx_cur_scope->__pyx_t_0 = __pyx_t_4; @@ -14732,9 +15840,19 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener __Pyx_XGOTREF(__pyx_t_4); __pyx_t_5 = __pyx_cur_scope->__pyx_t_1; __pyx_t_6 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "datrie.pyx":1017 + * + * + * def to_ranges(lst): # <<<<<<<<<<<<<< + * """ + * Converts a list of numbers to a list of ranges:: + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -14753,6 +15871,14 @@ static PyObject *__pyx_gb_6datrie_2generator5(__pyx_GeneratorObject *__pyx_gener } static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +/* "datrie.pyx":1029 + * yield b[0][1], b[-1][1] + * + * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< + * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): + * yield begin, end + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_4alphabet_to_ranges(PyObject *__pyx_self, PyObject *__pyx_v_alphabet); /*proto*/ static PyMethodDef __pyx_mdef_6datrie_4alphabet_to_ranges = {__Pyx_NAMESTR("alphabet_to_ranges"), (PyCFunction)__pyx_pw_6datrie_4alphabet_to_ranges, METH_O, __Pyx_DOCSTR(0)}; @@ -14761,18 +15887,12 @@ static PyObject *__pyx_pw_6datrie_4alphabet_to_ranges(PyObject *__pyx_self, PyOb __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("alphabet_to_ranges (wrapper)", 0); __pyx_r = __pyx_pf_6datrie_3alphabet_to_ranges(__pyx_self, ((PyObject *)__pyx_v_alphabet)); + + /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "datrie.pyx":1006 - * yield b[0][1], b[-1][1] - * - * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< - * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): - * yield begin, end - */ - static PyObject *__pyx_pf_6datrie_3alphabet_to_ranges(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_alphabet) { struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *__pyx_cur_scope; PyObject *__pyx_r = NULL; @@ -14791,12 +15911,13 @@ static PyObject *__pyx_pf_6datrie_3alphabet_to_ranges(CYTHON_UNUSED PyObject *__ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_alphabet); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alphabet); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_5generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_6datrie_5generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } + /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; @@ -14834,20 +15955,20 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":1007 + /* "datrie.pyx":1030 * * def alphabet_to_ranges(alphabet): * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): # <<<<<<<<<<<<<< * yield begin, end * */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__to_ranges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_to_ranges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_alphabet); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_alphabet); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_builtin_ord); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_ord); @@ -14855,31 +15976,31 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; } @@ -14888,23 +16009,24 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -14920,7 +16042,7 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -14933,16 +16055,15 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - { + } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -14950,7 +16071,7 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; @@ -14958,28 +16079,26 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_begin); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_begin); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_begin, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); - __pyx_cur_scope->__pyx_v_begin = __pyx_t_1; __pyx_t_1 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_end); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); - __pyx_cur_scope->__pyx_v_end = __pyx_t_6; __pyx_t_6 = 0; - /* "datrie.pyx":1008 + /* "datrie.pyx":1031 * def alphabet_to_ranges(alphabet): * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): * yield begin, end # <<<<<<<<<<<<<< * * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): */ - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_begin); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_begin); @@ -14987,7 +16106,7 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_cur_scope->__pyx_v_end); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end); - __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_XGIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_t_0 = __pyx_t_3; @@ -15004,9 +16123,19 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener __Pyx_XGOTREF(__pyx_t_3); __pyx_t_4 = __pyx_cur_scope->__pyx_t_1; __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "datrie.pyx":1029 + * yield b[0][1], b[-1][1] + * + * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< + * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): + * yield begin, end + */ + + /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -15024,6 +16153,14 @@ static PyObject *__pyx_gb_6datrie_5generator6(__pyx_GeneratorObject *__pyx_gener return NULL; } +/* "datrie.pyx":1033 + * yield begin, end + * + * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): # <<<<<<<<<<<<<< + * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) + * return Trie(alphabet, ranges, alpha_map) + */ + /* Python wrapper */ static PyObject *__pyx_pw_6datrie_7new(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_6datrie_7new = {__Pyx_NAMESTR("new"), (PyCFunction)__pyx_pw_6datrie_7new, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}; @@ -15038,16 +16175,8 @@ static PyObject *__pyx_pw_6datrie_7new(PyObject *__pyx_self, PyObject *__pyx_arg __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("new (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alphabet,&__pyx_n_s__ranges,&__pyx_n_s__alpha_map,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alphabet,&__pyx_n_s_ranges,&__pyx_n_s_alpha_map,0}; PyObject* values[3] = {0,0,0}; - - /* "datrie.pyx":1010 - * yield begin, end - * - * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): # <<<<<<<<<<<<<< - * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) - * return Trie(alphabet, ranges, alpha_map) - */ values[0] = ((PyObject *)Py_None); values[1] = ((PyObject *)Py_None); values[2] = (PyObject *)((struct __pyx_obj_6datrie_AlphaMap *)Py_None); @@ -15065,22 +16194,22 @@ static PyObject *__pyx_pw_6datrie_7new(PyObject *__pyx_self, PyObject *__pyx_arg switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alphabet); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ranges); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ranges); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alpha_map); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha_map); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "new") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "new") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -15097,14 +16226,16 @@ static PyObject *__pyx_pw_6datrie_7new(PyObject *__pyx_self, PyObject *__pyx_arg } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("new", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("new", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("datrie.new", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alpha_map), __pyx_ptype_6datrie_AlphaMap, 1, "alpha_map", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alpha_map), __pyx_ptype_6datrie_AlphaMap, 1, "alpha_map", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_6datrie_6new(__pyx_self, __pyx_v_alphabet, __pyx_v_ranges, __pyx_v_alpha_map); + + /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -15124,40 +16255,40 @@ static PyObject *__pyx_pf_6datrie_6new(CYTHON_UNUSED PyObject *__pyx_self, PyObj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("new", 0); - /* "datrie.pyx":1011 + /* "datrie.pyx":1034 * * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) # <<<<<<<<<<<<<< * return Trie(alphabet, ranges, alpha_map) * */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__warnings); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_24)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24)); + __Pyx_INCREF(__pyx_kp_s_datrie_new_is_deprecated_please); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_datrie_new_is_deprecated_please); + __Pyx_GIVEREF(__pyx_kp_s_datrie_new_is_deprecated_please); __Pyx_INCREF(__pyx_builtin_DeprecationWarning); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_builtin_DeprecationWarning); __Pyx_GIVEREF(__pyx_builtin_DeprecationWarning); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "datrie.pyx":1012 + /* "datrie.pyx":1035 * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) * return Trie(alphabet, ranges, alpha_map) # <<<<<<<<<<<<<< * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_alphabet); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_alphabet); @@ -15168,15 +16299,22 @@ static PyObject *__pyx_pf_6datrie_6new(CYTHON_UNUSED PyObject *__pyx_self, PyObj __Pyx_INCREF(((PyObject *)__pyx_v_alpha_map)); PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_alpha_map)); __Pyx_GIVEREF(((PyObject *)__pyx_v_alpha_map)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6datrie_Trie)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; + /* "datrie.pyx":1033 + * yield begin, end + * + * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): # <<<<<<<<<<<<<< + * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) + * return Trie(alphabet, ranges, alpha_map) + */ + + /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); @@ -15188,142 +16326,105 @@ static PyObject *__pyx_pf_6datrie_6new(CYTHON_UNUSED PyObject *__pyx_self, PyObj __Pyx_RefNannyFinishContext(); return __pyx_r; } -static struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_vtable_6datrie__TrieIterator; +static struct __pyx_vtabstruct_6datrie_BaseTrie __pyx_vtable_6datrie_BaseTrie; -static PyObject *__pyx_tp_new_6datrie__TrieIterator(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_6datrie__TrieIterator *p; +static PyObject *__pyx_tp_new_6datrie_BaseTrie(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_6datrie_BaseTrie *p; PyObject *o; - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie__TrieIterator *)o); - p->__pyx_vtab = __pyx_vtabptr_6datrie__TrieIterator; - p->_root = ((struct __pyx_obj_6datrie__TrieState *)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_pw_6datrie_13_TrieIterator_1__cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie_BaseTrie *)o); + p->__pyx_vtab = __pyx_vtabptr_6datrie_BaseTrie; return o; } -static void __pyx_tp_dealloc_6datrie__TrieIterator(PyObject *o) { - struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; - PyObject_GC_UnTrack(o); +static void __pyx_tp_dealloc_6datrie_BaseTrie(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); - __pyx_pw_6datrie_13_TrieIterator_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + __pyx_pw_6datrie_8BaseTrie_3__dealloc__(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } - Py_CLEAR(p->_root); (*Py_TYPE(o)->tp_free)(o); } - -static int __pyx_tp_traverse_6datrie__TrieIterator(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; - if (p->_root) { - e = (*v)(((PyObject*)p->_root), a); if (e) return e; - } - return 0; +static PyObject *__pyx_sq_item_6datrie_BaseTrie(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; } -static int __pyx_tp_clear_6datrie__TrieIterator(PyObject *o) { - struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; - PyObject* tmp; - tmp = ((PyObject*)p->_root); - p->_root = ((struct __pyx_obj_6datrie__TrieState *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; +static int __pyx_mp_ass_subscript_6datrie_BaseTrie(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_6datrie_8BaseTrie_15__setitem__(o, i, v); + } + else { + return __pyx_pw_6datrie_8BaseTrie_21__delitem__(o, i); + } } -static PyMethodDef __pyx_methods_6datrie__TrieIterator[] = { - {__Pyx_NAMESTR("next"), (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_5next, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("key"), (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_7key, METH_NOARGS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_6datrie_BaseTrie[] = { + {__Pyx_NAMESTR("is_dirty"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_5is_dirty, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_4is_dirty)}, + {__Pyx_NAMESTR("save"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_7save, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_6save)}, + {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_9write, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_8write)}, + {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_11load, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_10load)}, + {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_13read, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_12read)}, + {__Pyx_NAMESTR("_delitem"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_23_delitem, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_22_delitem)}, + {__Pyx_NAMESTR("setdefault"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_27setdefault, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("iter_prefixes"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_29iter_prefixes, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_28iter_prefixes)}, + {__Pyx_NAMESTR("iter_prefix_items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_32iter_prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_31iter_prefix_items)}, + {__Pyx_NAMESTR("iter_prefix_values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_35iter_prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_34iter_prefix_values)}, + {__Pyx_NAMESTR("prefixes"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_38prefixes, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_37prefixes)}, + {__Pyx_NAMESTR("suffixes"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_40suffixes, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_39suffixes)}, + {__Pyx_NAMESTR("prefix_items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_42prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_41prefix_items)}, + {__Pyx_NAMESTR("prefix_values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_44prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_43prefix_values)}, + {__Pyx_NAMESTR("longest_prefix"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_46longest_prefix, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_45longest_prefix)}, + {__Pyx_NAMESTR("longest_prefix_item"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_48longest_prefix_item, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_47longest_prefix_item)}, + {__Pyx_NAMESTR("longest_prefix_value"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_50longest_prefix_value, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_49longest_prefix_value)}, + {__Pyx_NAMESTR("has_keys_with_prefix"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_52has_keys_with_prefix, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_51has_keys_with_prefix)}, + {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_54items, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_53items)}, + {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_56keys, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_55keys)}, + {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_58values, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_57values)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie__TrieIterator = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie._TrieIterator"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie__TrieIterator), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ - __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_6datrie__TrieIterator, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_6datrie__TrieIterator, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif -}; -static struct __pyx_vtabstruct_6datrie_Iterator __pyx_vtable_6datrie_Iterator; - -static PyObject *__pyx_tp_new_6datrie_Iterator(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_6datrie_Iterator *p; - PyObject *o = __pyx_tp_new_6datrie__TrieIterator(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_Iterator *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieIterator*)__pyx_vtabptr_6datrie_Iterator; - if (unlikely(__pyx_pw_6datrie_8Iterator_1__cinit__(o, a, k) < 0)) { - Py_DECREF(o); o = 0; - } - return o; -} +static PySequenceMethods __pyx_tp_as_sequence_BaseTrie = { + __pyx_pw_6datrie_8BaseTrie_25__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_6datrie_BaseTrie, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + __pyx_pw_6datrie_8BaseTrie_19__contains__, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; -static PyMethodDef __pyx_methods_6datrie_Iterator[] = { - {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_8Iterator_3data, METH_NOARGS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} +static PyMappingMethods __pyx_tp_as_mapping_BaseTrie = { + __pyx_pw_6datrie_8BaseTrie_25__len__, /*mp_length*/ + __pyx_pw_6datrie_8BaseTrie_17__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_6datrie_BaseTrie, /*mp_ass_subscript*/ }; -static PyTypeObject __pyx_type_6datrie_Iterator = { +static PyTypeObject __pyx_type_6datrie_BaseTrie = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.Iterator"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_Iterator), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.BaseTrie"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_BaseTrie), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie_BaseTrie, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -15334,23 +16435,23 @@ static PyTypeObject __pyx_type_6datrie_Iterator = { #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ + &__pyx_tp_as_sequence_BaseTrie, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_BaseTrie, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("\n cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie\n traversal.\n "), /*tp_doc*/ - __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ - __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + __Pyx_DOCSTR("\n Wrapper for libdatrie's trie.\n\n Keys are unicode strings, values are integers -2147483648 <= x <= 2147483647.\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie_Iterator, /*tp_methods*/ + __pyx_methods_6datrie_BaseTrie, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -15358,9 +16459,9 @@ static PyTypeObject __pyx_type_6datrie_Iterator = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_6datrie_8BaseTrie_1__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_Iterator, /*tp_new*/ + __pyx_tp_new_6datrie_BaseTrie, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -15372,48 +16473,126 @@ static PyTypeObject __pyx_type_6datrie_Iterator = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_vtabstruct_6datrie_AlphaMap __pyx_vtable_6datrie_AlphaMap; +static struct __pyx_vtabstruct_6datrie_Trie __pyx_vtable_6datrie_Trie; -static PyObject *__pyx_tp_new_6datrie_AlphaMap(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie_AlphaMap *p; - PyObject *o; - o = (*t->tp_alloc)(t, 0); +static PyObject *__pyx_tp_new_6datrie_Trie(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6datrie_Trie *p; + PyObject *o = __pyx_tp_new_6datrie_BaseTrie(t, a, k); if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_AlphaMap *)o); - p->__pyx_vtab = __pyx_vtabptr_6datrie_AlphaMap; - if (unlikely(__pyx_pw_6datrie_8AlphaMap_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_6datrie_Trie *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie_BaseTrie*)__pyx_vtabptr_6datrie_Trie; + p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_6datrie_AlphaMap(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_6datrie_8AlphaMap_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); +static void __pyx_tp_dealloc_6datrie_Trie(PyObject *o) { + struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; } - (*Py_TYPE(o)->tp_free)(o); + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->_values); + #if CYTHON_COMPILING_IN_CPYTHON + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_6datrie_BaseTrie(o); } -static PyMethodDef __pyx_methods_6datrie_AlphaMap[] = { - {__Pyx_NAMESTR("add_alphabet"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_7add_alphabet, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8AlphaMap_6add_alphabet)}, - {__Pyx_NAMESTR("add_range"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_9add_range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8AlphaMap_8add_range)}, - {__Pyx_NAMESTR("_add_range"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_11_add_range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_6datrie_Trie(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; + e = ((likely(__pyx_ptype_6datrie_BaseTrie)) ? ((__pyx_ptype_6datrie_BaseTrie->tp_traverse) ? __pyx_ptype_6datrie_BaseTrie->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6datrie_Trie)); if (e) return e; + if (p->_values) { + e = (*v)(p->_values, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6datrie_Trie(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; + if (likely(__pyx_ptype_6datrie_BaseTrie)) { if (__pyx_ptype_6datrie_BaseTrie->tp_clear) __pyx_ptype_6datrie_BaseTrie->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6datrie_Trie); + tmp = ((PyObject*)p->_values); + p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_6datrie_Trie(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_6datrie_Trie(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_6datrie_4Trie_5__setitem__(o, i, v); + } + else { + return __pyx_pw_6datrie_4Trie_9__delitem__(o, i); + } +} + +static PyMethodDef __pyx_methods_6datrie_Trie[] = { + {__Pyx_NAMESTR("setdefault"), (PyCFunction)__pyx_pw_6datrie_4Trie_7setdefault, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_6datrie_4Trie_11write, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_10write)}, + {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_6datrie_4Trie_13read, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_12read)}, + {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_6datrie_4Trie_15items, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_14items)}, + {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pw_6datrie_4Trie_17values, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_16values)}, + {__Pyx_NAMESTR("longest_prefix_item"), (PyCFunction)__pyx_pw_6datrie_4Trie_19longest_prefix_item, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_18longest_prefix_item)}, + {__Pyx_NAMESTR("longest_prefix_value"), (PyCFunction)__pyx_pw_6datrie_4Trie_21longest_prefix_value, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_20longest_prefix_value)}, + {__Pyx_NAMESTR("prefix_items"), (PyCFunction)__pyx_pw_6datrie_4Trie_23prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_22prefix_items)}, + {__Pyx_NAMESTR("iter_prefix_items"), (PyCFunction)__pyx_pw_6datrie_4Trie_25iter_prefix_items, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("prefix_values"), (PyCFunction)__pyx_pw_6datrie_4Trie_28prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_27prefix_values)}, + {__Pyx_NAMESTR("iter_prefix_values"), (PyCFunction)__pyx_pw_6datrie_4Trie_30iter_prefix_values, METH_O, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie_AlphaMap = { +static PySequenceMethods __pyx_tp_as_sequence_Trie = { + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6datrie_8BaseTrie_25__len__, /*sq_length*/ + #else + 0, /*sq_length*/ + #endif + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_6datrie_Trie, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6datrie_8BaseTrie_19__contains__, /*sq_contains*/ + #else + 0, /*sq_contains*/ + #endif + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_Trie = { + #if CYTHON_COMPILING_IN_PYPY + __pyx_pw_6datrie_8BaseTrie_25__len__, /*mp_length*/ + #else + 0, /*mp_length*/ + #endif + __pyx_pw_6datrie_4Trie_3__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_6datrie_Trie, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_6datrie_Trie = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.AlphaMap"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_AlphaMap), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.Trie"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_Trie), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie_AlphaMap, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie_Trie, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -15424,23 +16603,23 @@ static PyTypeObject __pyx_type_6datrie_AlphaMap = { #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ + &__pyx_tp_as_sequence_Trie, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Trie, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - __Pyx_DOCSTR("\n Alphabet map.\n\n For sparse data compactness, the trie alphabet set should\n be continuous, but that is usually not the case in general\n character sets. Therefore, a map between the input character\n and the low-level alphabet set for the trie is created in the\n middle. You will have to define your input character set by\n listing their continuous ranges of character codes creating a\n trie. Then, each character will be automatically assigned\n internal codes of continuous values.\n "), /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("\n Wrapper for libdatrie's trie.\n Keys are unicode strings, values are Python objects.\n "), /*tp_doc*/ + __pyx_tp_traverse_6datrie_Trie, /*tp_traverse*/ + __pyx_tp_clear_6datrie_Trie, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie_AlphaMap, /*tp_methods*/ + __pyx_methods_6datrie_Trie, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -15448,9 +16627,9 @@ static PyTypeObject __pyx_type_6datrie_AlphaMap = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_pw_6datrie_8AlphaMap_5__init__, /*tp_init*/ + __pyx_pw_6datrie_4Trie_1__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_AlphaMap, /*tp_new*/ + __pyx_tp_new_6datrie_Trie, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -15462,13 +16641,20 @@ static PyTypeObject __pyx_type_6datrie_AlphaMap = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; static struct __pyx_vtabstruct_6datrie__TrieState __pyx_vtable_6datrie__TrieState; static PyObject *__pyx_tp_new_6datrie__TrieState(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_6datrie__TrieState *p; PyObject *o; - o = (*t->tp_alloc)(t, 0); + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } if (unlikely(!o)) return 0; p = ((struct __pyx_obj_6datrie__TrieState *)o); p->__pyx_vtab = __pyx_vtabptr_6datrie__TrieState; @@ -15481,13 +16667,17 @@ static PyObject *__pyx_tp_new_6datrie__TrieState(PyTypeObject *t, PyObject *a, P static void __pyx_tp_dealloc_6datrie__TrieState(PyObject *o) { struct __pyx_obj_6datrie__TrieState *p = (struct __pyx_obj_6datrie__TrieState *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif PyObject_GC_UnTrack(o); { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); __pyx_pw_6datrie_10_TrieState_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } @@ -15504,30 +16694,104 @@ static int __pyx_tp_traverse_6datrie__TrieState(PyObject *o, visitproc v, void * return 0; } -static int __pyx_tp_clear_6datrie__TrieState(PyObject *o) { - struct __pyx_obj_6datrie__TrieState *p = (struct __pyx_obj_6datrie__TrieState *)o; - PyObject* tmp; - tmp = ((PyObject*)p->_trie); - p->_trie = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; +static int __pyx_tp_clear_6datrie__TrieState(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6datrie__TrieState *p = (struct __pyx_obj_6datrie__TrieState *)o; + tmp = ((PyObject*)p->_trie); + p->_trie = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_6datrie__TrieState[] = { + {__Pyx_NAMESTR("walk"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_5walk, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("copy_to"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_7copy_to, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_10_TrieState_6copy_to)}, + {__Pyx_NAMESTR("rewind"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_9rewind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6datrie_10_TrieState_8rewind)}, + {__Pyx_NAMESTR("is_terminal"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_11is_terminal, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("is_single"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_13is_single, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("is_leaf"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_15is_leaf, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__unicode__"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_17__unicode__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_6datrie__TrieState = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("datrie._TrieState"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie__TrieState), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6datrie__TrieState, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + __pyx_pw_6datrie_10_TrieState_19__repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6datrie__TrieState, /*tp_traverse*/ + __pyx_tp_clear_6datrie__TrieState, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6datrie__TrieState, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6datrie__TrieState, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_6datrie_BaseState __pyx_vtable_6datrie_BaseState; + +static PyObject *__pyx_tp_new_6datrie_BaseState(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6datrie_BaseState *p; + PyObject *o = __pyx_tp_new_6datrie__TrieState(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie_BaseState *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieState*)__pyx_vtabptr_6datrie_BaseState; + return o; } -static PyMethodDef __pyx_methods_6datrie__TrieState[] = { - {__Pyx_NAMESTR("walk"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_5walk, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("copy_to"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_7copy_to, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_10_TrieState_6copy_to)}, - {__Pyx_NAMESTR("rewind"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_9rewind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6datrie_10_TrieState_8rewind)}, - {__Pyx_NAMESTR("is_terminal"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_11is_terminal, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("is_single"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_13is_single, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("is_leaf"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_15is_leaf, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("__unicode__"), (PyCFunction)__pyx_pw_6datrie_10_TrieState_17__unicode__, METH_NOARGS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_6datrie_BaseState[] = { + {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_9BaseState_1data, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie__TrieState = { +static PyTypeObject __pyx_type_6datrie_BaseState = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie._TrieState"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie__TrieState), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.BaseState"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_BaseState), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_6datrie__TrieState, /*tp_dealloc*/ 0, /*tp_print*/ @@ -15538,7 +16802,11 @@ static PyTypeObject __pyx_type_6datrie__TrieState = { #else 0, /*reserved*/ #endif + #if CYTHON_COMPILING_IN_PYPY __pyx_pw_6datrie_10_TrieState_19__repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -15549,14 +16817,14 @@ static PyTypeObject __pyx_type_6datrie__TrieState = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + __Pyx_DOCSTR("\n cdatrie.TrieState wrapper. It can be used for custom trie traversal.\n "), /*tp_doc*/ __pyx_tp_traverse_6datrie__TrieState, /*tp_traverse*/ __pyx_tp_clear_6datrie__TrieState, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie__TrieState, /*tp_methods*/ + __pyx_methods_6datrie_BaseState, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -15566,7 +16834,7 @@ static PyTypeObject __pyx_type_6datrie__TrieState = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie__TrieState, /*tp_new*/ + __pyx_tp_new_6datrie_BaseState, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -15578,6 +16846,9 @@ static PyTypeObject __pyx_type_6datrie__TrieState = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; static struct __pyx_vtabstruct_6datrie_State __pyx_vtable_6datrie_State; @@ -15656,99 +16927,80 @@ static PyTypeObject __pyx_type_6datrie_State = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; +static struct __pyx_vtabstruct_6datrie__TrieIterator __pyx_vtable_6datrie__TrieIterator; -static struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *__pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items = 0; - -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p; +static PyObject *__pyx_tp_new_6datrie__TrieIterator(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6datrie__TrieIterator *p; PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[--__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items)); - PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie__TrieIterator *)o); + p->__pyx_vtab = __pyx_vtabptr_6datrie__TrieIterator; + p->_root = ((struct __pyx_obj_6datrie__TrieState *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_6datrie_13_TrieIterator_1__cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o); - p->__pyx_v_k = 0; - p->__pyx_v_key = 0; - p->__pyx_v_self = 0; - p->__pyx_v_v = 0; - p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; +static void __pyx_tp_dealloc_6datrie__TrieIterator(PyObject *o) { + struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_k); - Py_CLEAR(p->__pyx_v_key); - Py_CLEAR(p->__pyx_v_self); - Py_CLEAR(p->__pyx_v_v); - Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items))) { - __pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_6datrie_13_TrieIterator_3__dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); } + Py_CLEAR(p->_root); + (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6datrie__TrieIterator(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; - if (p->__pyx_v_k) { - e = (*v)(p->__pyx_v_k, a); if (e) return e; - } - if (p->__pyx_v_key) { - e = (*v)(p->__pyx_v_key, a); if (e) return e; - } - if (p->__pyx_v_self) { - e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; - } - if (p->__pyx_v_v) { - e = (*v)(p->__pyx_v_v, a); if (e) return e; - } - if (p->__pyx_t_0) { - e = (*v)(p->__pyx_t_0, a); if (e) return e; + struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; + if (p->_root) { + e = (*v)(((PyObject*)p->_root), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; +static int __pyx_tp_clear_6datrie__TrieIterator(PyObject *o) { PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_k); - p->__pyx_v_k = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_key); - p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_6datrie_Trie *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_v); - p->__pyx_v_v = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_t_0); - p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); + struct __pyx_obj_6datrie__TrieIterator *p = (struct __pyx_obj_6datrie__TrieIterator *)o; + tmp = ((PyObject*)p->_root); + p->_root = ((struct __pyx_obj_6datrie__TrieState *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_3_iter_prefix_items[] = { +static PyMethodDef __pyx_methods_6datrie__TrieIterator[] = { + {__Pyx_NAMESTR("next"), (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_5next, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("key"), (PyCFunction)__pyx_pw_6datrie_13_TrieIterator_7key, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items = { +static PyTypeObject __pyx_type_6datrie__TrieIterator = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct_3_iter_prefix_items"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie._TrieIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie__TrieIterator), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -15767,15 +17019,15 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items = 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_clear*/ + __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ + __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_methods*/ + __pyx_methods_6datrie__TrieIterator, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -15785,7 +17037,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items = 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_new*/ + __pyx_tp_new_6datrie__TrieIterator, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -15797,91 +17049,109 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items = #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; +static struct __pyx_vtabstruct_6datrie_BaseIterator __pyx_vtable_6datrie_BaseIterator; -static struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *__pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values = 0; - -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p; - PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[--__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values)); - PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o); - p->__pyx_v_key = 0; - p->__pyx_v_self = 0; - p->__pyx_v_v = 0; - p->__pyx_t_0 = 0; +static PyObject *__pyx_tp_new_6datrie_BaseIterator(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6datrie_BaseIterator *p; + PyObject *o = __pyx_tp_new_6datrie__TrieIterator(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie_BaseIterator *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieIterator*)__pyx_vtabptr_6datrie_BaseIterator; return o; } -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_key); - Py_CLEAR(p->__pyx_v_self); - Py_CLEAR(p->__pyx_v_v); - Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values))) { - __pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} +static PyMethodDef __pyx_methods_6datrie_BaseIterator[] = { + {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_12BaseIterator_1data, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; -static int __pyx_tp_traverse_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; - if (p->__pyx_v_key) { - e = (*v)(p->__pyx_v_key, a); if (e) return e; - } - if (p->__pyx_v_self) { - e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; - } - if (p->__pyx_v_v) { - e = (*v)(p->__pyx_v_v, a); if (e) return e; - } - if (p->__pyx_t_0) { - e = (*v)(p->__pyx_t_0, a); if (e) return e; - } - return 0; -} +static PyTypeObject __pyx_type_6datrie_BaseIterator = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("datrie.BaseIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_BaseIterator), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("\n cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie\n traversal.\n "), /*tp_doc*/ + __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ + __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6datrie_BaseIterator, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6datrie_BaseIterator, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_6datrie_Iterator __pyx_vtable_6datrie_Iterator; -static int __pyx_tp_clear_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; - PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_key); - p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_6datrie_Trie *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_v); - p->__pyx_v_v = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_t_0); - p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; +static PyObject *__pyx_tp_new_6datrie_Iterator(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_6datrie_Iterator *p; + PyObject *o = __pyx_tp_new_6datrie__TrieIterator(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie_Iterator *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieIterator*)__pyx_vtabptr_6datrie_Iterator; + if (unlikely(__pyx_pw_6datrie_8Iterator_1__cinit__(o, a, k) < 0)) { + Py_DECREF(o); o = 0; + } + return o; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_4_iter_prefix_values[] = { +static PyMethodDef __pyx_methods_6datrie_Iterator[] = { + {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_8Iterator_3data, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values = { +static PyTypeObject __pyx_type_6datrie_Iterator = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct_4_iter_prefix_values"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.Iterator"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_Iterator), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -15900,15 +17170,15 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values = 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + __Pyx_DOCSTR("\n cdatrie.TrieIterator wrapper. It can be used for custom datrie.Trie\n traversal.\n "), /*tp_doc*/ + __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ + __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_methods*/ + __pyx_methods_6datrie_Iterator, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -15918,7 +17188,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values = 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_new*/ + __pyx_tp_new_6datrie_Iterator, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -15930,83 +17200,59 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values = #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; +static struct __pyx_vtabstruct_6datrie_AlphaMap __pyx_vtable_6datrie_AlphaMap; -static struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *__pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values = 0; - -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p; +static PyObject *__pyx_tp_new_6datrie_AlphaMap(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_6datrie_AlphaMap *p; PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[--__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values)); - PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o); - p->__pyx_v_key = 0; - p->__pyx_v_self = 0; - p->__pyx_t_0 = 0; - return o; -} - -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_key); - Py_CLEAR(p->__pyx_v_self); - Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values))) { - __pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o); } else { - (*Py_TYPE(o)->tp_free)(o); + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_6datrie_AlphaMap *)o); + p->__pyx_vtab = __pyx_vtabptr_6datrie_AlphaMap; + if (unlikely(__pyx_pw_6datrie_8AlphaMap_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) { + Py_DECREF(o); o = 0; } + return o; } -static int __pyx_tp_traverse_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; - if (p->__pyx_v_key) { - e = (*v)(p->__pyx_v_key, a); if (e) return e; - } - if (p->__pyx_v_self) { - e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; +static void __pyx_tp_dealloc_6datrie_AlphaMap(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; } - if (p->__pyx_t_0) { - e = (*v)(p->__pyx_t_0, a); if (e) return e; + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_6datrie_8AlphaMap_3__dealloc__(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); } - return 0; -} - -static int __pyx_tp_clear_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; - PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_key); - p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_t_0); - p->__pyx_t_0 = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; + (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_2_iter_prefix_values[] = { +static PyMethodDef __pyx_methods_6datrie_AlphaMap[] = { + {__Pyx_NAMESTR("add_alphabet"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_7add_alphabet, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8AlphaMap_6add_alphabet)}, + {__Pyx_NAMESTR("add_range"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_9add_range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8AlphaMap_8add_range)}, + {__Pyx_NAMESTR("_add_range"), (PyCFunction)__pyx_pw_6datrie_8AlphaMap_11_add_range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values = { +static PyTypeObject __pyx_type_6datrie_AlphaMap = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct_2_iter_prefix_values"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.AlphaMap"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie_AlphaMap), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie_AlphaMap, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16025,15 +17271,15 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values = 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + __Pyx_DOCSTR("\n Alphabet map.\n\n For sparse data compactness, the trie alphabet set should\n be continuous, but that is usually not the case in general\n character sets. Therefore, a map between the input character\n and the low-level alphabet set for the trie is created in the\n middle. You will have to define your input character set by\n listing their continuous ranges of character codes creating a\n trie. Then, each character will be automatically assigned\n internal codes of continuous values.\n "), /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_methods*/ + __pyx_methods_6datrie_AlphaMap, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16041,9 +17287,9 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values = 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_6datrie_8AlphaMap_5__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_new*/ + __pyx_tp_new_6datrie_AlphaMap, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16055,97 +17301,65 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values = #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_vtabstruct_6datrie_BaseTrie __pyx_vtable_6datrie_BaseTrie; -static PyObject *__pyx_tp_new_6datrie_BaseTrie(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie_BaseTrie *p; +static struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *__pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes = 0; + +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct__iter_prefixes(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_BaseTrie *)o); - p->__pyx_vtab = __pyx_vtabptr_6datrie_BaseTrie; + if (likely((__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[--__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } return o; } -static void __pyx_tp_dealloc_6datrie_BaseTrie(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_6datrie_8BaseTrie_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_key); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_t_0); + if ((__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes))) { + __pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes++] = ((struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); } - (*Py_TYPE(o)->tp_free)(o); -} -static PyObject *__pyx_sq_item_6datrie_BaseTrie(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; } -static int __pyx_mp_ass_subscript_6datrie_BaseTrie(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_pw_6datrie_8BaseTrie_15__setitem__(o, i, v); - } - else { - return __pyx_pw_6datrie_8BaseTrie_21__delitem__(o, i); +static int __pyx_tp_traverse_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } + return 0; } -static PyMethodDef __pyx_methods_6datrie_BaseTrie[] = { - {__Pyx_NAMESTR("is_dirty"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_5is_dirty, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_4is_dirty)}, - {__Pyx_NAMESTR("save"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_7save, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_6save)}, - {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_9write, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_8write)}, - {__Pyx_NAMESTR("load"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_11load, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_10load)}, - {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_13read, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_12read)}, - {__Pyx_NAMESTR("_delitem"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_23_delitem, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_22_delitem)}, - {__Pyx_NAMESTR("setdefault"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_27setdefault, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("iter_prefixes"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_29iter_prefixes, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_28iter_prefixes)}, - {__Pyx_NAMESTR("iter_prefix_items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_32iter_prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_31iter_prefix_items)}, - {__Pyx_NAMESTR("iter_prefix_values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_35iter_prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_34iter_prefix_values)}, - {__Pyx_NAMESTR("prefixes"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_38prefixes, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_37prefixes)}, - {__Pyx_NAMESTR("prefix_items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_40prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_39prefix_items)}, - {__Pyx_NAMESTR("prefix_values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_42prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_41prefix_values)}, - {__Pyx_NAMESTR("longest_prefix"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_44longest_prefix, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_43longest_prefix)}, - {__Pyx_NAMESTR("longest_prefix_item"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_46longest_prefix_item, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_45longest_prefix_item)}, - {__Pyx_NAMESTR("longest_prefix_value"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_48longest_prefix_value, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_47longest_prefix_value)}, - {__Pyx_NAMESTR("has_keys_with_prefix"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_50has_keys_with_prefix, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_49has_keys_with_prefix)}, - {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_52items, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_51items)}, - {__Pyx_NAMESTR("keys"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_54keys, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_53keys)}, - {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pw_6datrie_8BaseTrie_56values, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_8BaseTrie_55values)}, - {0, 0, 0, 0} -}; - -static PySequenceMethods __pyx_tp_as_sequence_BaseTrie = { - __pyx_pw_6datrie_8BaseTrie_25__len__, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_6datrie_BaseTrie, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - __pyx_pw_6datrie_8BaseTrie_19__contains__, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_BaseTrie = { - __pyx_pw_6datrie_8BaseTrie_25__len__, /*mp_length*/ - __pyx_pw_6datrie_8BaseTrie_17__getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_6datrie_BaseTrie, /*mp_ass_subscript*/ -}; +static int __pyx_tp_clear_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} -static PyTypeObject __pyx_type_6datrie_BaseTrie = { +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct__iter_prefixes = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.BaseTrie"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_BaseTrie), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct__iter_prefixes"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie_BaseTrie, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct__iter_prefixes, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16156,23 +17370,23 @@ static PyTypeObject __pyx_type_6datrie_BaseTrie = { #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_BaseTrie, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_BaseTrie, /*tp_as_mapping*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - __Pyx_DOCSTR("\n Wrapper for libdatrie's trie.\n\n Keys are unicode strings, values are integers -2147483648 <= x <= 2147483647.\n "), /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct__iter_prefixes, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct__iter_prefixes, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie_BaseTrie, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16180,9 +17394,9 @@ static PyTypeObject __pyx_type_6datrie_BaseTrie = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_pw_6datrie_8BaseTrie_1__init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_BaseTrie, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct__iter_prefixes, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16194,115 +17408,65 @@ static PyTypeObject __pyx_type_6datrie_BaseTrie = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_vtabstruct_6datrie_Trie __pyx_vtable_6datrie_Trie; -static PyObject *__pyx_tp_new_6datrie_Trie(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_6datrie_Trie *p; - PyObject *o = __pyx_tp_new_6datrie_BaseTrie(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_Trie *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie_BaseTrie*)__pyx_vtabptr_6datrie_Trie; - p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None); +static struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *__pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items = 0; + +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_1_iter_prefix_items(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (likely((__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[--__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } return o; } -static void __pyx_tp_dealloc_6datrie_Trie(PyObject *o) { - struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; PyObject_GC_UnTrack(o); - Py_CLEAR(p->_values); - PyObject_GC_Track(o); - __pyx_tp_dealloc_6datrie_BaseTrie(o); + Py_CLEAR(p->__pyx_v_key); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_t_0); + if ((__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items))) { + __pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } } -static int __pyx_tp_traverse_6datrie_Trie(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; - e = ((likely(__pyx_ptype_6datrie_BaseTrie)) ? ((__pyx_ptype_6datrie_BaseTrie->tp_traverse) ? __pyx_ptype_6datrie_BaseTrie->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_6datrie_Trie)); if (e) return e; - if (p->_values) { - e = (*v)(p->_values, a); if (e) return e; + struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_6datrie_Trie(PyObject *o) { - struct __pyx_obj_6datrie_Trie *p = (struct __pyx_obj_6datrie_Trie *)o; +static int __pyx_tp_clear_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o) { PyObject* tmp; - if (likely(__pyx_ptype_6datrie_BaseTrie)) { if (__pyx_ptype_6datrie_BaseTrie->tp_clear) __pyx_ptype_6datrie_BaseTrie->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_6datrie_Trie); - tmp = ((PyObject*)p->_values); - p->_values = ((PyObject*)Py_None); Py_INCREF(Py_None); + struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_sq_item_6datrie_Trie(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static int __pyx_mp_ass_subscript_6datrie_Trie(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_pw_6datrie_4Trie_5__setitem__(o, i, v); - } - else { - return __pyx_pw_6datrie_4Trie_9__delitem__(o, i); - } -} - -static PyMethodDef __pyx_methods_6datrie_Trie[] = { - {__Pyx_NAMESTR("setdefault"), (PyCFunction)__pyx_pw_6datrie_4Trie_7setdefault, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_6datrie_4Trie_11write, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_10write)}, - {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_6datrie_4Trie_13read, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_12read)}, - {__Pyx_NAMESTR("items"), (PyCFunction)__pyx_pw_6datrie_4Trie_15items, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_14items)}, - {__Pyx_NAMESTR("values"), (PyCFunction)__pyx_pw_6datrie_4Trie_17values, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_16values)}, - {__Pyx_NAMESTR("longest_prefix_item"), (PyCFunction)__pyx_pw_6datrie_4Trie_19longest_prefix_item, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_18longest_prefix_item)}, - {__Pyx_NAMESTR("longest_prefix_value"), (PyCFunction)__pyx_pw_6datrie_4Trie_21longest_prefix_value, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_20longest_prefix_value)}, - {__Pyx_NAMESTR("prefix_items"), (PyCFunction)__pyx_pw_6datrie_4Trie_23prefix_items, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_22prefix_items)}, - {__Pyx_NAMESTR("iter_prefix_items"), (PyCFunction)__pyx_pw_6datrie_4Trie_25iter_prefix_items, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("prefix_values"), (PyCFunction)__pyx_pw_6datrie_4Trie_28prefix_values, METH_O, __Pyx_DOCSTR(__pyx_doc_6datrie_4Trie_27prefix_values)}, - {__Pyx_NAMESTR("iter_prefix_values"), (PyCFunction)__pyx_pw_6datrie_4Trie_30iter_prefix_values, METH_O, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -static PySequenceMethods __pyx_tp_as_sequence_Trie = { - #if CYTHON_COMPILING_IN_PYPY - __pyx_pw_6datrie_8BaseTrie_25__len__, /*sq_length*/ - #else - 0, /*sq_length*/ - #endif - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_6datrie_Trie, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - #if CYTHON_COMPILING_IN_PYPY - __pyx_pw_6datrie_8BaseTrie_19__contains__, /*sq_contains*/ - #else - 0, /*sq_contains*/ - #endif - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Trie = { - #if CYTHON_COMPILING_IN_PYPY - __pyx_pw_6datrie_8BaseTrie_25__len__, /*mp_length*/ - #else - 0, /*mp_length*/ - #endif - __pyx_pw_6datrie_4Trie_3__getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_6datrie_Trie, /*mp_ass_subscript*/ -}; -static PyTypeObject __pyx_type_6datrie_Trie = { +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.Trie"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_Trie), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct_1_iter_prefix_items"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie_Trie, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16313,23 +17477,23 @@ static PyTypeObject __pyx_type_6datrie_Trie = { #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_Trie, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Trie, /*tp_as_mapping*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("\n Wrapper for libdatrie's trie.\n Keys are unicode strings, values are Python objects.\n "), /*tp_doc*/ - __pyx_tp_traverse_6datrie_Trie, /*tp_traverse*/ - __pyx_tp_clear_6datrie_Trie, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie_Trie, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16337,9 +17501,9 @@ static PyTypeObject __pyx_type_6datrie_Trie = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_pw_6datrie_4Trie_1__init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_Trie, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16351,83 +17515,65 @@ static PyTypeObject __pyx_type_6datrie_Trie = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *__pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes = 0; +static struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *__pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values = 0; -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct__iter_prefixes(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p; +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[--__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes)); - PyObject_INIT(o, t); + if (likely((__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[--__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values)); + (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o); - p->__pyx_v_key = 0; - p->__pyx_v_self = 0; - p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_v_key); Py_CLEAR(p->__pyx_v_self); Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes))) { - __pyx_freelist_6datrie___pyx_scope_struct__iter_prefixes[__pyx_freecount_6datrie___pyx_scope_struct__iter_prefixes++] = ((struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o); + if ((__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values))) { + __pyx_freelist_6datrie___pyx_scope_struct_2_iter_prefix_values[__pyx_freecount_6datrie___pyx_scope_struct_2_iter_prefix_values++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } -static int __pyx_tp_traverse_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; - if (p->__pyx_v_key) { - e = (*v)(p->__pyx_v_key, a); if (e) return e; - } + struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } - if (p->__pyx_t_0) { - e = (*v)(p->__pyx_t_0, a); if (e) return e; - } return 0; } -static int __pyx_tp_clear_6datrie___pyx_scope_struct__iter_prefixes(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *p = (struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes *)o; +static int __pyx_tp_clear_6datrie___pyx_scope_struct_2_iter_prefix_values(PyObject *o) { PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_key); - p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); + struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values *)o; tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_t_0); - p->__pyx_t_0 = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct__iter_prefixes[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct__iter_prefixes = { +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct__iter_prefixes"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct__iter_prefixes), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct_2_iter_prefix_values"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_2_iter_prefix_values), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct__iter_prefixes, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16448,13 +17594,13 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct__iter_prefixes = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct__iter_prefixes, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct__iter_prefixes, /*tp_clear*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct__iter_prefixes, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16464,7 +17610,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct__iter_prefixes = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct__iter_prefixes, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct_2_iter_prefix_values, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16476,83 +17622,85 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct__iter_prefixes = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *__pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items = 0; +static struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *__pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items = 0; -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_1_iter_prefix_items(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p; +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[--__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items)); - PyObject_INIT(o, t); + if (likely((__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[--__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items)); + (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o); - p->__pyx_v_key = 0; - p->__pyx_v_self = 0; - p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_k); Py_CLEAR(p->__pyx_v_key); Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_v); Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items))) { - __pyx_freelist_6datrie___pyx_scope_struct_1_iter_prefix_items[__pyx_freecount_6datrie___pyx_scope_struct_1_iter_prefix_items++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o); + if ((__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items))) { + __pyx_freelist_6datrie___pyx_scope_struct_3_iter_prefix_items[__pyx_freecount_6datrie___pyx_scope_struct_3_iter_prefix_items++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } -static int __pyx_tp_traverse_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; - if (p->__pyx_v_key) { - e = (*v)(p->__pyx_v_key, a); if (e) return e; + struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; + if (p->__pyx_v_k) { + e = (*v)(p->__pyx_v_k, a); if (e) return e; } if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } + if (p->__pyx_v_v) { + e = (*v)(p->__pyx_v_v, a); if (e) return e; + } if (p->__pyx_t_0) { e = (*v)(p->__pyx_t_0, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_6datrie___pyx_scope_struct_1_iter_prefix_items(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items *)o; +static int __pyx_tp_clear_6datrie___pyx_scope_struct_3_iter_prefix_items(PyObject *o) { PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_key); - p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); + struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *p = (struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items *)o; + tmp = ((PyObject*)p->__pyx_v_k); + p->__pyx_v_k = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_6datrie_BaseTrie *)Py_None); Py_INCREF(Py_None); + p->__pyx_v_self = ((struct __pyx_obj_6datrie_Trie *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_v); + p->__pyx_v_v = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_t_0); - p->__pyx_t_0 = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_1_iter_prefix_items[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items = { +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct_1_iter_prefix_items"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_1_iter_prefix_items), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct_3_iter_prefix_items"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_3_iter_prefix_items), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16573,13 +17721,13 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items = 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_clear*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16589,7 +17737,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items = 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct_1_iter_prefix_items, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct_3_iter_prefix_items, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16601,56 +17749,50 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items = #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *__pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[8]; -static int __pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0; +static struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *__pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values = 0; -static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p; +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; - if (likely((__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges)))) { - o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[--__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges]; - memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges)); - PyObject_INIT(o, t); + if (likely((__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[--__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values)); + (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o); - p->__pyx_v_alphabet = 0; - p->__pyx_v_begin = 0; - p->__pyx_v_end = 0; - p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_alphabet); - Py_CLEAR(p->__pyx_v_begin); - Py_CLEAR(p->__pyx_v_end); + Py_CLEAR(p->__pyx_v_key); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_v); Py_CLEAR(p->__pyx_t_0); - if ((__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges))) { - __pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o); + if ((__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values))) { + __pyx_freelist_6datrie___pyx_scope_struct_4_iter_prefix_values[__pyx_freecount_6datrie___pyx_scope_struct_4_iter_prefix_values++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } -static int __pyx_tp_traverse_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; - if (p->__pyx_v_alphabet) { - e = (*v)(p->__pyx_v_alphabet, a); if (e) return e; - } - if (p->__pyx_v_begin) { - e = (*v)(p->__pyx_v_begin, a); if (e) return e; + struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } - if (p->__pyx_v_end) { - e = (*v)(p->__pyx_v_end, a); if (e) return e; + if (p->__pyx_v_v) { + e = (*v)(p->__pyx_v_v, a); if (e) return e; } if (p->__pyx_t_0) { e = (*v)(p->__pyx_t_0, a); if (e) return e; @@ -16658,17 +17800,14 @@ static int __pyx_tp_traverse_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyO return 0; } -static int __pyx_tp_clear_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; +static int __pyx_tp_clear_6datrie___pyx_scope_struct_4_iter_prefix_values(PyObject *o) { PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_alphabet); - p->__pyx_v_alphabet = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_begin); - p->__pyx_v_begin = Py_None; Py_INCREF(Py_None); + struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *p = (struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values *)o; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_6datrie_Trie *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_end); - p->__pyx_v_end = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_v); + p->__pyx_v_v = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_t_0); p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); @@ -16676,16 +17815,12 @@ static int __pyx_tp_clear_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObje return 0; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_6_alphabet_to_ranges[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges = { +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.__pyx_scope_struct_6_alphabet_to_ranges"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct_4_iter_prefix_values"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_4_iter_prefix_values), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16706,13 +17841,13 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_traverse*/ - __pyx_tp_clear_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_clear*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16722,7 +17857,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct_4_iter_prefix_values, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -16734,76 +17869,8 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges = #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif -}; -static struct __pyx_vtabstruct_6datrie_BaseIterator __pyx_vtable_6datrie_BaseIterator; - -static PyObject *__pyx_tp_new_6datrie_BaseIterator(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_6datrie_BaseIterator *p; - PyObject *o = __pyx_tp_new_6datrie__TrieIterator(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_BaseIterator *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieIterator*)__pyx_vtabptr_6datrie_BaseIterator; - return o; -} - -static PyMethodDef __pyx_methods_6datrie_BaseIterator[] = { - {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_12BaseIterator_1data, METH_NOARGS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_6datrie_BaseIterator = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.BaseIterator"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_BaseIterator), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie__TrieIterator, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("\n cdatrie.TrieIterator wrapper. It can be used for custom datrie.BaseTrie\n traversal.\n "), /*tp_doc*/ - __pyx_tp_traverse_6datrie__TrieIterator, /*tp_traverse*/ - __pyx_tp_clear_6datrie__TrieIterator, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_6datrie_BaseIterator, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_BaseIterator, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ #endif }; @@ -16811,22 +17878,16 @@ static struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *__pyx_freelist_6 static int __pyx_freecount_6datrie___pyx_scope_struct_5_to_ranges = 0; static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_5_to_ranges(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *p; PyObject *o; if (likely((__pyx_freecount_6datrie___pyx_scope_struct_5_to_ranges > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges)))) { o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_5_to_ranges[--__pyx_freecount_6datrie___pyx_scope_struct_5_to_ranges]; memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges)); - PyObject_INIT(o, t); + (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } - p = ((struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *)o); - p->__pyx_v_a = 0; - p->__pyx_v_b = 0; - p->__pyx_v_lst = 0; - p->__pyx_t_0 = 0; return o; } @@ -16863,8 +17924,8 @@ static int __pyx_tp_traverse_6datrie___pyx_scope_struct_5_to_ranges(PyObject *o, } static int __pyx_tp_clear_6datrie___pyx_scope_struct_5_to_ranges(PyObject *o) { - struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *)o; PyObject* tmp; + struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_5_to_ranges *)o; tmp = ((PyObject*)p->__pyx_v_a); p->__pyx_v_a = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); @@ -16880,10 +17941,6 @@ static int __pyx_tp_clear_6datrie___pyx_scope_struct_5_to_ranges(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_6datrie___pyx_scope_struct_5_to_ranges[] = { - {0, 0, 0, 0} -}; - static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_5_to_ranges = { PyVarObject_HEAD_INIT(0, 0) __Pyx_NAMESTR("datrie.__pyx_scope_struct_5_to_ranges"), /*tp_name*/ @@ -16916,7 +17973,7 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_5_to_ranges = { 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie___pyx_scope_struct_5_to_ranges, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -16938,29 +17995,84 @@ static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_5_to_ranges = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; -static struct __pyx_vtabstruct_6datrie_BaseState __pyx_vtable_6datrie_BaseState; -static PyObject *__pyx_tp_new_6datrie_BaseState(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_6datrie_BaseState *p; - PyObject *o = __pyx_tp_new_6datrie__TrieState(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_6datrie_BaseState *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_6datrie__TrieState*)__pyx_vtabptr_6datrie_BaseState; +static struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *__pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[8]; +static int __pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges = 0; + +static PyObject *__pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (likely((__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges)))) { + o = (PyObject*)__pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[--__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges]; + memset(o, 0, sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } return o; } -static PyMethodDef __pyx_methods_6datrie_BaseState[] = { - {__Pyx_NAMESTR("data"), (PyCFunction)__pyx_pw_6datrie_9BaseState_1data, METH_NOARGS, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; +static void __pyx_tp_dealloc_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o) { + struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_alphabet); + Py_CLEAR(p->__pyx_v_begin); + Py_CLEAR(p->__pyx_v_end); + Py_CLEAR(p->__pyx_t_0); + if ((__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges))) { + __pyx_freelist_6datrie___pyx_scope_struct_6_alphabet_to_ranges[__pyx_freecount_6datrie___pyx_scope_struct_6_alphabet_to_ranges++] = ((struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} -static PyTypeObject __pyx_type_6datrie_BaseState = { +static int __pyx_tp_traverse_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; + if (p->__pyx_v_alphabet) { + e = (*v)(p->__pyx_v_alphabet, a); if (e) return e; + } + if (p->__pyx_v_begin) { + e = (*v)(p->__pyx_v_begin, a); if (e) return e; + } + if (p->__pyx_v_end) { + e = (*v)(p->__pyx_v_end, a); if (e) return e; + } + if (p->__pyx_t_0) { + e = (*v)(p->__pyx_t_0, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6datrie___pyx_scope_struct_6_alphabet_to_ranges(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *p = (struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges *)o; + tmp = ((PyObject*)p->__pyx_v_alphabet); + p->__pyx_v_alphabet = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_begin); + p->__pyx_v_begin = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_end); + p->__pyx_v_end = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_t_0); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyTypeObject __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("datrie.BaseState"), /*tp_name*/ - sizeof(struct __pyx_obj_6datrie_BaseState), /*tp_basicsize*/ + __Pyx_NAMESTR("datrie.__pyx_scope_struct_6_alphabet_to_ranges"), /*tp_name*/ + sizeof(struct __pyx_obj_6datrie___pyx_scope_struct_6_alphabet_to_ranges), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6datrie__TrieState, /*tp_dealloc*/ + __pyx_tp_dealloc_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -16969,11 +18081,7 @@ static PyTypeObject __pyx_type_6datrie_BaseState = { #else 0, /*reserved*/ #endif - #if CYTHON_COMPILING_IN_PYPY - __pyx_pw_6datrie_10_TrieState_19__repr__, /*tp_repr*/ - #else 0, /*tp_repr*/ - #endif 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ @@ -16983,15 +18091,15 @@ static PyTypeObject __pyx_type_6datrie_BaseState = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("\n cdatrie.TrieState wrapper. It can be used for custom trie traversal.\n "), /*tp_doc*/ - __pyx_tp_traverse_6datrie__TrieState, /*tp_traverse*/ - __pyx_tp_clear_6datrie__TrieState, /*tp_clear*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_traverse*/ + __pyx_tp_clear_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6datrie_BaseState, /*tp_methods*/ + 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -17001,7 +18109,7 @@ static PyTypeObject __pyx_type_6datrie_BaseState = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6datrie_BaseState, /*tp_new*/ + __pyx_tp_new_6datrie___pyx_scope_struct_6_alphabet_to_ranges, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -17013,6 +18121,9 @@ static PyTypeObject __pyx_type_6datrie_BaseState = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif }; static PyMethodDef __pyx_methods[] = { @@ -17027,7 +18138,7 @@ static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, #endif __Pyx_NAMESTR("datrie"), - __Pyx_DOCSTR(__pyx_k_25), /* m_doc */ + __Pyx_DOCSTR(__pyx_k_Cython_wrapper_for_libdatrie), /* m_doc */ -1, /* m_size */ __pyx_methods /* m_methods */, NULL, /* m_reload */ @@ -17038,122 +18149,125 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_u_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 1, 0, 0}, - {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, - {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, - {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0}, - {&__pyx_n_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 1}, - {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0}, - {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, - {&__pyx_kp_u_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 1, 0, 0}, - {&__pyx_kp_u_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 1, 0, 0}, - {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0}, - {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, - {&__pyx_n_s__DELETED_OBJECT, __pyx_k__DELETED_OBJECT, sizeof(__pyx_k__DELETED_OBJECT), 0, 0, 1, 1}, - {&__pyx_n_s__DatrieError, __pyx_k__DatrieError, sizeof(__pyx_k__DatrieError), 0, 0, 1, 1}, - {&__pyx_n_s__DeprecationWarning, __pyx_k__DeprecationWarning, sizeof(__pyx_k__DeprecationWarning), 0, 0, 1, 1}, - {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1}, - {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1}, - {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1}, - {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1}, - {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1}, - {&__pyx_n_s__RAISE_KEY_ERROR, __pyx_k__RAISE_KEY_ERROR, sizeof(__pyx_k__RAISE_KEY_ERROR), 0, 0, 1, 1}, - {&__pyx_n_s__RERAISE_KEY_ERROR, __pyx_k__RERAISE_KEY_ERROR, sizeof(__pyx_k__RERAISE_KEY_ERROR), 0, 0, 1, 1}, - {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, - {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1}, - {&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1}, - {&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1}, - {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1}, - {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1}, - {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, - {&__pyx_n_s____metaclass__, __pyx_k____metaclass__, sizeof(__pyx_k____metaclass__), 0, 0, 1, 1}, - {&__pyx_n_s____module__, __pyx_k____module__, sizeof(__pyx_k____module__), 0, 0, 1, 1}, - {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1}, - {&__pyx_n_s____qualname__, __pyx_k____qualname__, sizeof(__pyx_k____qualname__), 0, 0, 1, 1}, - {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, - {&__pyx_n_s____unicode__, __pyx_k____unicode__, sizeof(__pyx_k____unicode__), 0, 0, 1, 1}, - {&__pyx_n_s___add_range, __pyx_k___add_range, sizeof(__pyx_k___add_range), 0, 0, 1, 1}, - {&__pyx_n_s___create, __pyx_k___create, sizeof(__pyx_k___create), 0, 0, 1, 1}, - {&__pyx_n_s___delitem, __pyx_k___delitem, sizeof(__pyx_k___delitem), 0, 0, 1, 1}, - {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1}, - {&__pyx_n_s__add_alphabet, __pyx_k__add_alphabet, sizeof(__pyx_k__add_alphabet), 0, 0, 1, 1}, - {&__pyx_n_s__add_range, __pyx_k__add_range, sizeof(__pyx_k__add_range), 0, 0, 1, 1}, - {&__pyx_n_s__alpha_map, __pyx_k__alpha_map, sizeof(__pyx_k__alpha_map), 0, 0, 1, 1}, - {&__pyx_n_s__alphabet, __pyx_k__alphabet, sizeof(__pyx_k__alphabet), 0, 0, 1, 1}, - {&__pyx_n_s__alphabet_to_ranges, __pyx_k__alphabet_to_ranges, sizeof(__pyx_k__alphabet_to_ranges), 0, 0, 1, 1}, - {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1}, - {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1}, - {&__pyx_n_s__begin, __pyx_k__begin, sizeof(__pyx_k__begin), 0, 0, 1, 1}, - {&__pyx_n_s__cPickle, __pyx_k__cPickle, sizeof(__pyx_k__cPickle), 0, 0, 1, 1}, - {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1}, - {&__pyx_n_s__copy_to, __pyx_k__copy_to, sizeof(__pyx_k__copy_to), 0, 0, 1, 1}, - {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1}, - {&__pyx_n_s__datrie, __pyx_k__datrie, sizeof(__pyx_k__datrie), 0, 0, 1, 1}, - {&__pyx_n_s__default, __pyx_k__default, sizeof(__pyx_k__default), 0, 0, 1, 1}, - {&__pyx_n_s__dump, __pyx_k__dump, sizeof(__pyx_k__dump), 0, 0, 1, 1}, - {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1}, - {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1}, - {&__pyx_n_s__fileno, __pyx_k__fileno, sizeof(__pyx_k__fileno), 0, 0, 1, 1}, - {&__pyx_n_s__flush, __pyx_k__flush, sizeof(__pyx_k__flush), 0, 0, 1, 1}, - {&__pyx_n_s__groupby, __pyx_k__groupby, sizeof(__pyx_k__groupby), 0, 0, 1, 1}, - {&__pyx_n_s__is_dirty, __pyx_k__is_dirty, sizeof(__pyx_k__is_dirty), 0, 0, 1, 1}, - {&__pyx_n_s__is_leaf, __pyx_k__is_leaf, sizeof(__pyx_k__is_leaf), 0, 0, 1, 1}, - {&__pyx_n_s__is_single, __pyx_k__is_single, sizeof(__pyx_k__is_single), 0, 0, 1, 1}, - {&__pyx_n_s__is_terminal, __pyx_k__is_terminal, sizeof(__pyx_k__is_terminal), 0, 0, 1, 1}, - {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1}, - {&__pyx_n_s__iter_prefix_items, __pyx_k__iter_prefix_items, sizeof(__pyx_k__iter_prefix_items), 0, 0, 1, 1}, - {&__pyx_n_s__iter_prefix_values, __pyx_k__iter_prefix_values, sizeof(__pyx_k__iter_prefix_values), 0, 0, 1, 1}, - {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1}, - {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1}, - {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1}, - {&__pyx_n_s__load, __pyx_k__load, sizeof(__pyx_k__load), 0, 0, 1, 1}, - {&__pyx_n_s__lst, __pyx_k__lst, sizeof(__pyx_k__lst), 0, 0, 1, 1}, - {&__pyx_n_s__map, __pyx_k__map, sizeof(__pyx_k__map), 0, 0, 1, 1}, - {&__pyx_n_s__new, __pyx_k__new, sizeof(__pyx_k__new), 0, 0, 1, 1}, - {&__pyx_n_s__next, __pyx_k__next, sizeof(__pyx_k__next), 0, 0, 1, 1}, - {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1}, - {&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1}, - {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1}, - {&__pyx_n_s__pickle, __pyx_k__pickle, sizeof(__pyx_k__pickle), 0, 0, 1, 1}, - {&__pyx_n_s__prefix, __pyx_k__prefix, sizeof(__pyx_k__prefix), 0, 0, 1, 1}, - {&__pyx_n_s__protocol, __pyx_k__protocol, sizeof(__pyx_k__protocol), 0, 0, 1, 1}, - {&__pyx_n_s__ranges, __pyx_k__ranges, sizeof(__pyx_k__ranges), 0, 0, 1, 1}, - {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1}, - {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1}, - {&__pyx_n_s__rewind, __pyx_k__rewind, sizeof(__pyx_k__rewind), 0, 0, 1, 1}, - {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1}, - {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1}, - {&__pyx_n_s__sorted, __pyx_k__sorted, sizeof(__pyx_k__sorted), 0, 0, 1, 1}, - {&__pyx_n_s__state, __pyx_k__state, sizeof(__pyx_k__state), 0, 0, 1, 1}, - {&__pyx_n_s__super, __pyx_k__super, sizeof(__pyx_k__super), 0, 0, 1, 1}, - {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1}, - {&__pyx_n_s__throw, __pyx_k__throw, sizeof(__pyx_k__throw), 0, 0, 1, 1}, - {&__pyx_n_s__to_ranges, __pyx_k__to_ranges, sizeof(__pyx_k__to_ranges), 0, 0, 1, 1}, - {&__pyx_n_s__trie, __pyx_k__trie, sizeof(__pyx_k__trie), 0, 0, 1, 1}, - {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1}, - {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1}, - {&__pyx_n_s__walk, __pyx_k__walk, sizeof(__pyx_k__walk), 0, 0, 1, 1}, - {&__pyx_n_s__warn, __pyx_k__warn, sizeof(__pyx_k__warn), 0, 0, 1, 1}, - {&__pyx_n_s__warnings, __pyx_k__warnings, sizeof(__pyx_k__warnings), 0, 0, 1, 1}, - {&__pyx_n_s__wb, __pyx_k__wb, sizeof(__pyx_k__wb), 0, 0, 1, 1}, - {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1}, + {&__pyx_kp_s_Can_t_load_trie_from_stream, __pyx_k_Can_t_load_trie_from_stream, sizeof(__pyx_k_Can_t_load_trie_from_stream), 0, 0, 1, 0}, + {&__pyx_kp_s_Can_t_open_file_descriptor, __pyx_k_Can_t_open_file_descriptor, sizeof(__pyx_k_Can_t_open_file_descriptor), 0, 0, 1, 0}, + {&__pyx_kp_s_Can_t_write_to_file, __pyx_k_Can_t_write_to_file, sizeof(__pyx_k_Can_t_write_to_file), 0, 0, 1, 0}, + {&__pyx_kp_u_Converts_a_list_of_numbers_to_a, __pyx_k_Converts_a_list_of_numbers_to_a, sizeof(__pyx_k_Converts_a_list_of_numbers_to_a), 0, 1, 0, 0}, + {&__pyx_n_s_DELETED_OBJECT, __pyx_k_DELETED_OBJECT, sizeof(__pyx_k_DELETED_OBJECT), 0, 0, 1, 1}, + {&__pyx_n_s_DatrieError, __pyx_k_DatrieError, sizeof(__pyx_k_DatrieError), 0, 0, 1, 1}, + {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1}, + {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1}, + {&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_kp_s_Please_provide_alphabet_ranges_o, __pyx_k_Please_provide_alphabet_ranges_o, sizeof(__pyx_k_Please_provide_alphabet_ranges_o), 0, 0, 1, 0}, + {&__pyx_n_s_RAISE_KEY_ERROR, __pyx_k_RAISE_KEY_ERROR, sizeof(__pyx_k_RAISE_KEY_ERROR), 0, 0, 1, 1}, + {&__pyx_n_s_RERAISE_KEY_ERROR, __pyx_k_RERAISE_KEY_ERROR, sizeof(__pyx_k_RERAISE_KEY_ERROR), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0}, + {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1}, + {&__pyx_n_s_add_alphabet, __pyx_k_add_alphabet, sizeof(__pyx_k_add_alphabet), 0, 0, 1, 1}, + {&__pyx_n_s_add_range, __pyx_k_add_range, sizeof(__pyx_k_add_range), 0, 0, 1, 1}, + {&__pyx_n_s_add_range_2, __pyx_k_add_range_2, sizeof(__pyx_k_add_range_2), 0, 0, 1, 1}, + {&__pyx_n_s_alpha_map, __pyx_k_alpha_map, sizeof(__pyx_k_alpha_map), 0, 0, 1, 1}, + {&__pyx_n_s_alphabet, __pyx_k_alphabet, sizeof(__pyx_k_alphabet), 0, 0, 1, 1}, + {&__pyx_n_s_alphabet_to_ranges, __pyx_k_alphabet_to_ranges, sizeof(__pyx_k_alphabet_to_ranges), 0, 0, 1, 1}, + {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, + {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1}, + {&__pyx_n_s_begin, __pyx_k_begin, sizeof(__pyx_k_begin), 0, 0, 1, 1}, + {&__pyx_n_s_cPickle, __pyx_k_cPickle, sizeof(__pyx_k_cPickle), 0, 0, 1, 1}, + {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, + {&__pyx_n_s_copy_to, __pyx_k_copy_to, sizeof(__pyx_k_copy_to), 0, 0, 1, 1}, + {&__pyx_n_s_create, __pyx_k_create, sizeof(__pyx_k_create), 0, 0, 1, 1}, + {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, + {&__pyx_kp_u_data_d_term_s_leaf_s_single_s, __pyx_k_data_d_term_s_leaf_s_single_s, sizeof(__pyx_k_data_d_term_s_leaf_s_single_s), 0, 1, 0, 0}, + {&__pyx_n_s_datrie, __pyx_k_datrie, sizeof(__pyx_k_datrie), 0, 0, 1, 1}, + {&__pyx_kp_s_datrie_new_is_deprecated_please, __pyx_k_datrie_new_is_deprecated_please, sizeof(__pyx_k_datrie_new_is_deprecated_please), 0, 0, 1, 0}, + {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1}, + {&__pyx_n_s_delitem, __pyx_k_delitem, sizeof(__pyx_k_delitem), 0, 0, 1, 1}, + {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, + {&__pyx_n_s_dump, __pyx_k_dump, sizeof(__pyx_k_dump), 0, 0, 1, 1}, + {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, + {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1}, + {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, + {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1}, + {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1}, + {&__pyx_n_s_flush, __pyx_k_flush, sizeof(__pyx_k_flush), 0, 0, 1, 1}, + {&__pyx_n_s_groupby, __pyx_k_groupby, sizeof(__pyx_k_groupby), 0, 0, 1, 1}, + {&__pyx_kp_s_home_striky_mywspace_datrie_xmo, __pyx_k_home_striky_mywspace_datrie_xmo, sizeof(__pyx_k_home_striky_mywspace_datrie_xmo), 0, 0, 1, 0}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, + {&__pyx_n_s_is_dirty, __pyx_k_is_dirty, sizeof(__pyx_k_is_dirty), 0, 0, 1, 1}, + {&__pyx_n_s_is_leaf, __pyx_k_is_leaf, sizeof(__pyx_k_is_leaf), 0, 0, 1, 1}, + {&__pyx_n_s_is_single, __pyx_k_is_single, sizeof(__pyx_k_is_single), 0, 0, 1, 1}, + {&__pyx_n_s_is_terminal, __pyx_k_is_terminal, sizeof(__pyx_k_is_terminal), 0, 0, 1, 1}, + {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, + {&__pyx_n_s_iter_prefix_items, __pyx_k_iter_prefix_items, sizeof(__pyx_k_iter_prefix_items), 0, 0, 1, 1}, + {&__pyx_n_s_iter_prefix_values, __pyx_k_iter_prefix_values, sizeof(__pyx_k_iter_prefix_values), 0, 0, 1, 1}, + {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1}, + {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1}, + {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, + {&__pyx_n_s_load, __pyx_k_load, sizeof(__pyx_k_load), 0, 0, 1, 1}, + {&__pyx_n_s_lst, __pyx_k_lst, sizeof(__pyx_k_lst), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1}, + {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, + {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, + {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, + {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1}, + {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1}, + {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1}, + {&__pyx_n_s_ord, __pyx_k_ord, sizeof(__pyx_k_ord), 0, 0, 1, 1}, + {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, + {&__pyx_n_s_prefix, __pyx_k_prefix, sizeof(__pyx_k_prefix), 0, 0, 1, 1}, + {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, + {&__pyx_n_s_protocol, __pyx_k_protocol, sizeof(__pyx_k_protocol), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, + {&__pyx_kp_s_range_begin_end, __pyx_k_range_begin_end, sizeof(__pyx_k_range_begin_end), 0, 0, 1, 0}, + {&__pyx_n_s_ranges, __pyx_k_ranges, sizeof(__pyx_k_ranges), 0, 0, 1, 1}, + {&__pyx_n_s_rb, __pyx_k_rb, sizeof(__pyx_k_rb), 0, 0, 1, 1}, + {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1}, + {&__pyx_n_s_rewind, __pyx_k_rewind, sizeof(__pyx_k_rewind), 0, 0, 1, 1}, + {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1}, + {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, + {&__pyx_n_s_sorted, __pyx_k_sorted, sizeof(__pyx_k_sorted), 0, 0, 1, 1}, + {&__pyx_n_s_state, __pyx_k_state, sizeof(__pyx_k_state), 0, 0, 1, 1}, + {&__pyx_n_s_suffixes, __pyx_k_suffixes, sizeof(__pyx_k_suffixes), 0, 0, 1, 1}, + {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1}, + {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, + {&__pyx_n_s_to_ranges, __pyx_k_to_ranges, sizeof(__pyx_k_to_ranges), 0, 0, 1, 1}, + {&__pyx_kp_u_to_ranges_line_1017, __pyx_k_to_ranges_line_1017, sizeof(__pyx_k_to_ranges_line_1017), 0, 1, 0, 0}, + {&__pyx_n_s_to_ranges_locals_lambda, __pyx_k_to_ranges_locals_lambda, sizeof(__pyx_k_to_ranges_locals_lambda), 0, 0, 1, 1}, + {&__pyx_n_s_trie, __pyx_k_trie, sizeof(__pyx_k_trie), 0, 0, 1, 1}, + {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1}, + {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, + {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1}, + {&__pyx_n_s_walk, __pyx_k_walk, sizeof(__pyx_k_walk), 0, 0, 1, 1}, + {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1}, + {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1}, + {&__pyx_n_s_wb, __pyx_k_wb, sizeof(__pyx_k_wb), 0, 0, 1, 1}, + {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ord = __Pyx_GetBuiltinName(__pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s__DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ord = __Pyx_GetBuiltinName(__pyx_n_s_ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_n_s_sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -17170,9 +18284,9 @@ static int __Pyx_InitCachedConstants(void) { * * if alpha_map is None: */ - __pyx_k_tuple_3 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_3); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3)); + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Please_provide_alphabet_ranges_o); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); /* "datrie.pyx":77 * Saves this trie. @@ -17181,9 +18295,9 @@ static int __Pyx_InitCachedConstants(void) { * self.write(f) * */ - __pyx_k_tuple_4 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_4); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); + __pyx_tuple__2 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); /* "datrie.pyx":89 * cdef stdio.FILE* f_ptr = stdio_ext.fdopen(f.fileno(), "w") @@ -17192,9 +18306,9 @@ static int __Pyx_InitCachedConstants(void) { * * cdef int res = cdatrie.trie_fwrite(self._c_trie, f_ptr) */ - __pyx_k_tuple_6 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_5)); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_6); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Can_t_open_file_descriptor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); /* "datrie.pyx":93 * cdef int res = cdatrie.trie_fwrite(self._c_trie, f_ptr) @@ -17203,9 +18317,9 @@ static int __Pyx_InitCachedConstants(void) { * * stdio.fflush(f_ptr) */ - __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_8); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8)); + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Can_t_write_to_file); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); /* "datrie.pyx":103 * Loads a trie from file. @@ -17214,67 +18328,70 @@ static int __Pyx_InitCachedConstants(void) { * return cls.read(f) * */ - __pyx_k_tuple_9 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_9); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9)); + __pyx_tuple__5 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_tuple__6 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); - /* "datrie.pyx":873 + /* "datrie.pyx":896 * cdef cdatrie.Trie* trie = cdatrie.trie_fread(f_ptr) * if trie == NULL: * raise DatrieError("Can't load trie from stream") # <<<<<<<<<<<<<< * * cdef int f_pos = stdio.ftell(f_ptr) */ - __pyx_k_tuple_20 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_19)); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_20); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Can_t_load_trie_from_stream); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); - /* "datrie.pyx":944 + /* "datrie.pyx":967 * cpdef _add_range(self, cdatrie.AlphaChar begin, cdatrie.AlphaChar end): * if begin > end: * raise DatrieError('range begin > end') # <<<<<<<<<<<<<< * code = cdatrie.alpha_map_add_range(self._c_alpha_map, begin, end) * if code != 0: */ - __pyx_k_tuple_22 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_21)); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_22); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_range_begin_end); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); - /* "datrie.pyx":994 + /* "datrie.pyx":1017 * * * def to_ranges(lst): # <<<<<<<<<<<<<< * """ * Converts a list of numbers to a list of ranges:: */ - __pyx_k_tuple_26 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__lst), ((PyObject *)__pyx_n_s__a), ((PyObject *)__pyx_n_s__b)); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_26); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - __pyx_k_codeobj_27 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__to_ranges, 994, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__17 = PyTuple_Pack(3, __pyx_n_s_lst, __pyx_n_s_a, __pyx_n_s_b); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_striky_mywspace_datrie_xmo, __pyx_n_s_to_ranges, 1017, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":1006 + /* "datrie.pyx":1029 * yield b[0][1], b[-1][1] * * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): * yield begin, end */ - __pyx_k_tuple_29 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__alphabet), ((PyObject *)__pyx_n_s__begin), ((PyObject *)__pyx_n_s__end)); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_29); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29)); - __pyx_k_codeobj_30 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__alphabet_to_ranges, 1006, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__19 = PyTuple_Pack(3, __pyx_n_s_alphabet, __pyx_n_s_begin, __pyx_n_s_end); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); + __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_striky_mywspace_datrie_xmo, __pyx_n_s_alphabet_to_ranges, 1029, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "datrie.pyx":1010 + /* "datrie.pyx":1033 * yield begin, end * * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): # <<<<<<<<<<<<<< * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) * return Trie(alphabet, ranges, alpha_map) */ - __pyx_k_tuple_31 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__alphabet), ((PyObject *)__pyx_n_s__ranges), ((PyObject *)__pyx_n_s__alpha_map)); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_31); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31)); - __pyx_k_codeobj_32 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_28, __pyx_n_s__new, 1010, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__21 = PyTuple_Pack(3, __pyx_n_s_alphabet, __pyx_n_s_ranges, __pyx_n_s_alpha_map); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_striky_mywspace_datrie_xmo, __pyx_n_s_new, 1033, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -17284,8 +18401,8 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -17342,21 +18459,13 @@ PyMODINIT_FUNC PyInit_datrie(void) #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("datrie"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_25), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("datrie"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_Cython_wrapper_for_libdatrie), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (!PyDict_GetItemString(modules, "datrie")) { - if (unlikely(PyDict_SetItemString(modules, "datrie", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - } - #endif __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); @@ -17368,8 +18477,16 @@ PyMODINIT_FUNC PyInit_datrie(void) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_datrie) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "datrie")) { + if (unlikely(PyDict_SetItemString(modules, "datrie", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif /*--- Builtin init code ---*/ if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ @@ -17378,59 +18495,13 @@ PyMODINIT_FUNC PyInit_datrie(void) /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ - __pyx_vtabptr_6datrie__TrieIterator = &__pyx_vtable_6datrie__TrieIterator; - __pyx_vtable_6datrie__TrieIterator.next = (int (*)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_13_TrieIterator_next; - __pyx_vtable_6datrie__TrieIterator.key = (PyObject *(*)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_13_TrieIterator_key; - if (PyType_Ready(&__pyx_type_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie__TrieIterator.tp_dict, __pyx_vtabptr_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "_TrieIterator", (PyObject *)&__pyx_type_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie__TrieIterator = &__pyx_type_6datrie__TrieIterator; - __pyx_vtabptr_6datrie_Iterator = &__pyx_vtable_6datrie_Iterator; - __pyx_vtable_6datrie_Iterator.__pyx_base = *__pyx_vtabptr_6datrie__TrieIterator; - __pyx_vtable_6datrie_Iterator.data = (PyObject *(*)(struct __pyx_obj_6datrie_Iterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_8Iterator_data; - __pyx_type_6datrie_Iterator.tp_base = __pyx_ptype_6datrie__TrieIterator; - if (PyType_Ready(&__pyx_type_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie_Iterator.tp_dict, __pyx_vtabptr_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Iterator", (PyObject *)&__pyx_type_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie_Iterator = &__pyx_type_6datrie_Iterator; - __pyx_vtabptr_6datrie_AlphaMap = &__pyx_vtable_6datrie_AlphaMap; - __pyx_vtable_6datrie_AlphaMap._add_range = (PyObject *(*)(struct __pyx_obj_6datrie_AlphaMap *, AlphaChar, AlphaChar, int __pyx_skip_dispatch))__pyx_f_6datrie_8AlphaMap__add_range; - if (PyType_Ready(&__pyx_type_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie_AlphaMap.tp_dict, __pyx_vtabptr_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "AlphaMap", (PyObject *)&__pyx_type_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie_AlphaMap = &__pyx_type_6datrie_AlphaMap; - __pyx_vtabptr_6datrie__TrieState = &__pyx_vtable_6datrie__TrieState; - __pyx_vtable_6datrie__TrieState.walk = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_walk; - __pyx_vtable_6datrie__TrieState.walk_char = (int (*)(struct __pyx_obj_6datrie__TrieState *, AlphaChar))__pyx_f_6datrie_10_TrieState_walk_char; - __pyx_vtable_6datrie__TrieState.copy_to = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_copy_to; - __pyx_vtable_6datrie__TrieState.rewind = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_rewind; - __pyx_vtable_6datrie__TrieState.is_terminal = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_terminal; - __pyx_vtable_6datrie__TrieState.is_single = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_single; - __pyx_vtable_6datrie__TrieState.is_leaf = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_leaf; - if (PyType_Ready(&__pyx_type_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie__TrieState.tp_dict, __pyx_vtabptr_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "_TrieState", (PyObject *)&__pyx_type_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie__TrieState = &__pyx_type_6datrie__TrieState; - __pyx_vtabptr_6datrie_State = &__pyx_vtable_6datrie_State; - __pyx_vtable_6datrie_State.__pyx_base = *__pyx_vtabptr_6datrie__TrieState; - __pyx_vtable_6datrie_State.data = (PyObject *(*)(struct __pyx_obj_6datrie_State *, int __pyx_skip_dispatch))__pyx_f_6datrie_5State_data; - __pyx_type_6datrie_State.tp_base = __pyx_ptype_6datrie__TrieState; - if (PyType_Ready(&__pyx_type_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie_State.tp_dict, __pyx_vtabptr_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "State", (PyObject *)&__pyx_type_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie_State = &__pyx_type_6datrie_State; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct_3_iter_prefix_items = &__pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct_4_iter_prefix_values = &__pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct_2_iter_prefix_values = &__pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values; __pyx_vtabptr_6datrie_BaseTrie = &__pyx_vtable_6datrie_BaseTrie; __pyx_vtable_6datrie_BaseTrie.is_dirty = (int (*)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch))__pyx_f_6datrie_8BaseTrie_is_dirty; __pyx_vtable_6datrie_BaseTrie._setitem = (void (*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData))__pyx_f_6datrie_8BaseTrie__setitem; __pyx_vtable_6datrie_BaseTrie._getitem = (TrieData (*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *))__pyx_f_6datrie_8BaseTrie__getitem; __pyx_vtable_6datrie_BaseTrie._delitem = (int (*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6datrie_8BaseTrie__delitem; __pyx_vtable_6datrie_BaseTrie._setdefault = (TrieData (*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, TrieData))__pyx_f_6datrie_8BaseTrie__setdefault; + __pyx_vtable_6datrie_BaseTrie.suffixes = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_suffixes *__pyx_optional_args))__pyx_f_6datrie_8BaseTrie_suffixes; __pyx_vtable_6datrie_BaseTrie._prefix_items = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *))__pyx_f_6datrie_8BaseTrie__prefix_items; __pyx_vtable_6datrie_BaseTrie._prefix_values = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *))__pyx_f_6datrie_8BaseTrie__prefix_values; __pyx_vtable_6datrie_BaseTrie._longest_prefix_item = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, PyObject *, struct __pyx_opt_args_6datrie_8BaseTrie__longest_prefix_item *__pyx_optional_args))__pyx_f_6datrie_8BaseTrie__longest_prefix_item; @@ -17440,6 +18511,7 @@ PyMODINIT_FUNC PyInit_datrie(void) __pyx_vtable_6datrie_BaseTrie.values = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_values *__pyx_optional_args))__pyx_f_6datrie_8BaseTrie_values; __pyx_vtable_6datrie_BaseTrie._index_to_value = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, TrieData))__pyx_f_6datrie_8BaseTrie__index_to_value; if (PyType_Ready(&__pyx_type_6datrie_BaseTrie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_BaseTrie.tp_print = 0; #if CYTHON_COMPILING_IN_CPYTHON { PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6datrie_BaseTrie, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -17459,10 +18531,11 @@ PyMODINIT_FUNC PyInit_datrie(void) __pyx_vtable_6datrie_Trie.__pyx_base.values = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, int __pyx_skip_dispatch, struct __pyx_opt_args_6datrie_8BaseTrie_values *__pyx_optional_args))__pyx_f_6datrie_4Trie_values; __pyx_vtable_6datrie_Trie.__pyx_base._index_to_value = (PyObject *(*)(struct __pyx_obj_6datrie_BaseTrie *, TrieData))__pyx_f_6datrie_4Trie__index_to_value; __pyx_type_6datrie_Trie.tp_base = __pyx_ptype_6datrie_BaseTrie; - if (PyType_Ready(&__pyx_type_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_Trie.tp_print = 0; #if CYTHON_COMPILING_IN_CPYTHON { - PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6datrie_Trie, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6datrie_Trie, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { __pyx_wrapperbase_6datrie_4Trie___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; __pyx_wrapperbase_6datrie_4Trie___init__.doc = __pyx_doc_6datrie_4Trie___init__; @@ -17470,33 +18543,94 @@ PyMODINIT_FUNC PyInit_datrie(void) } } #endif - if (__Pyx_SetVtable(__pyx_type_6datrie_Trie.tp_dict, __pyx_vtabptr_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Trie", (PyObject *)&__pyx_type_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_6datrie_Trie.tp_dict, __pyx_vtabptr_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Trie", (PyObject *)&__pyx_type_6datrie_Trie) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6datrie_Trie = &__pyx_type_6datrie_Trie; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct__iter_prefixes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct__iter_prefixes = &__pyx_type_6datrie___pyx_scope_struct__iter_prefixes; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct_1_iter_prefix_items = &__pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie___pyx_scope_struct_6_alphabet_to_ranges = &__pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges; + __pyx_vtabptr_6datrie__TrieState = &__pyx_vtable_6datrie__TrieState; + __pyx_vtable_6datrie__TrieState.walk = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, PyObject *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_walk; + __pyx_vtable_6datrie__TrieState.walk_char = (int (*)(struct __pyx_obj_6datrie__TrieState *, AlphaChar))__pyx_f_6datrie_10_TrieState_walk_char; + __pyx_vtable_6datrie__TrieState.copy_to = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_copy_to; + __pyx_vtable_6datrie__TrieState.rewind = (PyObject *(*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_rewind; + __pyx_vtable_6datrie__TrieState.is_terminal = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_terminal; + __pyx_vtable_6datrie__TrieState.is_single = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_single; + __pyx_vtable_6datrie__TrieState.is_leaf = (int (*)(struct __pyx_obj_6datrie__TrieState *, int __pyx_skip_dispatch))__pyx_f_6datrie_10_TrieState_is_leaf; + if (PyType_Ready(&__pyx_type_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie__TrieState.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie__TrieState.tp_dict, __pyx_vtabptr_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "_TrieState", (PyObject *)&__pyx_type_6datrie__TrieState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie__TrieState = &__pyx_type_6datrie__TrieState; + __pyx_vtabptr_6datrie_BaseState = &__pyx_vtable_6datrie_BaseState; + __pyx_vtable_6datrie_BaseState.__pyx_base = *__pyx_vtabptr_6datrie__TrieState; + __pyx_vtable_6datrie_BaseState.data = (int (*)(struct __pyx_obj_6datrie_BaseState *, int __pyx_skip_dispatch))__pyx_f_6datrie_9BaseState_data; + __pyx_type_6datrie_BaseState.tp_base = __pyx_ptype_6datrie__TrieState; + if (PyType_Ready(&__pyx_type_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_BaseState.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie_BaseState.tp_dict, __pyx_vtabptr_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "BaseState", (PyObject *)&__pyx_type_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie_BaseState = &__pyx_type_6datrie_BaseState; + __pyx_vtabptr_6datrie_State = &__pyx_vtable_6datrie_State; + __pyx_vtable_6datrie_State.__pyx_base = *__pyx_vtabptr_6datrie__TrieState; + __pyx_vtable_6datrie_State.data = (PyObject *(*)(struct __pyx_obj_6datrie_State *, int __pyx_skip_dispatch))__pyx_f_6datrie_5State_data; + __pyx_type_6datrie_State.tp_base = __pyx_ptype_6datrie__TrieState; + if (PyType_Ready(&__pyx_type_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_State.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie_State.tp_dict, __pyx_vtabptr_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "State", (PyObject *)&__pyx_type_6datrie_State) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie_State = &__pyx_type_6datrie_State; + __pyx_vtabptr_6datrie__TrieIterator = &__pyx_vtable_6datrie__TrieIterator; + __pyx_vtable_6datrie__TrieIterator.next = (int (*)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_13_TrieIterator_next; + __pyx_vtable_6datrie__TrieIterator.key = (PyObject *(*)(struct __pyx_obj_6datrie__TrieIterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_13_TrieIterator_key; + if (PyType_Ready(&__pyx_type_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie__TrieIterator.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie__TrieIterator.tp_dict, __pyx_vtabptr_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "_TrieIterator", (PyObject *)&__pyx_type_6datrie__TrieIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie__TrieIterator = &__pyx_type_6datrie__TrieIterator; __pyx_vtabptr_6datrie_BaseIterator = &__pyx_vtable_6datrie_BaseIterator; __pyx_vtable_6datrie_BaseIterator.__pyx_base = *__pyx_vtabptr_6datrie__TrieIterator; __pyx_vtable_6datrie_BaseIterator.data = (TrieData (*)(struct __pyx_obj_6datrie_BaseIterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_12BaseIterator_data; __pyx_type_6datrie_BaseIterator.tp_base = __pyx_ptype_6datrie__TrieIterator; - if (PyType_Ready(&__pyx_type_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie_BaseIterator.tp_dict, __pyx_vtabptr_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "BaseIterator", (PyObject *)&__pyx_type_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_BaseIterator.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie_BaseIterator.tp_dict, __pyx_vtabptr_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "BaseIterator", (PyObject *)&__pyx_type_6datrie_BaseIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_6datrie_BaseIterator = &__pyx_type_6datrie_BaseIterator; - if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_5_to_ranges) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_6datrie_Iterator = &__pyx_vtable_6datrie_Iterator; + __pyx_vtable_6datrie_Iterator.__pyx_base = *__pyx_vtabptr_6datrie__TrieIterator; + __pyx_vtable_6datrie_Iterator.data = (PyObject *(*)(struct __pyx_obj_6datrie_Iterator *, int __pyx_skip_dispatch))__pyx_f_6datrie_8Iterator_data; + __pyx_type_6datrie_Iterator.tp_base = __pyx_ptype_6datrie__TrieIterator; + if (PyType_Ready(&__pyx_type_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_Iterator.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie_Iterator.tp_dict, __pyx_vtabptr_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Iterator", (PyObject *)&__pyx_type_6datrie_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie_Iterator = &__pyx_type_6datrie_Iterator; + __pyx_vtabptr_6datrie_AlphaMap = &__pyx_vtable_6datrie_AlphaMap; + __pyx_vtable_6datrie_AlphaMap._add_range = (PyObject *(*)(struct __pyx_obj_6datrie_AlphaMap *, AlphaChar, AlphaChar, int __pyx_skip_dispatch))__pyx_f_6datrie_8AlphaMap__add_range; + if (PyType_Ready(&__pyx_type_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie_AlphaMap.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_6datrie_AlphaMap.tp_dict, __pyx_vtabptr_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "AlphaMap", (PyObject *)&__pyx_type_6datrie_AlphaMap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_6datrie_AlphaMap = &__pyx_type_6datrie_AlphaMap; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct__iter_prefixes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct__iter_prefixes.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct__iter_prefixes = &__pyx_type_6datrie___pyx_scope_struct__iter_prefixes; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct_1_iter_prefix_items = &__pyx_type_6datrie___pyx_scope_struct_1_iter_prefix_items; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct_2_iter_prefix_values = &__pyx_type_6datrie___pyx_scope_struct_2_iter_prefix_values; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct_3_iter_prefix_items = &__pyx_type_6datrie___pyx_scope_struct_3_iter_prefix_items; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct_4_iter_prefix_values = &__pyx_type_6datrie___pyx_scope_struct_4_iter_prefix_values; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_5_to_ranges) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_5_to_ranges.tp_print = 0; __pyx_ptype_6datrie___pyx_scope_struct_5_to_ranges = &__pyx_type_6datrie___pyx_scope_struct_5_to_ranges; - __pyx_vtabptr_6datrie_BaseState = &__pyx_vtable_6datrie_BaseState; - __pyx_vtable_6datrie_BaseState.__pyx_base = *__pyx_vtabptr_6datrie__TrieState; - __pyx_vtable_6datrie_BaseState.data = (int (*)(struct __pyx_obj_6datrie_BaseState *, int __pyx_skip_dispatch))__pyx_f_6datrie_9BaseState_data; - __pyx_type_6datrie_BaseState.tp_base = __pyx_ptype_6datrie__TrieState; - if (PyType_Ready(&__pyx_type_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_6datrie_BaseState.tp_dict, __pyx_vtabptr_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "BaseState", (PyObject *)&__pyx_type_6datrie_BaseState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_6datrie_BaseState = &__pyx_type_6datrie_BaseState; + if (PyType_Ready(&__pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges.tp_print = 0; + __pyx_ptype_6datrie___pyx_scope_struct_6_alphabet_to_ranges = &__pyx_type_6datrie___pyx_scope_struct_6_alphabet_to_ranges; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ @@ -17509,9 +18643,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * import sys * import itertools */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__warnings), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__warnings, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "datrie.pyx":13 @@ -17521,9 +18655,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * import itertools * */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "datrie.pyx":14 @@ -17533,9 +18667,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * * try: */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Import(__pyx_n_s_itertools, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "datrie.pyx":16 @@ -17559,9 +18693,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * except ImportError: * import pickle */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__cPickle), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L2_error;} + __pyx_t_1 = __Pyx_Import(__pyx_n_s_cPickle, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L2_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__pickle, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L2_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L2_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -17593,15 +18727,16 @@ PyMODINIT_FUNC PyInit_datrie(void) * * class DatrieError(Exception): */ - __pyx_t_8 = __Pyx_Import(((PyObject *)__pyx_n_s__pickle), 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;} + __pyx_t_8 = __Pyx_Import(__pyx_n_s_pickle, 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;} __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__pickle, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L3_exception_handled; } + goto __pyx_L4_except_error; __pyx_L4_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); @@ -17623,19 +18758,22 @@ PyMODINIT_FUNC PyInit_datrie(void) * pass * */ - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_7)); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_builtin_Exception); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_builtin_Exception); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_builtin_Exception); __Pyx_GIVEREF(__pyx_builtin_Exception); - __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7), __pyx_n_s__DatrieError, __pyx_n_s__DatrieError, __pyx_n_s__datrie); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_Py3MetaclassPrepare(__pyx_t_6, __pyx_t_7, __pyx_n_s_DatrieError, __pyx_n_s_DatrieError, (PyObject *) NULL, __pyx_n_s_datrie, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s__DatrieError, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_6, __pyx_n_s_DatrieError, __pyx_t_7, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DatrieError, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "datrie.pyx":24 * pass @@ -17644,9 +18782,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * RERAISE_KEY_ERROR = object() * DELETED_OBJECT = object() */ - __pyx_t_7 = PyObject_Call(__pyx_builtin_object, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_object, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__RAISE_KEY_ERROR, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_RAISE_KEY_ERROR, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "datrie.pyx":25 @@ -17656,9 +18794,9 @@ PyMODINIT_FUNC PyInit_datrie(void) * DELETED_OBJECT = object() * */ - __pyx_t_7 = PyObject_Call(__pyx_builtin_object, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_object, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__RERAISE_KEY_ERROR, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_RERAISE_KEY_ERROR, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "datrie.pyx":26 @@ -17668,24 +18806,11 @@ PyMODINIT_FUNC PyInit_datrie(void) * * */ - __pyx_t_7 = PyObject_Call(__pyx_builtin_object, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_object, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__DELETED_OBJECT, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DELETED_OBJECT, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":38 - * cdef cdatrie.Trie *_c_trie - * - * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< - * """ - * For efficiency trie needs to know what unicode symbols - */ - __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_k_1 = __pyx_t_7; - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_7 = 0; - /* "datrie.pyx":99 * * @classmethod @@ -17693,13 +18818,21 @@ PyMODINIT_FUNC PyInit_datrie(void) * """ * Loads a trie from file. */ - __pyx_t_7 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_BaseTrie, __pyx_n_s__load); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_BaseTrie, __pyx_n_s_load); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + + /* "datrie.pyx":98 + * + * + * @classmethod # <<<<<<<<<<<<<< + * def load(cls, path): + * """ + */ + __pyx_t_6 = __Pyx_Method_ClassMethod(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_BaseTrie->tp_dict, __pyx_n_s__load, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_BaseTrie->tp_dict, __pyx_n_s_load, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyType_Modified(__pyx_ptype_6datrie_BaseTrie); /* "datrie.pyx":107 @@ -17709,181 +18842,184 @@ PyMODINIT_FUNC PyInit_datrie(void) * """ * Creates a new Trie by reading it from file. */ - __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_BaseTrie, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_BaseTrie, __pyx_n_s_read); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + + /* "datrie.pyx":106 + * return cls.read(f) + * + * @classmethod # <<<<<<<<<<<<<< + * def read(cls, f): + * """ + */ + __pyx_t_7 = __Pyx_Method_ClassMethod(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_BaseTrie->tp_dict, __pyx_n_s__read, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_BaseTrie->tp_dict, __pyx_n_s_read, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; PyType_Modified(__pyx_ptype_6datrie_BaseTrie); - /* "datrie.pyx":333 + /* "datrie.pyx":356 * * * def longest_prefix(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * """ * Returns the longest key in this trie that is a prefix of ``key``. */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_10 = __pyx_t_7; + __pyx_k__8 = __pyx_t_7; __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":367 + /* "datrie.pyx":390 * * * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * """ * Returns the item (``(key,value)`` tuple) associated with the longest */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_11 = __pyx_t_7; + __pyx_k__9 = __pyx_t_7; __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":378 + /* "datrie.pyx":401 * return self._longest_prefix_item(key, default) * * cdef _longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_12 = __pyx_t_7; + __pyx_k__10 = __pyx_t_7; __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":407 + /* "datrie.pyx":430 * * * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * """ * Returns the value associated with the longest key in this trie that is */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_13 = __pyx_t_7; + __pyx_k__11 = __pyx_t_7; __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":418 + /* "datrie.pyx":441 * return self._longest_prefix_value(key, default) * * cdef _longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * cdef cdatrie.TrieState* state = cdatrie.trie_root(self._c_trie) * */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_14 = __pyx_t_7; + __pyx_k__12 = __pyx_t_7; __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; - /* "datrie.pyx":550 - * cdef list _values + /* "datrie.pyx":623 * - * def __init__(self, alphabet=None, ranges=None, AlphaMap alpha_map=None, _create=True): # <<<<<<<<<<<<<< + * @classmethod + * def read(cls, f): # <<<<<<<<<<<<<< * """ - * For efficiency trie needs to know what unicode symbols + * Creates a new Trie by reading it from file. */ - __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_Trie, __pyx_n_s_read); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_k_15 = __pyx_t_7; - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_7 = 0; - /* "datrie.pyx":600 + /* "datrie.pyx":622 + * pickle.dump(self._values, f, protocol=2) * - * @classmethod - * def read(cls, f): # <<<<<<<<<<<<<< + * @classmethod # <<<<<<<<<<<<<< + * def read(cls, f): * """ - * Creates a new Trie by reading it from file. */ - __pyx_t_7 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_6datrie_Trie, __pyx_n_s__read); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_Method_ClassMethod(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_Trie->tp_dict, __pyx_n_s__read, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem((PyObject *)__pyx_ptype_6datrie_Trie->tp_dict, __pyx_n_s_read, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyType_Modified(__pyx_ptype_6datrie_Trie); - /* "datrie.pyx":675 + /* "datrie.pyx":698 * * * def longest_prefix_item(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * """ * Returns the item (``(key,value)`` tuple) associated with the longest */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_k_16 = __pyx_t_1; - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_k__13 = __pyx_t_6; + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; - /* "datrie.pyx":692 + /* "datrie.pyx":715 * return res[0], self._values[res[1]] * * def longest_prefix_value(self, unicode key, default=RAISE_KEY_ERROR): # <<<<<<<<<<<<<< * """ * Returns the value associated with the longest key in this trie that is */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__RAISE_KEY_ERROR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_k_17 = __pyx_t_1; - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_RAISE_KEY_ERROR); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_k__14 = __pyx_t_6; + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; - /* "datrie.pyx":994 + /* "datrie.pyx":1017 * * * def to_ranges(lst): # <<<<<<<<<<<<<< * """ * Converts a list of numbers to a list of ranges:: */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6datrie_1to_ranges, NULL, __pyx_n_s__datrie); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__to_ranges, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_6datrie_1to_ranges, NULL, __pyx_n_s_datrie); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_ranges, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "datrie.pyx":1006 + /* "datrie.pyx":1029 * yield b[0][1], b[-1][1] * * def alphabet_to_ranges(alphabet): # <<<<<<<<<<<<<< * for begin, end in to_ranges(sorted(map(ord, iter(alphabet)))): * yield begin, end */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6datrie_4alphabet_to_ranges, NULL, __pyx_n_s__datrie); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__alphabet_to_ranges, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_6datrie_4alphabet_to_ranges, NULL, __pyx_n_s_datrie); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_alphabet_to_ranges, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "datrie.pyx":1010 + /* "datrie.pyx":1033 * yield begin, end * * def new(alphabet=None, ranges=None, AlphaMap alpha_map=None): # <<<<<<<<<<<<<< * warnings.warn('datrie.new is deprecated; please use datrie.Trie.', DeprecationWarning) * return Trie(alphabet, ranges, alpha_map) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6datrie_7new, NULL, __pyx_n_s__datrie); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s__new, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_6datrie_7new, NULL, __pyx_n_s_datrie); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_new, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "datrie.pyx":1 * # cython: profile=False # <<<<<<<<<<<<<< * """ * Cython wrapper for libdatrie. */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_33), ((PyObject *)__pyx_kp_u_34)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_kp_u_to_ranges_line_1017, __pyx_kp_u_Converts_a_list_of_numbers_to_a) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -17929,7 +19065,7 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else - "name '%s' is not defined", PyString_AS_STRING(name)); + "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; @@ -18034,12 +19170,12 @@ static int __Pyx_ParseOptionalKeywords( goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, - "%s() keywords must be strings", function_name); + "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 - "%s() got an unexpected keyword argument '%s'", + "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", @@ -18069,31 +19205,60 @@ static void __Pyx_RaiseArgtupleInvalid( more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, - "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, +static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, const char *name, int exact) { - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (Py_TYPE(obj) == type) return 1; + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif } else { - if (PyObject_TypeCheck(obj, type)) return 1; + if (likely(PyObject_TypeCheck(obj, type))) return 1; } - PyErr_Format(PyExc_TypeError, - "Argument '%s' has incorrect type (expected %s, got %s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); return 0; } +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); +#if PY_VERSION_HEX >= 0x02060000 + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; +#endif + result = (*call)(func, arg, kw); +#if PY_VERSION_HEX >= 0x02060000 + Py_LeaveRecursiveCall(); +#endif + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; @@ -18211,27 +19376,40 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyEval_CallObject(type, args); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + if (PyObject_IsSubclass(instance_class, type)) { + type = instance_class; + } else { + instance_class = NULL; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } } } else { PyErr_SetString(PyExc_TypeError, @@ -18278,10 +19456,18 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else @@ -18296,6 +19482,37 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, } } +static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +#else + PyErr_GetExcInfo(type, value, tb); +#endif +} +static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(type, value, tb); +#endif +} + static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; #if CYTHON_COMPILING_IN_CPYTHON @@ -18318,12 +19535,14 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif goto bad; #if PY_MAJOR_VERSION >= 3 - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } #endif - Py_INCREF(local_type); - Py_INCREF(local_value); - Py_INCREF(local_tb); + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; @@ -18334,8 +19553,6 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; - /* Make sure tstate is in a consistent state when we XDECREF - these objects (DECREF may run arbitrary code). */ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); @@ -18355,7 +19572,7 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (unlikely(!type)) { - PyErr_Format(PyExc_SystemError, "Missing type object"); + PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(PyObject_TypeCheck(obj, type))) @@ -18409,6 +19626,25 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring( #endif } +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; +#else + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); +#endif + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON @@ -18559,7 +19795,7 @@ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } @@ -18632,13 +19868,13 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( return 1; invalid_keyword_type: PyErr_Format(PyExc_TypeError, - "%s() keywords must be strings", function_name); + "%.200s() keywords must be strings", function_name); return 0; #endif invalid_keyword: PyErr_Format(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 - "%s() got an unexpected keyword argument '%s'", + "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else "%s() got an unexpected keyword argument '%U'", @@ -18673,6 +19909,44 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( } } +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } +done: + Py_DECREF(fake_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { @@ -18805,11 +20079,10 @@ __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) return 0; } static PyObject * -__Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op) +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) { - PyObject* dict = PyModule_GetDict(__pyx_m); - Py_XINCREF(dict); - return dict; + Py_INCREF(op->func_globals); + return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) @@ -18965,7 +20238,7 @@ static PyMethodDef __pyx_CyFunction_methods[] = { {0, 0, 0, 0} }; static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* code) { + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); if (op == NULL) return NULL; @@ -18983,6 +20256,8 @@ static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int f op->func_qualname = qualname; op->func_doc = NULL; op->func_classobj = NULL; + op->func_globals = globals; + Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; @@ -19003,6 +20278,7 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); Py_CLEAR(m->func_classobj); Py_CLEAR(m->defaults_tuple); @@ -19034,6 +20310,7 @@ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); Py_VISIT(m->func_code); Py_VISIT(m->func_classobj); Py_VISIT(m->defaults_tuple); @@ -19178,14 +20455,18 @@ static PyTypeObject __pyx_CyFunctionType_type = { #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ +#endif }; static int __Pyx_CyFunction_init(void) { #if !CYTHON_COMPILING_IN_PYPY __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; #endif - if (PyType_Ready(&__pyx_CyFunctionType_type) < 0) + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); + if (__pyx_CyFunctionType == NULL) { return -1; - __pyx_CyFunctionType = &__pyx_CyFunctionType_type; + } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { @@ -19242,7 +20523,7 @@ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { #endif if (!ob) goto bad; - if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0) + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) goto bad; Py_DECREF(ob); return 0; @@ -19251,6 +20532,110 @@ static int __Pyx_SetVtable(PyObject *dict, void *vtable) { return -1; } +static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { + Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); + for (i=0; i < nbases; i++) { + PyTypeObject *tmptype; + PyObject *tmp = PyTuple_GET_ITEM(bases, i); + tmptype = Py_TYPE(tmp); +#if PY_MAJOR_VERSION < 3 + if (tmptype == &PyClass_Type) + continue; +#endif + if (!metaclass) { + metaclass = tmptype; + continue; + } + if (PyType_IsSubtype(metaclass, tmptype)) + continue; + if (PyType_IsSubtype(tmptype, metaclass)) { + metaclass = tmptype; + continue; + } + PyErr_SetString(PyExc_TypeError, + "metaclass conflict: " + "the metaclass of a derived class " + "must be a (non-strict) subclass " + "of the metaclasses of all its bases"); + return NULL; + } + if (!metaclass) { +#if PY_MAJOR_VERSION < 3 + metaclass = &PyClass_Type; +#else + metaclass = &PyType_Type; +#endif + } + Py_INCREF((PyObject*) metaclass); + return (PyObject*) metaclass; +} + +static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, + PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { + PyObject *ns; + if (metaclass) { + PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare); + if (prep) { + PyObject *pargs = PyTuple_Pack(2, name, bases); + if (unlikely(!pargs)) { + Py_DECREF(prep); + return NULL; + } + ns = PyObject_Call(prep, pargs, mkw); + Py_DECREF(prep); + Py_DECREF(pargs); + } else { + if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + PyErr_Clear(); + ns = PyDict_New(); + } + } else { + ns = PyDict_New(); + } + if (unlikely(!ns)) + return NULL; + if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; + if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; + if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; + return ns; +bad: + Py_DECREF(ns); + return NULL; +} +static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, + PyObject *dict, PyObject *mkw, + int calculate_metaclass, int allow_py2_metaclass) { + PyObject *result, *margs; + PyObject *owned_metaclass = NULL; + if (allow_py2_metaclass) { + owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); + if (owned_metaclass) { + metaclass = owned_metaclass; + } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { + PyErr_Clear(); + } else { + return NULL; + } + } + if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { + metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); + Py_XDECREF(owned_metaclass); + if (unlikely(!metaclass)) + return NULL; + owned_metaclass = metaclass; + } + margs = PyTuple_Pack(3, name, bases, dict); + if (unlikely(!margs)) { + result = NULL; + } else { + result = PyObject_Call(metaclass, margs, mkw); + Py_DECREF(margs); + } + Py_XDECREF(owned_metaclass); + return result; +} + static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { PyObject *result; result = __Pyx_PyObject_GetAttrStr(nmspace, name); @@ -19259,37 +20644,6 @@ static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) { return result; } -static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -#else - PyErr_GetExcInfo(type, value, tb); -#endif -} -static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(type, value, tb); -#endif -} - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; @@ -19298,7 +20652,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *list; #if PY_VERSION_HEX < 0x03030000 PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__); + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) goto bad; #endif @@ -19356,845 +20710,582 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { } } #else - if (level>0) { - PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); - goto bad; - } - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, NULL); - #endif -bad: - #if PY_VERSION_HEX < 0x03030000 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) { - PyObject *metaclass; -#if PY_MAJOR_VERSION < 3 - if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { - PyObject *base = PyTuple_GET_ITEM(bases, 0); - metaclass = __Pyx_PyObject_GetAttrStr(base, __pyx_n_s____class__); - if (!metaclass) { - PyErr_Clear(); - metaclass = (PyObject*) Py_TYPE(base); - } - } else { - metaclass = (PyObject *) &PyClass_Type; - } -#else - if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) { - PyObject *base = PyTuple_GET_ITEM(bases, 0); - metaclass = (PyObject*) Py_TYPE(base); - } else { - metaclass = (PyObject *) &PyType_Type; - } -#endif - Py_INCREF(metaclass); - return metaclass; -} - -static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, - PyObject *qualname, PyObject *modname) { - PyObject *result; - PyObject *metaclass; - if (PyDict_SetItem(dict, __pyx_n_s____module__, modname) < 0) - return NULL; - if (PyDict_SetItem(dict, __pyx_n_s____qualname__, qualname) < 0) - return NULL; - metaclass = PyDict_GetItem(dict, __pyx_n_s____metaclass__); - if (metaclass) { - Py_INCREF(metaclass); - } else { - metaclass = __Pyx_FindPy2Metaclass(bases); - } - result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL); - Py_DECREF(metaclass); - return result; -} - -static CYTHON_INLINE TrieData __Pyx_PyInt_from_py_TrieData(PyObject* x) { - const TrieData neg_one = (TrieData)-1, const_zero = (TrieData)0; - const int is_unsigned = const_zero < neg_one; - if (sizeof(TrieData) == sizeof(char)) { - if (is_unsigned) - return (TrieData)__Pyx_PyInt_AsUnsignedChar(x); - else - return (TrieData)__Pyx_PyInt_AsSignedChar(x); - } else if (sizeof(TrieData) == sizeof(short)) { - if (is_unsigned) - return (TrieData)__Pyx_PyInt_AsUnsignedShort(x); - else - return (TrieData)__Pyx_PyInt_AsSignedShort(x); - } else if (sizeof(TrieData) == sizeof(int)) { - if (is_unsigned) - return (TrieData)__Pyx_PyInt_AsUnsignedInt(x); - else - return (TrieData)__Pyx_PyInt_AsSignedInt(x); - } else if (sizeof(TrieData) == sizeof(long)) { - if (is_unsigned) - return (TrieData)__Pyx_PyInt_AsUnsignedLong(x); - else - return (TrieData)__Pyx_PyInt_AsSignedLong(x); - } else if (sizeof(TrieData) == sizeof(PY_LONG_LONG)) { - if (is_unsigned) - return (TrieData)__Pyx_PyInt_AsUnsignedLongLong(x); - else - return (TrieData)__Pyx_PyInt_AsSignedLongLong(x); - } else { - #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); - #else - TrieData val; - PyObject *v = __Pyx_PyNumber_Int(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } - #endif - return (TrieData)-1; - } -} - -static CYTHON_INLINE AlphaChar __Pyx_PyInt_from_py_AlphaChar(PyObject* x) { - const AlphaChar neg_one = (AlphaChar)-1, const_zero = (AlphaChar)0; - const int is_unsigned = const_zero < neg_one; - if (sizeof(AlphaChar) == sizeof(char)) { - if (is_unsigned) - return (AlphaChar)__Pyx_PyInt_AsUnsignedChar(x); - else - return (AlphaChar)__Pyx_PyInt_AsSignedChar(x); - } else if (sizeof(AlphaChar) == sizeof(short)) { - if (is_unsigned) - return (AlphaChar)__Pyx_PyInt_AsUnsignedShort(x); - else - return (AlphaChar)__Pyx_PyInt_AsSignedShort(x); - } else if (sizeof(AlphaChar) == sizeof(int)) { - if (is_unsigned) - return (AlphaChar)__Pyx_PyInt_AsUnsignedInt(x); - else - return (AlphaChar)__Pyx_PyInt_AsSignedInt(x); - } else if (sizeof(AlphaChar) == sizeof(long)) { - if (is_unsigned) - return (AlphaChar)__Pyx_PyInt_AsUnsignedLong(x); - else - return (AlphaChar)__Pyx_PyInt_AsSignedLong(x); - } else if (sizeof(AlphaChar) == sizeof(PY_LONG_LONG)) { - if (is_unsigned) - return (AlphaChar)__Pyx_PyInt_AsUnsignedLongLong(x); - else - return (AlphaChar)__Pyx_PyInt_AsSignedLongLong(x); - } else { - #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); - #else - AlphaChar val; - PyObject *v = __Pyx_PyNumber_Int(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } - #endif - return (AlphaChar)-1; - } -} - -static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_TrieData(TrieData val) { - const TrieData neg_one = (TrieData)-1, const_zero = (TrieData)0; - const int is_unsigned = const_zero < neg_one; - if ((sizeof(TrieData) == sizeof(char)) || - (sizeof(TrieData) == sizeof(short))) { - return PyInt_FromLong((long)val); - } else if ((sizeof(TrieData) == sizeof(int)) || - (sizeof(TrieData) == sizeof(long))) { - if (is_unsigned) - return PyLong_FromUnsignedLong((unsigned long)val); - else - return PyInt_FromLong((long)val); - } else if (sizeof(TrieData) == sizeof(PY_LONG_LONG)) { - if (is_unsigned) - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); - else - return PyLong_FromLongLong((PY_LONG_LONG)val); - } else { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(TrieData), - little, !is_unsigned); - } -} - -static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_AlphaChar(AlphaChar val) { - const AlphaChar neg_one = (AlphaChar)-1, const_zero = (AlphaChar)0; - const int is_unsigned = const_zero < neg_one; - if ((sizeof(AlphaChar) == sizeof(char)) || - (sizeof(AlphaChar) == sizeof(short))) { - return PyInt_FromLong((long)val); - } else if ((sizeof(AlphaChar) == sizeof(int)) || - (sizeof(AlphaChar) == sizeof(long))) { - if (is_unsigned) - return PyLong_FromUnsignedLong((unsigned long)val); - else - return PyInt_FromLong((long)val); - } else if (sizeof(AlphaChar) == sizeof(PY_LONG_LONG)) { - if (is_unsigned) - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); - else - return PyLong_FromLongLong((PY_LONG_LONG)val); - } else { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - return _PyLong_FromByteArray(bytes, sizeof(AlphaChar), - little, !is_unsigned); - } -} - -static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { -#if CYTHON_COMPILING_IN_PYPY - if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) { /* cdef classes */ - return PyClassMethod_New(method); - } -#else - static PyTypeObject *methoddescr_type = NULL; - if (methoddescr_type == NULL) { - PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append"); - if (!meth) return NULL; - methoddescr_type = Py_TYPE(meth); - Py_DECREF(meth); - } - if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */ - PyMethodDescrObject *descr = (PyMethodDescrObject *)method; - #if PY_VERSION_HEX < 0x03020000 - PyTypeObject *d_type = descr->d_type; - #else - PyTypeObject *d_type = descr->d_common.d_type; - #endif - return PyDescr_NewClassMethod(d_type, descr->d_method); - } -#endif - else if (PyMethod_Check(method)) { /* python classes */ - return PyClassMethod_New(PyMethod_GET_FUNCTION(method)); - } - else if (PyCFunction_Check(method)) { - return PyClassMethod_New(method); - } -#ifdef __Pyx_CyFunction_USED - else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) { - return PyClassMethod_New(method); - } -#endif - PyErr_Format(PyExc_TypeError, - "Class-level classmethod() can only be called on " - "a method_descriptor or instance method."); - return NULL; -} - -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { - const unsigned char neg_one = (unsigned char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned char" : - "value too large to convert to unsigned char"); - } - return (unsigned char)-1; - } - return (unsigned char)val; - } - return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { - const unsigned short neg_one = (unsigned short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned short" : - "value too large to convert to unsigned short"); - } - return (unsigned short)-1; - } - return (unsigned short)val; - } - return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { - const unsigned int neg_one = (unsigned int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned int" : - "value too large to convert to unsigned int"); - } - return (unsigned int)-1; - } - return (unsigned int)val; - } - return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { - const char neg_one = (char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to char" : - "value too large to convert to char"); - } - return (char)-1; - } - return (char)val; - } - return (char)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { - const short neg_one = (short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to short" : - "value too large to convert to short"); - } - return (short)-1; - } - return (short)val; - } - return (short)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; - } - return (int)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { - const signed char neg_one = (signed char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed char" : - "value too large to convert to signed char"); - } - return (signed char)-1; - } - return (signed char)val; - } - return (signed char)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { - const signed short neg_one = (signed short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed short" : - "value too large to convert to signed short"); - } - return (signed short)-1; - } - return (signed short)val; - } - return (signed short)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { - const signed int neg_one = (signed int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed int" : - "value too large to convert to signed int"); - } - return (signed int)-1; - } - return (signed int)val; + if (level>0) { + PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); + goto bad; } - return (signed int)__Pyx_PyInt_AsSignedLong(x); + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, NULL); + #endif +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; } -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \ + { \ + func_type value = func(x); \ + if (sizeof(target_type) < sizeof(func_type)) { \ + if (unlikely(value != (func_type) (target_type) value)) { \ + func_type zero = 0; \ + PyErr_SetString(PyExc_OverflowError, \ + (is_unsigned && unlikely(value < zero)) ? \ + "can't convert negative value to " #target_type : \ + "value too large to convert to " #target_type); \ + return (target_type) -1; \ + } \ + } \ + return (target_type) value; \ } - return (int)__Pyx_PyInt_AsLong(x); -} #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -#endif -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { - const unsigned long neg_one = (unsigned long)-1, const_zero = 0; +static CYTHON_INLINE TrieData __Pyx_PyInt_As_TrieData(PyObject *x) { + const TrieData neg_one = (TrieData) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; + if (sizeof(TrieData) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(TrieData, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to TrieData"); + return (TrieData) -1; + } + return (TrieData) val; } - return (unsigned long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(TrieData)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (TrieData) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; + "can't convert negative value to TrieData"); + return (TrieData) -1; + } + if (sizeof(TrieData) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(TrieData, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(TrieData) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(TrieData, unsigned long long, PyLong_AsUnsignedLongLong) } - return (unsigned long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(TrieData)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(TrieData) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(TrieData) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif + if (sizeof(TrieData) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(TrieData, long, PyLong_AsLong) + } else if (sizeof(TrieData) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(TrieData, long long, PyLong_AsLongLong) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + TrieData val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } #endif - return (unsigned long)PyLong_AsLong(x); + return (TrieData) -1; } } else { - unsigned long val; + TrieData val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned long)-1; - val = __Pyx_PyInt_AsUnsignedLong(tmp); + if (!tmp) return (TrieData) -1; + val = __Pyx_PyInt_As_TrieData(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { - const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; +static CYTHON_INLINE AlphaChar __Pyx_PyInt_As_AlphaChar(PyObject *x) { + const AlphaChar neg_one = (AlphaChar) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; + if (sizeof(AlphaChar) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(AlphaChar, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to AlphaChar"); + return (AlphaChar) -1; + } + return (AlphaChar) val; } - return (unsigned PY_LONG_LONG)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(AlphaChar)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (AlphaChar) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; + "can't convert negative value to AlphaChar"); + return (AlphaChar) -1; + } + if (sizeof(AlphaChar) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(AlphaChar, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(AlphaChar) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(AlphaChar, unsigned long long, PyLong_AsUnsignedLongLong) } - return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(AlphaChar)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(AlphaChar) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(AlphaChar) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif + if (sizeof(AlphaChar) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(AlphaChar, long, PyLong_AsLong) + } else if (sizeof(AlphaChar) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(AlphaChar, long long, PyLong_AsLongLong) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + AlphaChar val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } #endif - return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); + return (AlphaChar) -1; } } else { - unsigned PY_LONG_LONG val; + AlphaChar val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsUnsignedLongLong(tmp); + if (!tmp) return (AlphaChar) -1; + val = __Pyx_PyInt_As_AlphaChar(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -#endif -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { - const long neg_one = (long)-1, const_zero = 0; +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; + } + return (int) val; } - return (long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (int) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; + "can't convert negative value to int"); + return (int) -1; + } + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(int) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong) } - return (long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(int) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(int) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong) + } else if (sizeof(int) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } #endif - return (long)PyLong_AsLong(x); + return (int) -1; } } else { - long val; + int val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (long)-1; - val = __Pyx_PyInt_AsLong(tmp); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { - const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_TrieData(TrieData value) { + const TrieData neg_one = (TrieData) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; + if (is_unsigned) { + if (sizeof(TrieData) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(TrieData) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(TrieData) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } - return (PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; - } - return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - return (PY_LONG_LONG)PyLong_AsLongLong(x); + } else { + if (sizeof(TrieData) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(TrieData) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(TrieData), + little, !is_unsigned); + } +} + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(int) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } } else { - PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsLongLong(tmp); - Py_DECREF(tmp); - return val; + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); } } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { - const signed long neg_one = (signed long)-1, const_zero = 0; +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(long) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } - return (signed long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; - } - return (signed long)PyLong_AsUnsignedLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - return (signed long)PyLong_AsLong(x); + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_AlphaChar(AlphaChar value) { + const AlphaChar neg_one = (AlphaChar) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(AlphaChar) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(AlphaChar) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(AlphaChar) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } } else { - signed long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed long)-1; - val = __Pyx_PyInt_AsSignedLong(tmp); - Py_DECREF(tmp); - return val; + if (sizeof(AlphaChar) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(AlphaChar) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(AlphaChar), + little, !is_unsigned); } } -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" +static PyObject* __Pyx_Method_ClassMethod(PyObject *method) { +#if CYTHON_COMPILING_IN_PYPY + if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) { /* cdef classes */ + return PyClassMethod_New(method); + } +#else + static PyTypeObject *methoddescr_type = NULL; + if (methoddescr_type == NULL) { + PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append"); + if (!meth) return NULL; + methoddescr_type = Py_TYPE(meth); + Py_DECREF(meth); + } + if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */ + PyMethodDescrObject *descr = (PyMethodDescrObject *)method; + #if PY_VERSION_HEX < 0x03020000 + PyTypeObject *d_type = descr->d_type; + #else + PyTypeObject *d_type = descr->d_common.d_type; + #endif + return PyDescr_NewClassMethod(d_type, descr->d_method); + } +#endif + else if (PyMethod_Check(method)) { /* python classes */ + return PyClassMethod_New(PyMethod_GET_FUNCTION(method)); + } + else if (PyCFunction_Check(method)) { + return PyClassMethod_New(method); + } +#ifdef __Pyx_CyFunction_USED + else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) { + return PyClassMethod_New(method); + } #endif + PyErr_SetString(PyExc_TypeError, + "Class-level classmethod() can only be called on " + "a method_descriptor or instance method."); + return NULL; +} + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { - const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; + } + return (long) val; } - return (signed PY_LONG_LONG)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; + "can't convert negative value to long"); + return (long) -1; + } + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(long) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong) } - return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(long) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong) + } else if (sizeof(long) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } #endif - return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + return (long) -1; } } else { - signed PY_LONG_LONG val; + long val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsSignedLongLong(tmp); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } } -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; -#else - PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); - PyErr_SetExcInfo(*type, *value, *tb); -#endif - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} - static PyObject *__Pyx_Generator_Next(PyObject *self); static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value); static PyObject *__Pyx_Generator_Close(PyObject *self); @@ -20244,7 +21335,7 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { Py_DECREF(ev); #else { - PyObject* args = PyObject_GetAttr(ev, __pyx_n_s__args); + PyObject* args = PyObject_GetAttr(ev, __pyx_n_s_args); Py_DECREF(ev); if (likely(args)) { value = PyObject_GetItem(args, 0); @@ -20380,7 +21471,7 @@ static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) { if (value == Py_None) ret = PyIter_Next(yf); else - ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s__send, value); + ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); } gen->is_running = 0; if (likely(ret)) { @@ -20400,7 +21491,7 @@ static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) { } else { PyObject *meth; gen->is_running = 1; - meth = PyObject_GetAttr(yf, __pyx_n_s__close); + meth = PyObject_GetAttr(yf, __pyx_n_s_close); if (unlikely(!meth)) { if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_WriteUnraisable(yf); @@ -20485,7 +21576,7 @@ static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) { if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Generator_Throw(yf, args); } else { - PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s__throw); + PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s_throw); if (unlikely(!meth)) { Py_DECREF(yf); if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { @@ -20536,13 +21627,17 @@ static void __Pyx_Generator_dealloc(PyObject *self) { PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); - PyObject_GC_Track(self); if (gen->resume_label > 0) { + PyObject_GC_Track(self); +#if PY_VERSION_HEX >= 0x030400a1 + if (PyObject_CallFinalizerFromDealloc(self)) +#else Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) +#endif return; /* resurrected. :( */ + PyObject_GC_UnTrack(self); } - PyObject_GC_UnTrack(self); __Pyx_Generator_clear(self); PyObject_GC_Del(gen); } @@ -20552,8 +21647,10 @@ static void __Pyx_Generator_del(PyObject *self) { __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; if (gen->resume_label <= 0) return ; +#if PY_VERSION_HEX < 0x030400a1 assert(self->ob_refcnt == 0); self->ob_refcnt = 1; +#endif __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); res = __Pyx_Generator_Close(self); if (res == NULL) @@ -20561,6 +21658,7 @@ static void __Pyx_Generator_del(PyObject *self) { else Py_DECREF(res); __Pyx_ErrRestore(error_type, error_value, error_traceback); +#if PY_VERSION_HEX < 0x030400a1 /* Undo the temporary resurrection; can't use DECREF here, it would * cause a recursive call. */ @@ -20592,6 +21690,7 @@ static void __Pyx_Generator_del(PyObject *self) { --Py_TYPE(self)->tp_frees; --Py_TYPE(self)->tp_allocs; #endif +#endif } static PyMemberDef __pyx_Generator_memberlist[] = { {(char *) "gi_running", @@ -20635,7 +21734,7 @@ static PyTypeObject __pyx_GeneratorType_type = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags*/ 0, /*tp_doc*/ (traverseproc) __Pyx_Generator_traverse, /*tp_traverse*/ 0, /*tp_clear*/ @@ -20661,10 +21760,17 @@ static PyTypeObject __pyx_GeneratorType_type = { 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ +#if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_del*/ +#else __Pyx_Generator_del, /*tp_del*/ +#endif #if PY_VERSION_HEX >= 0x02060000 0, /*tp_version_tag*/ #endif +#if PY_VERSION_HEX >= 0x030400a1 + __Pyx_Generator_del, /*tp_finalize*/ +#endif }; static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, PyObject *closure) { @@ -20689,10 +21795,10 @@ static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, static int __pyx_Generator_init(void) { __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr; __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; - if (PyType_Ready(&__pyx_GeneratorType_type)) { + __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); + if (__pyx_GeneratorType == NULL) { return -1; } - __pyx_GeneratorType = &__pyx_GeneratorType_type; return 0; } @@ -20956,10 +22062,18 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_ #endif /* PY_VERSION_HEX < 0x03030000 */ } else #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ +#if !CYTHON_COMPILING_IN_PYPY +#if PY_VERSION_HEX >= 0x02060000 + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif +#endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); - if (r < 0) { + if (unlikely(r < 0)) { return NULL; } else { return result; @@ -21004,7 +22118,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, - "__%s__ returned non-%s (type %.200s)", + "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; @@ -21016,9 +22130,35 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { } return res; } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif +#endif static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; - PyObject* x = PyNumber_Index(b); + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) + return PyInt_AS_LONG(b); +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(b)) { + case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; + case 0: return 0; + case 1: return ((PyLongObject*)b)->ob_digit[0]; + } + #endif + #endif + #if PY_VERSION_HEX < 0x02060000 + return PyInt_AsSsize_t(b); + #else + return PyLong_AsSsize_t(b); + #endif + } + x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); @@ -21037,16 +22177,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); #endif } -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { - unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t)-1; - } - return (size_t)val; -} #endif /* Py_PYTHON_H */ diff --git a/src/datrie.pyx b/src/datrie.pyx index 7d8c217..3220a35 100644 --- a/src/datrie.pyx +++ b/src/datrie.pyx @@ -275,6 +275,29 @@ cdef class BaseTrie: finally: cdatrie.trie_state_free(state) + + cpdef suffixes(self, unicode prefix=u''): + """ + Returns a list of this trie's suffixes. + If ``prefix`` is not empty, returns only the suffixes of words prefixed by ``prefix``. + """ + cdef bint success + cdef list res = [] + cdef BaseState state = BaseState(self) + + if prefix is not None: + success = state.walk(prefix) + if not success: + return res + + cdef BaseIterator iter = BaseIterator(state) + + while iter.next(): + res.append(iter.key()) + + return res + + def prefix_items(self, unicode key): ''' Returns a list of the items (``(key,value)`` tuples) diff --git a/src/stdio_ext.c b/src/stdio_ext.c index e44074c..5e46941 100644 --- a/src/stdio_ext.c +++ b/src/stdio_ext.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.19.1 on Mon Jul 8 04:02:25 2013 */ +/* Generated by Cython 0.20.1 on Mon Feb 17 23:36:45 2014 */ #define PY_SSIZE_T_CLEAN #ifndef CYTHON_USE_PYLONG_INTERNALS @@ -19,6 +19,7 @@ #elif PY_VERSION_HEX < 0x02040000 #error Cython requires Python 2.4+. #else +#define CYTHON_ABI "0_20_1" #include /* For offsetof */ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -53,6 +54,9 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif +#if CYTHON_COMPILING_IN_PYPY +#define Py_OptimizeFlag 0 +#endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX @@ -60,7 +64,7 @@ #define PY_FORMAT_SIZE_T "" #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) + #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ (PyErr_Format(PyExc_TypeError, \ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \ @@ -112,13 +116,15 @@ #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ - PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type #endif -#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 +#if PY_VERSION_HEX < 0x02060000 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif #if PY_MAJOR_VERSION >= 3 @@ -131,19 +137,44 @@ #if PY_VERSION_HEX < 0x02060000 #define Py_TPFLAGS_HAVE_VERSION_TAG 0 #endif +#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT) + #define Py_TPFLAGS_IS_ABSTRACT 0 +#endif +#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #else #define CYTHON_PEP393_ENABLED 0 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type @@ -176,7 +207,7 @@ #else #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \ PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) @@ -201,11 +232,12 @@ #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif -#if PY_VERSION_HEX < 0x03020000 +#if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t PyInt_AsLong @@ -264,7 +296,7 @@ #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) + #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict @@ -339,8 +371,20 @@ typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; #define __PYX_DEFAULT_STRING_ENCODING "" #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ + (sizeof(type) < sizeof(Py_ssize_t)) || \ + (sizeof(type) > sizeof(Py_ssize_t) && \ + likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX) && \ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ + v == (type)PY_SSIZE_T_MIN))) || \ + (sizeof(type) == sizeof(Py_ssize_t) && \ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); @@ -351,9 +395,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) +#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s) #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s) #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s) #if PY_MAJOR_VERSION < 3 @@ -375,7 +421,6 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #if CYTHON_COMPILING_IN_CPYTHON #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else @@ -384,7 +429,7 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; @@ -409,7 +454,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.", + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } @@ -433,7 +478,7 @@ static int __Pyx_init_sys_getdefaultencoding_params() { #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params() { +static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys = NULL; PyObject* default_encoding = NULL; char* default_encoding_c; @@ -537,40 +582,22 @@ static const char *__pyx_f[] = { #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif /* CYTHON_REFNANNY */ +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); - -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); - -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); - -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); - -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); - -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); - -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); static int __Pyx_check_binary_version(void); @@ -605,10 +632,10 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ int __pyx_module_is_main_stdio_ext = 0; /* Implementation of 'stdio_ext' */ -static char __pyx_k____main__[] = "__main__"; -static char __pyx_k____test__[] = "__test__"; -static PyObject *__pyx_n_s____main__; -static PyObject *__pyx_n_s____test__; +static char __pyx_k_main[] = "__main__"; +static char __pyx_k_test[] = "__test__"; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_test; static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} @@ -633,8 +660,8 @@ static struct PyModuleDef __pyx_moduledef = { #endif static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, - {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { @@ -706,14 +733,6 @@ PyMODINIT_FUNC PyInit_stdio_ext(void) if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} Py_INCREF(__pyx_d); - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (!PyDict_GetItemString(modules, "stdio_ext")) { - if (unlikely(PyDict_SetItemString(modules, "stdio_ext", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - } - #endif __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); @@ -725,8 +744,16 @@ PyMODINIT_FUNC PyInit_stdio_ext(void) if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if (__pyx_module_is_main_stdio_ext) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "stdio_ext")) { + if (unlikely(PyDict_SetItemString(modules, "stdio_ext", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } } + #endif /*--- Builtin init code ---*/ if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Constants init code ---*/ @@ -746,9 +773,9 @@ PyMODINIT_FUNC PyInit_stdio_ext(void) * cdef extern from "stdio.h" nogil: */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -784,358 +811,96 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif /* CYTHON_REFNANNY */ -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { - const unsigned char neg_one = (unsigned char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned char" : - "value too large to convert to unsigned char"); - } - return (unsigned char)-1; - } - return (unsigned char)val; - } - return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { - const unsigned short neg_one = (unsigned short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned short" : - "value too large to convert to unsigned short"); - } - return (unsigned short)-1; - } - return (unsigned short)val; - } - return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { - const unsigned int neg_one = (unsigned int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned int" : - "value too large to convert to unsigned int"); - } - return (unsigned int)-1; - } - return (unsigned int)val; - } - return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { - const char neg_one = (char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to char" : - "value too large to convert to char"); - } - return (char)-1; - } - return (char)val; - } - return (char)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { - const short neg_one = (short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to short" : - "value too large to convert to short"); - } - return (short)-1; - } - return (short)val; - } - return (short)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(long) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); } - return (int)val; - } - return (int)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { - const signed char neg_one = (signed char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed char" : - "value too large to convert to signed char"); - } - return (signed char)-1; - } - return (signed char)val; - } - return (signed char)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { - const signed short neg_one = (signed short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed short" : - "value too large to convert to signed short"); - } - return (signed short)-1; + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); } - return (signed short)val; } - return (signed short)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { - const signed int neg_one = (signed int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed int" : - "value too large to convert to signed int"); - } - return (signed int)-1; - } - return (signed int)val; + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); } - return (signed int)__Pyx_PyInt_AsSignedLong(x); } -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \ + { \ + func_type value = func(x); \ + if (sizeof(target_type) < sizeof(func_type)) { \ + if (unlikely(value != (func_type) (target_type) value)) { \ + func_type zero = 0; \ + PyErr_SetString(PyExc_OverflowError, \ + (is_unsigned && unlikely(value < zero)) ? \ + "can't convert negative value to " #target_type : \ + "value too large to convert to " #target_type); \ + return (target_type) -1; \ + } \ + } \ + return (target_type) value; \ } - return (int)__Pyx_PyInt_AsLong(x); -} #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -#endif -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { - const unsigned long neg_one = (unsigned long)-1, const_zero = 0; +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)PyLong_AsUnsignedLong(x); + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG) } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned long)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - return (unsigned long)PyLong_AsLong(x); - } - } else { - unsigned long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned long)-1; - val = __Pyx_PyInt_AsUnsignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { - const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } - } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + "can't convert negative value to long"); + return (long) -1; } -#endif -#endif - return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); - } - } else { - unsigned PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsUnsignedLongLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { - const long neg_one = (long)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; + return (long) val; } - return (long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS + #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; case 1: return (long) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); - return (long)-1; + return (long) -1; + } + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(long) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong) } - return (long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS + #if CYTHON_USE_PYLONG_INTERNALS if (sizeof(digit) <= sizeof(long)) { switch (Py_SIZE(x)) { case 0: return 0; @@ -1143,198 +908,146 @@ static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { case -1: return -(long) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif -#endif - return (long)PyLong_AsLong(x); - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (long)-1; - val = __Pyx_PyInt_AsLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { - const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; - } - return (PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong) + } else if (sizeof(long) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong) } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); } - return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; } #endif -#endif - return (PY_LONG_LONG)PyLong_AsLongLong(x); + return (long) -1; } } else { - PY_LONG_LONG val; + long val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsLongLong(tmp); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } } #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif #endif -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { - const signed long neg_one = (signed long)-1, const_zero = 0; +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; + } + return (int) val; } - return (signed long)val; } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return (signed long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return (int) ((PyLongObject*)x)->ob_digit[0]; } } -#endif + #endif #endif if (unlikely(Py_SIZE(x) < 0)) { PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; + "can't convert negative value to int"); + return (int) -1; + } + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong) + } else if (sizeof(int) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong) } - return (signed long)PyLong_AsUnsignedLong(x); } else { #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed long)) { + #if CYTHON_USE_PYLONG_INTERNALS + if (sizeof(digit) <= sizeof(int)) { switch (Py_SIZE(x)) { case 0: return 0; - case 1: return +(signed long) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0]; + case 1: return +(int) ((PyLongObject*)x)->ob_digit[0]; + case -1: return -(int) ((PyLongObject*)x)->ob_digit[0]; } } + #endif #endif -#endif - return (signed long)PyLong_AsLong(x); - } - } else { - signed long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed long)-1; - val = __Pyx_PyInt_AsSignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS -#include "longintrepr.h" -#endif -#endif -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { - const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; - } - return (signed PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong) + } else if (sizeof(int) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong) } -#endif -#endif - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); } - return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { -#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -#if CYTHON_USE_PYLONG_INTERNALS - if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) { - switch (Py_SIZE(x)) { - case 0: return 0; - case 1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0]; - } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; } #endif -#endif - return (signed PY_LONG_LONG)PyLong_AsLongLong(x); + return (int) -1; } } else { - signed PY_LONG_LONG val; + int val; PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsSignedLongLong(tmp); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } @@ -1600,10 +1313,18 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_ #endif /* PY_VERSION_HEX < 0x03030000 */ } else #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */ +#if !CYTHON_COMPILING_IN_PYPY +#if PY_VERSION_HEX >= 0x02060000 + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif +#endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); - if (r < 0) { + if (unlikely(r < 0)) { return NULL; } else { return result; @@ -1648,7 +1369,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { if (!PyLong_Check(res)) { #endif PyErr_Format(PyExc_TypeError, - "__%s__ returned non-%s (type %.200s)", + "__%.4s__ returned non-%.4s (type %.200s)", name, name, Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; @@ -1660,9 +1381,35 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { } return res; } +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif +#endif static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; - PyObject* x = PyNumber_Index(b); + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) + return PyInt_AS_LONG(b); +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(b)) { + case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; + case 0: return 0; + case 1: return ((PyLongObject*)b)->ob_digit[0]; + } + #endif + #endif + #if PY_VERSION_HEX < 0x02060000 + return PyInt_AsSsize_t(b); + #else + return PyLong_AsSsize_t(b); + #endif + } + x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); @@ -1681,16 +1428,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); #endif } -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { - unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred()) - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t)-1; - } - return (size_t)val; -} #endif /* Py_PYTHON_H */ diff --git a/tests/test_trie.py b/tests/test_trie.py index e28c918..8d9999d 100644 --- a/tests/test_trie.py +++ b/tests/test_trie.py @@ -138,6 +138,18 @@ def test_trie_items(): assert trie.items() == [('bar', 'foo'), ('foo', 10), ('foobar', 30)] assert trie.keys() == ['bar', 'foo', 'foobar'] +def test_trie_suffixes(): + trie = datrie.Trie(string.ascii_lowercase) + + trie['pro']=1 + trie['prof']=2 + trie['product']=3 + trie['production']=4 + trie['producer'] = 5 + trie['producers']= 6 + trie['productivity']=7 + + assert trie.suffixes('pro') == ['', 'ducer', 'ducers', 'duct', 'duction', 'ductivity', 'f'] def test_trie_len(): trie = datrie.Trie(string.ascii_lowercase)