diff --git a/.travis.yml b/.travis.yml index 2574d2f..22b1030 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: python python: - "3.5" - "3.6" +before_install: + - sudo apt-get update + - sudo apt-get install pandoc -y + # command to install dependencies install: - pip install -r requirements_dev.txt @@ -10,3 +14,15 @@ install: script: - flake8 - python -m unittest +deploy: + provider: pypi + user: stegben + password: + secure: eihswW4KNxCa9Tn/iPcYE6mdlLHwMVWG+2Dll2WhuCj2+ZBL+zI4UHoGmSWqevwal39iBqb+9gwY8tALzCG1XDIYx2nXjz7dtvNlAyWTMg5IgyvxhqxARcrhiWsO9dqi/mUzdGdUthiIztlMF3torYqQDO3mZ67oGCZZSf+o5+KXJX49WnkbTOSDlDNG6ndsmJaAQGq8uxDIiIMzbD8tbIx2AM/eyd0s8KGbRaotQxViS7uPpqofUJql7QdWRnYHmp12joOx0P9g7EKShbPDDYikDGfgpXoAZMgHErIOIPP7ed0+vYp5sVP23y34pmyQFjuXn63l1u9+dicd2m3xVAAuY775evt2EX3zOgfjQmNVo8jKBWWaPbxznKiXT52DAQcB4Z/q0WgoA0q1RWnwqhzUvV1VQzJ57v4LnOuvba6bDXRQvKgNZIA7lTpeDwvxPYtIRtL2bUlyVoDUeNREBniZzSyPwXrehDasUurD1kyHg8+4uM/E3I2T6nrCQsPojZ9i6GP3JEiaZmyuBbCFrNxNUGIxeysaaE5vYpQxxZE6HPozDGmnUjJThA5mWhwBZ4d1t7PFK3RQl/JRo7GRSloEZi7V1gkzVcGKsU4njRWC1vORk9ue+FSqdarlgMCcbxr/A+b06QAi0EGbXkQP4m3TdzaNClOn7xOtn7OXXxE= + distributions: sdist + skip_cleanup: true + on: + tags: true + python: + - "3.5" + - "3.6" diff --git a/requirements_dev.txt b/requirements_dev.txt index 89443a8..372f66b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,3 +1,4 @@ flake8-config-yoctol==0.0.9 pycodestyle==2.3.1 +pypandoc -e . diff --git a/setup.py b/setup.py index 38f5986..bc250bd 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup, find_packages, Extension +from pathlib import Path try: @@ -35,9 +36,23 @@ ] +readme = Path(__file__).parent.joinpath('README.md') +if readme.exists(): + with readme.open() as f: + long_description = f.read() + try: + from pypandoc import convert_text + long_description = convert_text( + long_description, 'rst', format='md') + except ImportError: + print("warning: pypandoc module not found, could not convert Markdown to RST") +else: + long_description = '-' + + setup( name="uttut", - version='0.4.0', + version='0.5.0', description="Yoctol Utterance processing utilities", license="MIT", author="cph", diff --git a/uttut/elements.c b/uttut/elements.c index e3082d1..3cc6463 100644 --- a/uttut/elements.c +++ b/uttut/elements.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.28.1 */ +/* Generated by Cython 0.28.5 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,7 +7,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_28_1" +#define CYTHON_ABI "0_28_5" #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof @@ -453,6 +453,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) @@ -645,7 +646,7 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ @@ -753,7 +754,7 @@ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; +static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -1010,14 +1011,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) #endif -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); @@ -1168,6 +1161,14 @@ static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* k #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); @@ -2604,7 +2605,7 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_10to_dict(struct __pyx_obj_5u * * @classmethod * def from_dict(cls, dict entity, str utterance): # <<<<<<<<<<<<<< - * new_end = entity['end'] + 1 + * new_end = entity['end'] * entity_value = utterance[entity['start']: new_end] */ @@ -2682,9 +2683,9 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_2; Py_ssize_t __pyx_t_3; - Py_ssize_t __pyx_t_4; + PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("from_dict", 0); @@ -2692,7 +2693,7 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p /* "uttut/elements.pyx":84 * @classmethod * def from_dict(cls, dict entity, str utterance): - * new_end = entity['end'] + 1 # <<<<<<<<<<<<<< + * new_end = entity['end'] # <<<<<<<<<<<<<< * entity_value = utterance[entity['start']: new_end] * replacements = entity.get('replacements') */ @@ -2702,15 +2703,12 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p } __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_end); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_new_end = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_new_end = __pyx_t_1; + __pyx_t_1 = 0; /* "uttut/elements.pyx":85 * def from_dict(cls, dict entity, str utterance): - * new_end = entity['end'] + 1 + * new_end = entity['end'] * entity_value = utterance[entity['start']: new_end] # <<<<<<<<<<<<<< * replacements = entity.get('replacements') * return cls( @@ -2723,18 +2721,18 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 85, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_v_new_end); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __pyx_t_2 = PySequence_GetSlice(__pyx_v_utterance, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_entity_value = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_start); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_v_new_end); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) + __pyx_t_1 = PySequence_GetSlice(__pyx_v_utterance, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_entity_value = __pyx_t_1; + __pyx_t_1 = 0; /* "uttut/elements.pyx":86 - * new_end = entity['end'] + 1 + * new_end = entity['end'] * entity_value = utterance[entity['start']: new_end] * replacements = entity.get('replacements') # <<<<<<<<<<<<<< * return cls( @@ -2744,10 +2742,10 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 86, __pyx_L1_error) } - __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_entity, __pyx_n_s_replacements, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_replacements = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_entity, __pyx_n_s_replacements, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_replacements = __pyx_t_1; + __pyx_t_1 = 0; /* "uttut/elements.pyx":87 * entity_value = utterance[entity['start']: new_end] @@ -2765,16 +2763,16 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p * value=entity_value, * start=entity['start'], */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_entity == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 88, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_name, __pyx_t_1) < 0) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name, __pyx_t_4) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "uttut/elements.pyx":89 * return cls( @@ -2783,7 +2781,7 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p * start=entity['start'], * end=new_end, */ - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_value, __pyx_v_entity_value) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_value, __pyx_v_entity_value) < 0) __PYX_ERR(0, 88, __pyx_L1_error) /* "uttut/elements.pyx":90 * name=entity['name'], @@ -2796,10 +2794,10 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 90, __pyx_L1_error) } - __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_start); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_start, __pyx_t_1) < 0) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_entity, __pyx_n_s_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_start, __pyx_t_4) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "uttut/elements.pyx":91 * value=entity_value, @@ -2808,7 +2806,7 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p * replacements=[] if replacements is None else replacements, * ) */ - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_end, __pyx_v_new_end) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_end, __pyx_v_new_end) < 0) __PYX_ERR(0, 88, __pyx_L1_error) /* "uttut/elements.pyx":92 * start=entity['start'], @@ -2821,14 +2819,14 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p if ((__pyx_t_5 != 0)) { __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __pyx_t_6; + __pyx_t_4 = __pyx_t_6; __pyx_t_6 = 0; } else { __Pyx_INCREF(__pyx_v_replacements); - __pyx_t_1 = __pyx_v_replacements; + __pyx_t_4 = __pyx_v_replacements; } - if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_replacements, __pyx_t_1) < 0) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_replacements, __pyx_t_4) < 0) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "uttut/elements.pyx":87 * entity_value = utterance[entity['start']: new_end] @@ -2837,25 +2835,25 @@ static PyObject *__pyx_pf_5uttut_8elements_6Entity_12from_dict(PyTypeObject *__p * name=entity['name'], * value=entity_value, */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; /* "uttut/elements.pyx":83 * * @classmethod * def from_dict(cls, dict entity, str utterance): # <<<<<<<<<<<<<< - * new_end = entity['end'] + 1 + * new_end = entity['end'] * entity_value = utterance[entity['start']: new_end] */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("uttut.elements.Entity.from_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; @@ -9410,8 +9408,8 @@ static int __Pyx_modinit_function_import_code(void) { #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) - #define CYTHON_SMALL_CODE __attribute__((optimize("Os"))) +#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) + #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif @@ -9685,7 +9683,7 @@ if (!__Pyx_RefNanny) { * * @classmethod * def from_dict(cls, dict entity, str utterance): # <<<<<<<<<<<<<< - * new_end = entity['end'] + 1 + * new_end = entity['end'] * entity_value = utterance[entity['start']: new_end] */ __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_5uttut_8elements_Entity, __pyx_n_s_from_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) @@ -9696,7 +9694,7 @@ if (!__Pyx_RefNanny) { * * @classmethod # <<<<<<<<<<<<<< * def from_dict(cls, dict entity, str utterance): - * new_end = entity['end'] + 1 + * new_end = entity['end'] */ __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -10590,128 +10588,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } #endif -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long x; - long a = PyInt_AS_LONG(op1); - x = (long)((unsigned long)a + b); - if (likely((x^a) >= 0 || (x^b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla, llx; -#endif - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - } - x = a + b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla + llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - double result; - PyFPE_START_PROTECT("add", return NULL) - result = ((double)a) + (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); -} -#endif - /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { @@ -11732,6 +11608,128 @@ static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { } #endif +/* PyIntBinop */ + #if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, @@ -12192,6 +12190,9 @@ static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_li #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); @@ -12904,14 +12905,42 @@ static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, return res; } #endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; i