123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232 |
- /*
- * General object operations and protocol implementations,
- * including their specialisations for certain builtins.
- *
- * Optional optimisations for builtins are in Optimize.c.
- *
- * Required replacements of builtins are in Builtins.c.
- */
- /////////////// RaiseNoneIterError.proto ///////////////
- static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
- /////////////// RaiseNoneIterError ///////////////
- static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- }
- /////////////// RaiseTooManyValuesToUnpack.proto ///////////////
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
- /////////////// RaiseTooManyValuesToUnpack ///////////////
- static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
- }
- /////////////// RaiseNeedMoreValuesToUnpack.proto ///////////////
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
- /////////////// RaiseNeedMoreValuesToUnpack ///////////////
- static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
- }
- /////////////// UnpackTupleError.proto ///////////////
- static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
- /////////////// UnpackTupleError ///////////////
- //@requires: RaiseNoneIterError
- //@requires: RaiseNeedMoreValuesToUnpack
- //@requires: RaiseTooManyValuesToUnpack
- static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
- if (t == Py_None) {
- __Pyx_RaiseNoneNotIterableError();
- } else if (PyTuple_GET_SIZE(t) < index) {
- __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
- } else {
- __Pyx_RaiseTooManyValuesError(index);
- }
- }
- /////////////// UnpackItemEndCheck.proto ///////////////
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
- /////////////// UnpackItemEndCheck ///////////////
- //@requires: RaiseTooManyValuesToUnpack
- //@requires: IterFinish
- static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- } else {
- return __Pyx_IterFinish();
- }
- return 0;
- }
- /////////////// UnpackTuple2.proto ///////////////
- #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple) \
- (likely(is_tuple || PyTuple_Check(tuple)) ? \
- (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ? \
- __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) : \
- (__Pyx_UnpackTupleError(tuple, 2), -1)) : \
- __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
- static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
- PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
- static int __Pyx_unpack_tuple2_generic(
- PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
- /////////////// UnpackTuple2 ///////////////
- //@requires: UnpackItemEndCheck
- //@requires: UnpackTupleError
- //@requires: RaiseNeedMoreValuesToUnpack
- static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
- PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
- PyObject *value1 = NULL, *value2 = NULL;
- #if CYTHON_COMPILING_IN_PYPY
- value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad;
- value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad;
- #else
- value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1);
- value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2);
- #endif
- if (decref_tuple) {
- Py_DECREF(tuple);
- }
- *pvalue1 = value1;
- *pvalue2 = value2;
- return 0;
- #if CYTHON_COMPILING_IN_PYPY
- bad:
- Py_XDECREF(value1);
- Py_XDECREF(value2);
- if (decref_tuple) { Py_XDECREF(tuple); }
- return -1;
- #endif
- }
- static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
- int has_known_size, int decref_tuple) {
- Py_ssize_t index;
- PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
- iternextfunc iternext;
- iter = PyObject_GetIter(tuple);
- if (unlikely(!iter)) goto bad;
- if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
- iternext = Py_TYPE(iter)->tp_iternext;
- value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
- value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
- if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
- Py_DECREF(iter);
- *pvalue1 = value1;
- *pvalue2 = value2;
- return 0;
- unpacking_failed:
- if (!has_known_size && __Pyx_IterFinish() == 0)
- __Pyx_RaiseNeedMoreValuesError(index);
- bad:
- Py_XDECREF(iter);
- Py_XDECREF(value1);
- Py_XDECREF(value2);
- if (decref_tuple) { Py_XDECREF(tuple); }
- return -1;
- }
- /////////////// IterNext.proto ///////////////
- #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
- static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/
- /////////////// IterNext ///////////////
- //@requires: Exceptions.c::PyThreadStateGet
- //@requires: Exceptions.c::PyErrFetchRestore
- static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
- PyObject* exc_type;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- exc_type = __Pyx_PyErr_Occurred();
- if (unlikely(exc_type)) {
- if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(defval);
- return defval;
- }
- if (defval) {
- Py_INCREF(defval);
- return defval;
- }
- __Pyx_PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
- static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
- PyErr_Format(PyExc_TypeError,
- "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
- }
- // originally copied from Py3's builtin_next()
- static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
- PyObject* next;
- // We always do a quick slot check because calling PyIter_Check() is so wasteful.
- iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
- if (likely(iternext)) {
- #if CYTHON_USE_TYPE_SLOTS
- next = iternext(iterator);
- if (likely(next))
- return next;
- #if PY_VERSION_HEX >= 0x02070000
- if (unlikely(iternext == &_PyObject_NextNotImplemented))
- return NULL;
- #endif
- #else
- // Since the slot was set, assume that PyIter_Next() will likely succeed, and properly fail otherwise.
- // Note: PyIter_Next() crashes in CPython if "tp_iternext" is NULL.
- next = PyIter_Next(iterator);
- if (likely(next))
- return next;
- #endif
- } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
- // If CYTHON_USE_TYPE_SLOTS, then the slot was not set and we don't have an iterable.
- // Otherwise, don't trust "tp_iternext" and rely on PyIter_Check().
- __Pyx_PyIter_Next_ErrorNoIterator(iterator);
- return NULL;
- }
- #if !CYTHON_USE_TYPE_SLOTS
- else {
- // We have an iterator with an empty "tp_iternext", but didn't call next() on it yet.
- next = PyIter_Next(iterator);
- if (likely(next))
- return next;
- }
- #endif
- return __Pyx_PyIter_Next2Default(defval);
- }
- /////////////// IterFinish.proto ///////////////
- static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/
- /////////////// IterFinish ///////////////
- // When PyIter_Next(iter) has returned NULL in order to signal termination,
- // this function does the right cleanup and returns 0 on success. If it
- // detects an error that occurred in the iterator, it returns -1.
- static CYTHON_INLINE int __Pyx_IterFinish(void) {
- #if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
- #else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
- #endif
- }
- /////////////// ObjectGetItem.proto ///////////////
- #if CYTHON_USE_TYPE_SLOTS
- static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);/*proto*/
- #else
- #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
- #endif
- /////////////// ObjectGetItem ///////////////
- // //@requires: GetItemInt - added in IndexNode as it uses templating.
- #if CYTHON_USE_TYPE_SLOTS
- static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- // Error handling code -- only manage OverflowError differently.
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
- }
- static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
- }
- #endif
- /////////////// DictGetItem.proto ///////////////
- #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
- static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);/*proto*/
- #define __Pyx_PyObject_Dict_GetItem(obj, name) \
- (likely(PyDict_CheckExact(obj)) ? \
- __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
- #else
- #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
- #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
- #endif
- /////////////// DictGetItem ///////////////
- #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
- static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
- PyObject *value;
- value = PyDict_GetItemWithError(d, key);
- if (unlikely(!value)) {
- if (!PyErr_Occurred()) {
- PyObject* args = PyTuple_Pack(1, key);
- if (likely(args))
- PyErr_SetObject(PyExc_KeyError, args);
- Py_XDECREF(args);
- }
- return NULL;
- }
- Py_INCREF(value);
- return value;
- }
- #endif
- /////////////// GetItemInt.proto ///////////////
- #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))))
- {{for type in ['List', 'Tuple']}}
- #define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
- __Pyx_GetItemInt_{{type}}_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
- (PyErr_SetString(PyExc_IndexError, "{{ type.lower() }} index out of range"), (PyObject*)NULL))
- static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
- {{endfor}}
- static 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);
- /////////////// GetItemInt ///////////////
- static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
- }
- {{for type in ['List', 'Tuple']}}
- static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += Py{{type}}_GET_SIZE(o);
- }
- if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < Py{{type}}_GET_SIZE(o)))) {
- PyObject *r = Py{{type}}_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
- #else
- return PySequence_GetItem(o, i);
- #endif
- }
- {{endfor}}
- static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- // inlined PySequence_GetItem() + special cased length overflow
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
- #else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
- #endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
- }
- /////////////// SetItemInt.proto ///////////////
- #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 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);
- /////////////// SetItemInt ///////////////
- static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
- int r;
- if (!j) return -1;
- r = PyObject_SetItem(o, j, v);
- Py_DECREF(j);
- return r;
- }
- static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
- CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
- if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
- PyObject* old = PyList_GET_ITEM(o, n);
- Py_INCREF(v);
- PyList_SET_ITEM(o, n, v);
- Py_DECREF(old);
- return 1;
- }
- } else {
- // inlined PySequence_SetItem() + special cased length overflow
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_ass_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return -1;
- PyErr_Clear();
- }
- }
- return m->sq_ass_item(o, i, v);
- }
- }
- #else
- #if CYTHON_COMPILING_IN_PYPY
- if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
- #else
- if (is_list || PySequence_Check(o)) {
- #endif
- return PySequence_SetItem(o, i, v);
- }
- #endif
- return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
- }
- /////////////// DelItemInt.proto ///////////////
- #define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
- __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
- __Pyx_DelItem_Generic(o, to_py_func(i))))
- static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j);
- static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound);
- /////////////// DelItemInt ///////////////
- static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
- int r;
- if (!j) return -1;
- r = PyObject_DelItem(o, j);
- Py_DECREF(j);
- return r;
- }
- static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_UNUSED int is_list, CYTHON_NCP_UNUSED int wraparound) {
- #if !CYTHON_USE_TYPE_SLOTS
- if (is_list || PySequence_Check(o)) {
- return PySequence_DelItem(o, i);
- }
- #else
- // inlined PySequence_DelItem() + special cased length overflow
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_ass_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return -1;
- PyErr_Clear();
- }
- }
- return m->sq_ass_item(o, i, (PyObject *)NULL);
- }
- #endif
- return __Pyx_DelItem_Generic(o, PyInt_FromSsize_t(i));
- }
- /////////////// SliceObject.proto ///////////////
- // we pass pointer addresses to show the C compiler what is NULL and what isn't
- {{if access == 'Get'}}
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
- PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
- int has_cstart, int has_cstop, int wraparound);
- {{else}}
- #define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) \
- __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
- // we pass pointer addresses to show the C compiler what is NULL and what isn't
- static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
- PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
- int has_cstart, int has_cstop, int wraparound);
- {{endif}}
- /////////////// SliceObject ///////////////
- {{if access == 'Get'}}
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
- {{else}}
- static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
- {{endif}}
- Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
- int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
- #if CYTHON_USE_TYPE_SLOTS
- PyMappingMethods* mp;
- #if PY_MAJOR_VERSION < 3
- PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
- if (likely(ms && ms->sq_{{if access == 'Set'}}ass_{{endif}}slice)) {
- if (!has_cstart) {
- if (_py_start && (*_py_start != Py_None)) {
- cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
- if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstart = 0;
- }
- if (!has_cstop) {
- if (_py_stop && (*_py_stop != Py_None)) {
- cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
- if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstop = PY_SSIZE_T_MAX;
- }
- if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
- Py_ssize_t l = ms->sq_length(obj);
- if (likely(l >= 0)) {
- if (cstop < 0) {
- cstop += l;
- if (cstop < 0) cstop = 0;
- }
- if (cstart < 0) {
- cstart += l;
- if (cstart < 0) cstart = 0;
- }
- } else {
- // if length > max(Py_ssize_t), maybe the object can wrap around itself?
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- goto bad;
- PyErr_Clear();
- }
- }
- {{if access == 'Get'}}
- return ms->sq_slice(obj, cstart, cstop);
- {{else}}
- return ms->sq_ass_slice(obj, cstart, cstop, value);
- {{endif}}
- }
- #endif
- mp = Py_TYPE(obj)->tp_as_mapping;
- {{if access == 'Get'}}
- if (likely(mp && mp->mp_subscript))
- {{else}}
- if (likely(mp && mp->mp_ass_subscript))
- {{endif}}
- #endif
- {
- {{if access == 'Get'}}PyObject*{{else}}int{{endif}} result;
- PyObject *py_slice, *py_start, *py_stop;
- if (_py_slice) {
- py_slice = *_py_slice;
- } else {
- PyObject* owned_start = NULL;
- PyObject* owned_stop = NULL;
- if (_py_start) {
- py_start = *_py_start;
- } else {
- if (has_cstart) {
- owned_start = py_start = PyInt_FromSsize_t(cstart);
- if (unlikely(!py_start)) goto bad;
- } else
- py_start = Py_None;
- }
- if (_py_stop) {
- py_stop = *_py_stop;
- } else {
- if (has_cstop) {
- owned_stop = py_stop = PyInt_FromSsize_t(cstop);
- if (unlikely(!py_stop)) {
- Py_XDECREF(owned_start);
- goto bad;
- }
- } else
- py_stop = Py_None;
- }
- py_slice = PySlice_New(py_start, py_stop, Py_None);
- Py_XDECREF(owned_start);
- Py_XDECREF(owned_stop);
- if (unlikely(!py_slice)) goto bad;
- }
- #if CYTHON_USE_TYPE_SLOTS
- {{if access == 'Get'}}
- result = mp->mp_subscript(obj, py_slice);
- #else
- result = PyObject_GetItem(obj, py_slice);
- {{else}}
- result = mp->mp_ass_subscript(obj, py_slice, value);
- #else
- result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
- {{endif}}
- #endif
- if (!_py_slice) {
- Py_DECREF(py_slice);
- }
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- {{if access == 'Get'}}
- "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
- {{else}}
- "'%.200s' object does not support slice %.10s",
- Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
- {{endif}}
- bad:
- return {{if access == 'Get'}}NULL{{else}}-1{{endif}};
- }
- /////////////// SliceTupleAndList.proto ///////////////
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
- static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
- #else
- #define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
- #define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
- #endif
- /////////////// SliceTupleAndList ///////////////
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
- Py_ssize_t start = *_start, stop = *_stop, length = *_length;
- if (start < 0) {
- start += length;
- if (start < 0)
- start = 0;
- }
- if (stop < 0)
- stop += length;
- else if (stop > length)
- stop = length;
- *_length = stop - start;
- *_start = start;
- *_stop = stop;
- }
- static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
- PyObject *v;
- Py_ssize_t i;
- for (i = 0; i < length; i++) {
- v = dest[i] = src[i];
- Py_INCREF(v);
- }
- }
- {{for type in ['List', 'Tuple']}}
- static CYTHON_INLINE PyObject* __Pyx_Py{{type}}_GetSlice(
- PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
- PyObject* dest;
- Py_ssize_t length = Py{{type}}_GET_SIZE(src);
- __Pyx_crop_slice(&start, &stop, &length);
- if (unlikely(length <= 0))
- return Py{{type}}_New(0);
- dest = Py{{type}}_New(length);
- if (unlikely(!dest))
- return NULL;
- __Pyx_copy_object_array(
- ((Py{{type}}Object*)src)->ob_item + start,
- ((Py{{type}}Object*)dest)->ob_item,
- length);
- return dest;
- }
- {{endfor}}
- #endif
- /////////////// CalculateMetaclass.proto ///////////////
- static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
- /////////////// CalculateMetaclass ///////////////
- 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;
- }
- // else:
- 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
- }
- // make owned reference
- Py_INCREF((PyObject*) metaclass);
- return (PyObject*) metaclass;
- }
- /////////////// FindInheritedMetaclass.proto ///////////////
- static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases); /*proto*/
- /////////////// FindInheritedMetaclass ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: CalculateMetaclass
- static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases) {
- PyObject *metaclass;
- if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
- PyTypeObject *metatype;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- PyObject *base = PyTuple_GET_ITEM(bases, 0);
- #else
- PyObject *base = PySequence_ITEM(bases, 0);
- #endif
- #if PY_MAJOR_VERSION < 3
- PyObject* basetype = __Pyx_PyObject_GetAttrStr(base, PYIDENT("__class__"));
- if (basetype) {
- metatype = (PyType_Check(basetype)) ? ((PyTypeObject*) basetype) : NULL;
- } else {
- PyErr_Clear();
- metatype = Py_TYPE(base);
- basetype = (PyObject*) metatype;
- Py_INCREF(basetype);
- }
- #else
- metatype = Py_TYPE(base);
- #endif
- metaclass = __Pyx_CalculateMetaclass(metatype, bases);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(base);
- #endif
- #if PY_MAJOR_VERSION < 3
- Py_DECREF(basetype);
- #endif
- } else {
- // no bases => use default metaclass
- #if PY_MAJOR_VERSION < 3
- metaclass = (PyObject *) &PyClass_Type;
- #else
- metaclass = (PyObject *) &PyType_Type;
- #endif
- Py_INCREF(metaclass);
- }
- return metaclass;
- }
- /////////////// Py3MetaclassGet.proto ///////////////
- static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*/
- /////////////// Py3MetaclassGet ///////////////
- //@requires: FindInheritedMetaclass
- //@requires: CalculateMetaclass
- static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw) {
- PyObject *metaclass = mkw ? __Pyx_PyDict_GetItemStr(mkw, PYIDENT("metaclass")) : NULL;
- if (metaclass) {
- Py_INCREF(metaclass);
- if (PyDict_DelItem(mkw, PYIDENT("metaclass")) < 0) {
- Py_DECREF(metaclass);
- return NULL;
- }
- if (PyType_Check(metaclass)) {
- PyObject* orig = metaclass;
- metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
- Py_DECREF(orig);
- }
- return metaclass;
- }
- return __Pyx_FindInheritedMetaclass(bases);
- }
- /////////////// CreateClass.proto ///////////////
- static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
- PyObject *qualname, PyObject *modname); /*proto*/
- /////////////// CreateClass ///////////////
- //@requires: FindInheritedMetaclass
- //@requires: CalculateMetaclass
- static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
- PyObject *qualname, PyObject *modname) {
- PyObject *result;
- PyObject *metaclass;
- if (PyDict_SetItem(dict, PYIDENT("__module__"), modname) < 0)
- return NULL;
- if (PyDict_SetItem(dict, PYIDENT("__qualname__"), qualname) < 0)
- return NULL;
- /* Python2 __metaclass__ */
- metaclass = __Pyx_PyDict_GetItemStr(dict, PYIDENT("__metaclass__"));
- if (metaclass) {
- Py_INCREF(metaclass);
- if (PyType_Check(metaclass)) {
- PyObject* orig = metaclass;
- metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
- Py_DECREF(orig);
- }
- } else {
- metaclass = __Pyx_FindInheritedMetaclass(bases);
- }
- if (unlikely(!metaclass))
- return NULL;
- result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
- Py_DECREF(metaclass);
- return result;
- }
- /////////////// Py3ClassCreate.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*/
- /////////////// Py3ClassCreate ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: CalculateMetaclass
- 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, PYIDENT("__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;
- /* Required here to emulate assignment order */
- if (unlikely(PyObject_SetItem(ns, PYIDENT("__module__"), modname) < 0)) goto bad;
- if (unlikely(PyObject_SetItem(ns, PYIDENT("__qualname__"), qualname) < 0)) goto bad;
- if (unlikely(doc && PyObject_SetItem(ns, PYIDENT("__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) {
- /* honour Python2 __metaclass__ for backward compatibility */
- owned_metaclass = PyObject_GetItem(dict, PYIDENT("__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;
- }
- /////////////// ExtTypeTest.proto ///////////////
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
- /////////////// ExtTypeTest ///////////////
- static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
- }
- /////////////// CallableCheck.proto ///////////////
- #if CYTHON_USE_TYPE_SLOTS && PY_MAJOR_VERSION >= 3
- #define __Pyx_PyCallable_Check(obj) ((obj)->ob_type->tp_call != NULL)
- #else
- #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
- #endif
- /////////////// PyDictContains.proto ///////////////
- static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
- int result = PyDict_Contains(dict, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
- }
- /////////////// PySetContains.proto ///////////////
- static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); /* proto */
- /////////////// PySetContains ///////////////
- //@requires: Builtins.c::pyfrozenset_new
- static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
- int result = -1;
- if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
- /* Convert key to frozenset */
- PyObject *tmpkey;
- PyErr_Clear();
- tmpkey = __Pyx_PyFrozenSet_New(key);
- if (tmpkey != NULL) {
- result = PySet_Contains(set, tmpkey);
- Py_DECREF(tmpkey);
- }
- }
- return result;
- }
- static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
- int result = PySet_Contains(set, key);
- if (unlikely(result < 0)) {
- result = __Pyx_PySet_ContainsUnhashable(set, key);
- }
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
- }
- /////////////// PySequenceContains.proto ///////////////
- static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
- int result = PySequence_Contains(seq, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
- }
- /////////////// PyBoolOrNullFromLong.proto ///////////////
- static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
- return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
- }
- /////////////// GetBuiltinName.proto ///////////////
- static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
- /////////////// GetBuiltinName ///////////////
- //@requires: PyObjectGetAttrStr
- //@substitute: naming
- static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr($builtins_cname, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
- #if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
- #else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
- #endif
- }
- return result;
- }
- /////////////// GetNameInClass.proto ///////////////
- static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/
- /////////////// GetNameInClass ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: GetModuleGlobalName
- //@requires: Exceptions.c::PyThreadStateGet
- //@requires: Exceptions.c::PyErrFetchRestore
- //@requires: Exceptions.c::PyErrExceptionMatches
- static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- return __Pyx_GetModuleGlobalName(name);
- }
- static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
- PyObject *result;
- result = __Pyx_PyObject_GetAttrStr(nmspace, name);
- if (!result) {
- result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
- }
- return result;
- }
- /////////////// SetNameInClass.proto ///////////////
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- // Identifier names are always interned and have a pre-calculated hash value.
- #define __Pyx_SetNameInClass(ns, name, value) \
- (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
- #elif CYTHON_COMPILING_IN_CPYTHON
- #define __Pyx_SetNameInClass(ns, name, value) \
- (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
- #else
- #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
- #endif
- /////////////// GetModuleGlobalName.proto ///////////////
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
- /////////////// GetModuleGlobalName ///////////////
- //@requires: GetBuiltinName
- //@substitute: naming
- static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
- PyObject *result;
- #if !CYTHON_AVOID_BORROWED_REFS
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- // Identifier names are always interned and have a pre-calculated hash value.
- result = _PyDict_GetItem_KnownHash($moddict_cname, name, ((PyASCIIObject *) name)->hash);
- if (likely(result)) {
- Py_INCREF(result);
- } else if (unlikely(PyErr_Occurred())) {
- result = NULL;
- } else {
- #else
- result = PyDict_GetItem($moddict_cname, name);
- if (likely(result)) {
- Py_INCREF(result);
- } else {
- #endif
- #else
- result = PyObject_GetItem($moddict_cname, name);
- if (!result) {
- PyErr_Clear();
- #endif
- result = __Pyx_GetBuiltinName(name);
- }
- return result;
- }
- //////////////////// GetAttr.proto ////////////////////
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /*proto*/
- //////////////////// GetAttr ////////////////////
- //@requires: PyObjectGetAttrStr
- static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
- #if CYTHON_USE_TYPE_SLOTS
- #if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
- #else
- if (likely(PyString_Check(n)))
- #endif
- return __Pyx_PyObject_GetAttrStr(o, n);
- #endif
- return PyObject_GetAttr(o, n);
- }
- /////////////// PyObjectLookupSpecial.proto ///////////////
- //@requires: PyObjectGetAttrStr
- #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
- 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
- // adapted from CPython's special_lookup() in ceval.c
- 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
- /////////////// PyObject_GenericGetAttrNoDict.proto ///////////////
- // Setting "tp_getattro" to anything but "PyObject_GenericGetAttr" disables fast method calls in Py3.7.
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
- #else
- // No-args macro to allow function pointer assignment.
- #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
- #endif
- /////////////// PyObject_GenericGetAttrNoDict ///////////////
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
- static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
- #if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
- #else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
- #endif
- return NULL;
- }
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- // Copied and adapted from _PyObject_GenericGetAttrWithDict() in CPython 2.6/3.7.
- // To be used in the "tp_getattro" slot of extension types that have no instance dict and cannot be subclassed.
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- // Optimise for the non-descriptor case because it is faster.
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
- }
- #endif
- /////////////// PyObject_GenericGetAttr.proto ///////////////
- // Setting "tp_getattro" to anything but "PyObject_GenericGetAttr" disables fast method calls in Py3.7.
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
- static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
- #else
- // No-args macro to allow function pointer assignment.
- #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
- #endif
- /////////////// PyObject_GenericGetAttr ///////////////
- //@requires: PyObject_GenericGetAttrNoDict
- #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
- static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
- }
- #endif
- /////////////// PyObjectGetAttrStr.proto ///////////////
- #if CYTHON_USE_TYPE_SLOTS
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);/*proto*/
- #else
- #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
- #endif
- /////////////// PyObjectGetAttrStr ///////////////
- #if CYTHON_USE_TYPE_SLOTS
- static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
- #if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
- #endif
- return PyObject_GetAttr(obj, attr_name);
- }
- #endif
- /////////////// PyObjectSetAttrStr.proto ///////////////
- #if CYTHON_USE_TYPE_SLOTS
- #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
- static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);/*proto*/
- #else
- #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
- #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
- #endif
- /////////////// PyObjectSetAttrStr ///////////////
- #if CYTHON_USE_TYPE_SLOTS
- static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
- #if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
- #endif
- return PyObject_SetAttr(obj, attr_name, value);
- }
- #endif
- /////////////// UnpackUnboundCMethod.proto ///////////////
- typedef struct {
- PyObject *type;
- PyObject **method_name;
- // "func" is set on first access (direct C function pointer)
- PyCFunction func;
- // "method" is set on first access (fallback)
- PyObject *method;
- int flag;
- } __Pyx_CachedCFunction;
- /////////////// UnpackUnboundCMethod ///////////////
- //@requires: PyObjectGetAttrStr
- static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
- #if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- // method dscriptor type isn't exported in Py2.x, cannot easily check the type there
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST);
- }
- #endif
- return 0;
- }
- /////////////// CallUnboundCMethod0.proto ///////////////
- //@substitute: naming
- static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); /*proto*/
- #if CYTHON_COMPILING_IN_CPYTHON
- // FASTCALL methods receive "&empty_tuple" as simple "PyObject[0]*"
- #define __Pyx_CallUnboundCMethod0(cfunc, self) \
- (likely((cfunc)->func) ? \
- (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) : \
- (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ? \
- (PY_VERSION_HEX >= 0x030700A0 ? \
- (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &$empty_tuple, 0) : \
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &$empty_tuple, 0, NULL)) : \
- (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ? \
- (*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &$empty_tuple, 0, NULL) : \
- (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, $empty_tuple, NULL)) : \
- ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, $empty_tuple) : \
- __Pyx__CallUnboundCMethod0(cfunc, self)))))) : \
- __Pyx__CallUnboundCMethod0(cfunc, self))
- #else
- #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
- #endif
- /////////////// CallUnboundCMethod0 ///////////////
- //@requires: UnpackUnboundCMethod
- //@requires: PyObjectCall
- static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
- #if CYTHON_ASSUME_SAFE_MACROS
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- #else
- args = PyTuple_Pack(1, self);
- if (unlikely(!args)) goto bad;
- #endif
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- Py_DECREF(args);
- bad:
- return result;
- }
- /////////////// CallUnboundCMethod1.proto ///////////////
- static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/
- #else
- #define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
- #endif
- /////////////// CallUnboundCMethod1 ///////////////
- //@requires: UnpackUnboundCMethod
- //@requires: PyObjectCall
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
- if (likely(cfunc->func)) {
- int flag = cfunc->flag;
- // Not using #ifdefs for PY_VERSION_HEX to avoid C compiler warnings about unused functions.
- if (flag == METH_O) {
- return (*(cfunc->func))(self, arg);
- } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
- if (PY_VERSION_HEX >= 0x030700A0) {
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, &arg, 1);
- } else {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, &arg, 1, NULL);
- }
- }
- return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
- }
- #endif
- static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
- #if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
- #else
- args = PyTuple_Pack(2, self, arg);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- #endif
- bad:
- Py_XDECREF(args);
- return result;
- }
- /////////////// CallUnboundCMethod2.proto ///////////////
- static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); /*proto*/
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
- static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); /*proto*/
- #else
- #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
- #endif
- /////////////// CallUnboundCMethod2 ///////////////
- //@requires: UnpackUnboundCMethod
- //@requires: PyObjectCall
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
- static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
- if (likely(cfunc->func)) {
- PyObject *args[2] = {arg1, arg2};
- if (cfunc->flag == METH_FASTCALL) {
- #if PY_VERSION_HEX >= 0x030700A0
- return (*(__Pyx_PyCFunctionFast)cfunc->func)(self, args, 2);
- #else
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- #if PY_VERSION_HEX >= 0x030700A0
- if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
- return (*(__Pyx_PyCFunctionFastWithKeywords)cfunc->func)(self, args, 2, NULL);
- #endif
- }
- return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
- }
- #endif
- static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
- #if CYTHON_COMPILING_IN_CPYTHON
- if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto bad;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- if (cfunc->flag & METH_KEYWORDS)
- result = (*(PyCFunctionWithKeywords)cfunc->func)(self, args, NULL);
- else
- result = (*cfunc->func)(self, args);
- } else {
- args = PyTuple_New(3);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 1, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 2, arg2);
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- }
- #else
- args = PyTuple_Pack(3, self, arg1, arg2);
- if (unlikely(!args)) goto bad;
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- #endif
- bad:
- Py_XDECREF(args);
- return result;
- }
- /////////////// PyObjectCallMethod0.proto ///////////////
- static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /*proto*/
- /////////////// PyObjectCallMethod0 ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: PyObjectCallOneArg
- //@requires: PyObjectCallNoArg
- static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
- PyObject *method, *result = NULL;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) goto bad;
- #if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *function = PyMethod_GET_FUNCTION(method);
- result = __Pyx_PyObject_CallOneArg(function, self);
- Py_DECREF(method);
- return result;
- }
- }
- #endif
- result = __Pyx_PyObject_CallNoArg(method);
- Py_DECREF(method);
- bad:
- return result;
- }
- /////////////// PyObjectCallMethod1.proto ///////////////
- static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /*proto*/
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg); /*proto*/
- /////////////// PyObjectCallMethod1 ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: PyObjectCallOneArg
- //@requires: PyFunctionFastCall
- //@requires: PyCFunctionFastCall
- static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = NULL;
- #if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
- #endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- // avoid "unused label" warning
- goto done;
- done:
- return result;
- }
- static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method, *result;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- result = __Pyx__PyObject_CallMethod1(method, arg);
- Py_DECREF(method);
- return result;
- }
- /////////////// PyObjectCallMethod2.proto ///////////////
- static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2); /*proto*/
- /////////////// PyObjectCallMethod2 ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: PyObjectCall
- //@requires: PyFunctionFastCall
- //@requires: PyCFunctionFastCall
- static PyObject* __Pyx_PyObject_CallMethod2(PyObject* obj, PyObject* method_name, PyObject* arg1, PyObject* arg2) {
- PyObject *args, *method, *result = NULL;
- method = __Pyx_PyObject_GetAttrStr(obj, method_name);
- if (unlikely(!method)) return NULL;
- #if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method)) && likely(PyMethod_GET_SELF(method))) {
- PyObject *self, *function;
- self = PyMethod_GET_SELF(method);
- function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[3] = {self, arg1, arg2};
- result = __Pyx_PyFunction_FastCall(function, args, 3);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[3] = {self, arg1, arg2};
- result = __Pyx_PyFunction_FastCall(function, args, 3);
- goto done;
- }
- #endif
- args = PyTuple_New(3);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 1, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 2, arg2);
- Py_INCREF(function);
- Py_DECREF(method);
- method = function;
- } else
- #endif
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(method)) {
- PyObject *args[2] = {arg1, arg2};
- result = __Pyx_PyFunction_FastCall(method, args, 2);
- goto done;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(method)) {
- PyObject *args[2] = {arg1, arg2};
- result = __Pyx_PyCFunction_FastCall(method, args, 2);
- goto done;
- } else
- #endif
- {
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- }
- result = __Pyx_PyObject_Call(method, args, NULL);
- Py_DECREF(args);
- done:
- Py_DECREF(method);
- return result;
- }
- /////////////// tp_new.proto ///////////////
- #define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL)
- static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
- return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs));
- }
- /////////////// PyObjectCall.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
- /////////////// PyObjectCall ///////////////
- #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 (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
- }
- #endif
- /////////////// PyObjectCallMethO.proto ///////////////
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); /*proto*/
- #endif
- /////////////// PyObjectCallMethO ///////////////
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
- }
- #endif
- /////////////// PyFunctionFastCall.proto ///////////////
- #if CYTHON_FAST_PYCALL
- #define __Pyx_PyFunction_FastCall(func, args, nargs) \
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
- // let's assume that the non-public C-API function might still change during the 3.6 beta phase
- #if 1 || PY_VERSION_HEX < 0x030600B1
- static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
- #else
- #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
- #endif
- #endif
- /////////////// PyFunctionFastCall ///////////////
- // copied from CPython 3.6 ceval.c
- #if CYTHON_FAST_PYCALL
- #include "frameobject.h"
- static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = f->f_localsplus;
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
- }
- #if 1 || PY_VERSION_HEX < 0x030600B1
- static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
- #if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
- //#if PY_VERSION_HEX >= 0x03050000
- //PyObject *name, *qualname;
- //#endif
- #endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
- #if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
- #endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- /* Fast paths */
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
- #if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
- //#if PY_VERSION_HEX >= 0x03050000
- //name = ((PyFunctionObject *)func) -> func_name;
- //qualname = ((PyFunctionObject *)func) -> func_qualname;
- //#endif
- #endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
- //#if PY_VERSION_HEX >= 0x03050000
- //return _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
- // args, nargs,
- // NULL, 0,
- // d, nd, kwdefs,
- // closure, name, qualname);
- //#elif PY_MAJOR_VERSION >= 3
- #if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
- #else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, nargs,
- k, (int)nk,
- d, (int)nd, closure);
- #endif
- Py_XDECREF(kwtuple);
- done:
- Py_LeaveRecursiveCall();
- return result;
- }
- #endif /* CPython < 3.6 */
- #endif /* CYTHON_FAST_PYCALL */
- /////////////// PyCFunctionFastCall.proto ///////////////
- #if CYTHON_FAST_PYCCALL
- static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
- #else
- #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
- #endif
- /////////////// PyCFunctionFastCall ///////////////
- #if CYTHON_FAST_PYCCALL
- static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
- }
- }
- #endif /* CYTHON_FAST_PYCCALL */
- /////////////// PyObjectCallOneArg.proto ///////////////
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /*proto*/
- /////////////// PyObjectCallOneArg ///////////////
- //@requires: PyObjectCallMethO
- //@requires: PyObjectCall
- //@requires: PyFunctionFastCall
- //@requires: PyCFunctionFastCall
- #if CYTHON_COMPILING_IN_CPYTHON
- static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
- }
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
- #endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- // fast and simple case that we are optimising for
- return __Pyx_PyObject_CallMethO(func, arg);
- #if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
- #endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
- }
- #else
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
- }
- #endif
- /////////////// PyObjectCallNoArg.proto ///////////////
- //@requires: PyObjectCall
- //@substitute: naming
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /*proto*/
- #else
- #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, $empty_tuple, NULL)
- #endif
- /////////////// PyObjectCallNoArg ///////////////
- //@requires: PyObjectCallMethO
- //@requires: PyObjectCall
- //@requires: PyFunctionFastCall
- //@substitute: naming
- #if CYTHON_COMPILING_IN_CPYTHON
- static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
- #endif
- #ifdef __Pyx_CyFunction_USED
- if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
- #else
- if (likely(PyCFunction_Check(func))) {
- #endif
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- // fast and simple case that we are optimising for
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, $empty_tuple, NULL);
- }
- #endif
- /////////////// MatrixMultiply.proto ///////////////
- #if PY_VERSION_HEX >= 0x03050000
- #define __Pyx_PyNumber_MatrixMultiply(x,y) PyNumber_MatrixMultiply(x,y)
- #define __Pyx_PyNumber_InPlaceMatrixMultiply(x,y) PyNumber_InPlaceMatrixMultiply(x,y)
- #else
- #define __Pyx_PyNumber_MatrixMultiply(x,y) __Pyx__PyNumber_MatrixMultiply(x, y, "@")
- static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name);
- static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y);
- #endif
- /////////////// MatrixMultiply ///////////////
- //@requires: PyObjectGetAttrStr
- //@requires: PyObjectCallOneArg
- //@requires: PyFunctionFastCall
- //@requires: PyCFunctionFastCall
- #if PY_VERSION_HEX < 0x03050000
- static PyObject* __Pyx_PyObject_CallMatrixMethod(PyObject* method, PyObject* arg) {
- // NOTE: eats the method reference
- PyObject *result = NULL;
- #if CYTHON_UNPACK_METHODS
- if (likely(PyMethod_Check(method))) {
- PyObject *self = PyMethod_GET_SELF(method);
- if (likely(self)) {
- PyObject *args;
- PyObject *function = PyMethod_GET_FUNCTION(method);
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {self, arg};
- result = __Pyx_PyCFunction_FastCall(function, args, 2);
- goto done;
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 1, arg);
- Py_INCREF(function);
- Py_DECREF(method); method = NULL;
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
- return result;
- }
- }
- #endif
- result = __Pyx_PyObject_CallOneArg(method, arg);
- done:
- Py_DECREF(method);
- return result;
- }
- #define __Pyx_TryMatrixMethod(x, y, py_method_name) { \
- PyObject *func = __Pyx_PyObject_GetAttrStr(x, py_method_name); \
- if (func) { \
- PyObject *result = __Pyx_PyObject_CallMatrixMethod(func, y); \
- if (result != Py_NotImplemented) \
- return result; \
- Py_DECREF(result); \
- } else { \
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) \
- return NULL; \
- PyErr_Clear(); \
- } \
- }
- static PyObject* __Pyx__PyNumber_MatrixMultiply(PyObject* x, PyObject* y, const char* op_name) {
- int right_is_subtype = PyObject_IsSubclass((PyObject*)Py_TYPE(y), (PyObject*)Py_TYPE(x));
- if (unlikely(right_is_subtype == -1))
- return NULL;
- if (right_is_subtype) {
- // to allow subtypes to override parent behaviour, try reversed operation first
- // see note at https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
- __Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__"))
- }
- __Pyx_TryMatrixMethod(x, y, PYIDENT("__matmul__"))
- if (!right_is_subtype) {
- __Pyx_TryMatrixMethod(y, x, PYIDENT("__rmatmul__"))
- }
- PyErr_Format(PyExc_TypeError,
- "unsupported operand type(s) for %.2s: '%.100s' and '%.100s'",
- op_name,
- Py_TYPE(x)->tp_name,
- Py_TYPE(y)->tp_name);
- return NULL;
- }
- static PyObject* __Pyx_PyNumber_InPlaceMatrixMultiply(PyObject* x, PyObject* y) {
- __Pyx_TryMatrixMethod(x, y, PYIDENT("__imatmul__"))
- return __Pyx__PyNumber_MatrixMultiply(x, y, "@=");
- }
- #undef __Pyx_TryMatrixMethod
- #endif
|