static PyObject *__pyx_f_7Stemmer_7Stemmer_stemWord(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_word = 0; char *__pyx_v_c_word; PyObject *__pyx_v_was_unicode; PyObject *__pyx_v_cacheditem; PyObject *__pyx_v_result; PyObject *__pyx_v_length; PyObject *__pyx_r; PyObject *__pyx_1 = 0; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; char *__pyx_5; Py_ssize_t __pyx_6; PyObject *__pyx_7 = 0; PyObject *__pyx_8 = 0; static char *__pyx_argnames[] = {"word",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_word)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_word); __pyx_v_was_unicode = Py_None; Py_INCREF(Py_None); __pyx_v_cacheditem = Py_None; Py_INCREF(Py_None); __pyx_v_result = Py_None; Py_INCREF(Py_None); __pyx_v_length = Py_None; Py_INCREF(Py_None); /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":171 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} Py_DECREF(__pyx_v_was_unicode); __pyx_v_was_unicode = __pyx_1; __pyx_1 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":172 */ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;} __pyx_2 = PyObject_IsInstance(__pyx_v_word,__pyx_1); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":173 */ __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;} Py_DECREF(__pyx_v_was_unicode); __pyx_v_was_unicode = __pyx_1; __pyx_1 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":174 */ __pyx_1 = PyObject_GetAttr(__pyx_v_word, __pyx_n_encode); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;} Py_INCREF(__pyx_k9p); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k9p); __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_v_word); __pyx_v_word = __pyx_4; __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":176 */ __pyx_2 = (((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->max_cache_size > 0); if (__pyx_2) { /*try:*/ { /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":178 */ __pyx_1 = PyObject_GetItem(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache, __pyx_v_word); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L4;} Py_DECREF(__pyx_v_cacheditem); __pyx_v_cacheditem = __pyx_1; __pyx_1 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":179 */ __pyx_3 = __Pyx_GetItemInt(__pyx_v_cacheditem, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L4;} Py_DECREF(__pyx_v_result); __pyx_v_result = __pyx_3; __pyx_3 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":180 */ if (__Pyx_SetItemInt(__pyx_v_cacheditem, 1, ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L4;} /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":181 */ __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L4;} __pyx_1 = PyNumber_Add(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; goto __pyx_L4;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter); ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter = __pyx_1; __pyx_1 = 0; } goto __pyx_L5; __pyx_L4:; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_1); __pyx_1 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":182 */ __pyx_2 = PyErr_ExceptionMatches(PyExc_KeyError); if (__pyx_2) { __Pyx_AddTraceback("Stemmer.stemWord"); if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;} /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":183 */ __pyx_5 = PyString_AsString(__pyx_v_word); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;} __pyx_v_c_word = __pyx_5; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":184 */ __pyx_6 = PyObject_Length(__pyx_v_word); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;} __pyx_v_c_word = ((char *)sb_stemmer_stem(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cobj,((sb_symbol *)__pyx_v_c_word),__pyx_6)); /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":185 */ __pyx_7 = PyInt_FromLong(sb_stemmer_length(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cobj)); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} Py_DECREF(__pyx_v_length); __pyx_v_length = __pyx_7; __pyx_7 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":186 */ __pyx_2 = PyInt_AsLong(__pyx_v_length); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;} __pyx_7 = PyString_FromStringAndSize(__pyx_v_c_word,__pyx_2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;} Py_DECREF(__pyx_v_result); __pyx_v_result = __pyx_7; __pyx_7 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":187 */ __pyx_7 = PyList_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} Py_INCREF(__pyx_v_result); PyList_SET_ITEM(__pyx_7, 0, __pyx_v_result); Py_INCREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter); PyList_SET_ITEM(__pyx_7, 1, ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter); if (PyObject_SetItem(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cache, __pyx_v_word, __pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":188 */ __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} __pyx_8 = PyNumber_Add(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter, __pyx_7); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter); ((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->counter = __pyx_8; __pyx_8 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":189 */ __pyx_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n___purgeCache); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;} __pyx_8 = PyObject_CallObject(__pyx_7, 0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(__pyx_8); __pyx_8 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; goto __pyx_L5; } goto __pyx_L1; __pyx_L5:; goto __pyx_L3; } /*else*/ { /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":191 */ __pyx_5 = PyString_AsString(__pyx_v_word); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;} __pyx_v_c_word = __pyx_5; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":192 */ __pyx_6 = PyObject_Length(__pyx_v_word); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L1;} __pyx_v_c_word = ((char *)sb_stemmer_stem(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cobj,((sb_symbol *)__pyx_v_c_word),__pyx_6)); /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":193 */ __pyx_7 = PyInt_FromLong(sb_stemmer_length(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self)->cobj)); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} Py_DECREF(__pyx_v_length); __pyx_v_length = __pyx_7; __pyx_7 = 0; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":194 */ __pyx_2 = PyInt_AsLong(__pyx_v_length); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} __pyx_8 = PyString_FromStringAndSize(__pyx_v_c_word,__pyx_2); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} Py_DECREF(__pyx_v_result); __pyx_v_result = __pyx_8; __pyx_8 = 0; } __pyx_L3:; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":196 */ __pyx_2 = PyObject_IsTrue(__pyx_v_was_unicode); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;} if (__pyx_2) { __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n_decode); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} Py_INCREF(__pyx_k9p); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k9p); __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; goto __pyx_L6; } __pyx_L6:; /* "/home/richard/private/Working/snowball/pystemmer/src/Stemmer.pyx":198 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_7); Py_XDECREF(__pyx_8); __Pyx_AddTraceback("Stemmer.Stemmer.stemWord"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_was_unicode); Py_DECREF(__pyx_v_cacheditem); Py_DECREF(__pyx_v_result); Py_DECREF(__pyx_v_length); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_word); return __pyx_r; }
static PyObject * record_subscript(ApgRecordObject* o, PyObject* item) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return NULL; if (i < 0) { i += Py_SIZE(o); } return record_item(o, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; PyObject* result; PyObject* it; PyObject **src, **dest; if (PySlice_GetIndicesEx( item, Py_SIZE(o), &start, &stop, &step, &slicelength) < 0) { return NULL; } if (slicelength <= 0) { return PyTuple_New(0); } else { result = PyTuple_New(slicelength); if (!result) return NULL; src = o->ob_item; dest = ((PyTupleObject *)result)->ob_item; for (cur = start, i = 0; i < slicelength; cur += step, i++) { it = src[cur]; Py_INCREF(it); dest[i] = it; } return result; } } else { PyObject *mapped; mapped = PyObject_GetItem(o->mapping, item); if (mapped != NULL) { Py_ssize_t i; PyObject *result; if (!PyIndex_Check(mapped)) { Py_DECREF(mapped); goto noitem; } i = PyNumber_AsSsize_t(mapped, PyExc_IndexError); Py_DECREF(mapped); if (i < 0) { if (PyErr_Occurred()) { PyErr_Clear(); } goto noitem; } result = record_item(o, i); if (result == NULL) { PyErr_Clear(); goto noitem; } return result; } else { goto noitem; } } noitem: _PyErr_SetKeyError(item); return NULL; }
/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP with LOAD_CONST binop(c1,c2) The consts table must still be in list form so that the new constant can be appended. Called with codestr pointing to the first LOAD_CONST. Abandons the transformation if the folding fails (i.e. 1+'a'). If the new constant is a sequence, only folds when the size is below a threshold value. That keeps pyc files from becoming large in the presence of code like: (None,)*1000. */ static int fold_binops_on_constants(unsigned char *codestr, PyObject *consts) { PyObject *newconst, *v, *w; Py_ssize_t len_consts, size; int opcode; /* Pre-conditions */ assert(PyList_CheckExact(consts)); assert(codestr[0] == LOAD_CONST); assert(codestr[3] == LOAD_CONST); /* Create new constant */ v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); w = PyList_GET_ITEM(consts, GETARG(codestr, 3)); opcode = codestr[6]; switch (opcode) { case BINARY_POWER: newconst = PyNumber_Power(v, w, Py_None); break; case BINARY_MULTIPLY: newconst = PyNumber_Multiply(v, w); break; case BINARY_TRUE_DIVIDE: newconst = PyNumber_TrueDivide(v, w); break; case BINARY_FLOOR_DIVIDE: newconst = PyNumber_FloorDivide(v, w); break; case BINARY_MODULO: newconst = PyNumber_Remainder(v, w); break; case BINARY_ADD: newconst = PyNumber_Add(v, w); break; case BINARY_SUBTRACT: newconst = PyNumber_Subtract(v, w); break; case BINARY_SUBSCR: newconst = PyObject_GetItem(v, w); break; case BINARY_LSHIFT: newconst = PyNumber_Lshift(v, w); break; case BINARY_RSHIFT: newconst = PyNumber_Rshift(v, w); break; case BINARY_AND: newconst = PyNumber_And(v, w); break; case BINARY_XOR: newconst = PyNumber_Xor(v, w); break; case BINARY_OR: newconst = PyNumber_Or(v, w); break; default: /* Called with an unknown opcode */ PyErr_Format(PyExc_SystemError, "unexpected binary operation %d on a constant", opcode); return 0; } if (newconst == NULL) { if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) PyErr_Clear(); return 0; } size = PyObject_Size(newconst); if (size == -1) { if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) return 0; PyErr_Clear(); } else if (size > 20) { Py_DECREF(newconst); return 0; } /* Append folded constant into consts table */ len_consts = PyList_GET_SIZE(consts); if (PyList_Append(consts, newconst)) { Py_DECREF(newconst); return 0; } Py_DECREF(newconst); /* Write NOP NOP NOP NOP LOAD_CONST newconst */ memset(codestr, NOP, 4); codestr[4] = LOAD_CONST; SETARG(codestr, 4, len_consts); return 1; }
static PyObject * score(PyObject *self, PyObject *args) { /* Believe it or not, floating these common subexpressions "by hand" gets better code out of MSVC 6. */ const double B_FROM1 = 1.0 - B; const double K1_PLUS1 = K1 + 1.0; /* Inputs */ PyObject *result; /* IIBucket result, maps d to score */ PyObject *d2fitems; /* ._wordinfo[t].items(), maps d to f(d, t) */ PyObject *d2len; /* ._docweight, maps d to # words in d */ double idf; /* inverse doc frequency of t */ double meandoclen; /* average number of words in a doc */ int n, i; if (!PyArg_ParseTuple(args, "OOOdd:score", &result, &d2fitems, &d2len, &idf, &meandoclen)) return NULL; n = PyObject_Length(d2fitems); for (i = 0; i < n; ++i) { PyObject *d_and_f; /* d2f[i], a (d, f) pair */ PyObject *d; double f; PyObject *doclen; /* ._docweight[d] */ double lenweight; double tf; PyObject *doc_score; int status; d_and_f = PySequence_GetItem(d2fitems, i); if (d_and_f == NULL) return NULL; if (!(PyTuple_CheckExact(d_and_f) && PyTuple_GET_SIZE(d_and_f) == 2)) { PyErr_SetString(PyExc_TypeError, "d2fitems must produce 2-item tuples"); Py_DECREF(d_and_f); return NULL; } d = PyTuple_GET_ITEM(d_and_f, 0); f = (double)PyInt_AsLong(PyTuple_GET_ITEM(d_and_f, 1)); doclen = PyObject_GetItem(d2len, d); if (doclen == NULL) { Py_DECREF(d_and_f); return NULL; } lenweight = B_FROM1 + B * PyInt_AsLong(doclen) / meandoclen; tf = f * K1_PLUS1 / (f + K1 * lenweight); doc_score = PyFloat_FromDouble(tf * idf); if (doc_score == NULL) status = -1; else status = PyObject_SetItem(result, d, doc_score); Py_DECREF(d_and_f); Py_DECREF(doclen); Py_XDECREF(doc_score); if (status < 0) return NULL; } Py_INCREF(Py_None); return Py_None; }
static PyObject * BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key) { PyObject *processors, *values; PyObject *processor, *value, *processed_value; PyObject *row, *record, *result, *indexobject; PyObject *exc_module, *exception, *cstr_obj; #if PY_MAJOR_VERSION >= 3 PyObject *bytes; #endif char *cstr_key; long index; int key_fallback = 0; int tuple_check = 0; #if PY_MAJOR_VERSION < 3 if (PyInt_CheckExact(key)) { index = PyInt_AS_LONG(key); } #endif if (PyLong_CheckExact(key)) { index = PyLong_AsLong(key); if ((index == -1) && PyErr_Occurred()) /* -1 can be either the actual value, or an error flag. */ return NULL; } else if (PySlice_Check(key)) { values = PyObject_GetItem(self->row, key); if (values == NULL) return NULL; processors = PyObject_GetItem(self->processors, key); if (processors == NULL) { Py_DECREF(values); return NULL; } result = BaseRowProxy_processvalues(values, processors, 1); Py_DECREF(values); Py_DECREF(processors); return result; } else { record = PyDict_GetItem((PyObject *)self->keymap, key); if (record == NULL) { record = PyObject_CallMethod(self->parent, "_key_fallback", "O", key); if (record == NULL) return NULL; key_fallback = 1; } indexobject = PyTuple_GetItem(record, 2); if (indexobject == NULL) return NULL; if (key_fallback) { Py_DECREF(record); } if (indexobject == Py_None) { exc_module = PyImport_ImportModule("sqlalchemy.exc"); if (exc_module == NULL) return NULL; exception = PyObject_GetAttrString(exc_module, "InvalidRequestError"); Py_DECREF(exc_module); if (exception == NULL) return NULL; // wow. this seems quite excessive. cstr_obj = PyObject_Str(key); if (cstr_obj == NULL) return NULL; /* FIXME: raise encoding error exception (in both versions below) if the key contains non-ascii chars, instead of an InvalidRequestError without any message like in the python version. */ #if PY_MAJOR_VERSION >= 3 bytes = PyUnicode_AsASCIIString(cstr_obj); if (bytes == NULL) return NULL; cstr_key = PyBytes_AS_STRING(bytes); #else cstr_key = PyString_AsString(cstr_obj); #endif if (cstr_key == NULL) { Py_DECREF(cstr_obj); return NULL; } Py_DECREF(cstr_obj); PyErr_Format(exception, "Ambiguous column name '%.200s' in result set! " "try 'use_labels' option on select statement.", cstr_key); return NULL; } #if PY_MAJOR_VERSION >= 3 index = PyLong_AsLong(indexobject); #else index = PyInt_AsLong(indexobject); #endif if ((index == -1) && PyErr_Occurred()) /* -1 can be either the actual value, or an error flag. */ return NULL; } processor = PyList_GetItem(self->processors, index); if (processor == NULL) return NULL; row = self->row; if (PyTuple_CheckExact(row)) { value = PyTuple_GetItem(row, index); tuple_check = 1; } else { value = PySequence_GetItem(row, index); tuple_check = 0; } if (value == NULL) return NULL; if (processor != Py_None) { processed_value = PyObject_CallFunctionObjArgs(processor, value, NULL); if (!tuple_check) { Py_DECREF(value); } return processed_value; } else { if (tuple_check) { Py_INCREF(value); } return value; } }
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; __Pyx_ErrFetch(&et, &ev, &tb); if (!et) { Py_XDECREF(tb); Py_XDECREF(ev); Py_INCREF(Py_None); *pvalue = Py_None; return 0; } if (unlikely(et != PyExc_StopIteration) && unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) { __Pyx_ErrRestore(et, ev, tb); return -1; } // most common case: plain StopIteration without or with separate argument if (likely(et == PyExc_StopIteration)) { if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) { // PyErr_SetObject() and friends put the value directly into ev if (!ev) { Py_INCREF(Py_None); ev = Py_None; } Py_XDECREF(tb); Py_DECREF(et); *pvalue = ev; return 0; } } // otherwise: normalise and check what that gives us PyErr_NormalizeException(&et, &ev, &tb); if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) { // looks like normalisation failed - raise the new exception __Pyx_ErrRestore(et, ev, tb); return -1; } Py_XDECREF(tb); Py_DECREF(et); #if PY_VERSION_HEX >= 0x030300A0 value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); #else { PyObject* args = PyObject_GetAttr(ev, PYIDENT("args")); Py_DECREF(ev); if (likely(args)) { value = PyObject_GetItem(args, 0); Py_DECREF(args); } if (unlikely(!value)) { __Pyx_ErrRestore(NULL, NULL, NULL); Py_INCREF(Py_None); value = Py_None; } } #endif *pvalue = value; return 0; }
BOOST_PYTHON_DECL object getitem(object const& target, object const& key) { return object(detail::new_reference( PyObject_GetItem(target.ptr(), key.ptr()))); }
/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP with LOAD_CONST binop(c1,c2) The consts table must still be in list form so that the new constant can be appended. Called with codestr pointing to the first LOAD_CONST. Abandons the transformation if the folding fails (i.e. 1+'a'). If the new constant is a sequence, only folds when the size is below a threshold value. That keeps pyc files from becoming large in the presence of code like: (None,)*1000. */ static int fold_binops_on_constants(unsigned char *codestr, PyObject *consts) { PyObject *newconst, *v, *w; Py_ssize_t len_consts, size; int opcode; /* Pre-conditions */ assert(PyList_CheckExact(consts)); assert(codestr[0] == LOAD_CONST); assert(codestr[3] == LOAD_CONST); /* Create new constant */ v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); w = PyList_GET_ITEM(consts, GETARG(codestr, 3)); opcode = codestr[6]; switch (opcode) { case BINARY_POWER: newconst = PyNumber_Power(v, w, Py_None); break; case BINARY_MULTIPLY: newconst = PyNumber_Multiply(v, w); break; case BINARY_DIVIDE: /* Cannot fold this operation statically since the result can depend on the run-time presence of the -Qnew flag */ return 0; case BINARY_TRUE_DIVIDE: newconst = PyNumber_TrueDivide(v, w); break; case BINARY_FLOOR_DIVIDE: newconst = PyNumber_FloorDivide(v, w); break; case BINARY_MODULO: newconst = PyNumber_Remainder(v, w); break; case BINARY_ADD: newconst = PyNumber_Add(v, w); break; case BINARY_SUBTRACT: newconst = PyNumber_Subtract(v, w); break; case BINARY_SUBSCR: newconst = PyObject_GetItem(v, w); /* #5057: if v is unicode, there might be differences between wide and narrow builds in cases like u'\U00012345'[0]. Wide builds will return a non-BMP char, whereas narrow builds will return a surrogate. In both the cases skip the optimization in order to produce compatible pycs. */ if (newconst != NULL && PyUnicode_Check(v) && PyUnicode_Check(newconst)) { Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0]; #ifdef Py_UNICODE_WIDE if (ch > 0xFFFF) { #else if (ch >= 0xD800 && ch <= 0xDFFF) { #endif Py_DECREF(newconst); return 0; } } break; case BINARY_LSHIFT: newconst = PyNumber_Lshift(v, w); break; case BINARY_RSHIFT: newconst = PyNumber_Rshift(v, w); break; case BINARY_AND: newconst = PyNumber_And(v, w); break; case BINARY_XOR: newconst = PyNumber_Xor(v, w); break; case BINARY_OR: newconst = PyNumber_Or(v, w); break; default: /* Called with an unknown opcode */ PyErr_Format(PyExc_SystemError, "unexpected binary operation %d on a constant", opcode); return 0; } if (newconst == NULL) { PyErr_Clear(); return 0; } size = PyObject_Size(newconst); if (size == -1) PyErr_Clear(); else if (size > 20) { Py_DECREF(newconst); return 0; } /* Append folded constant into consts table */ len_consts = PyList_GET_SIZE(consts); if (PyList_Append(consts, newconst)) { Py_DECREF(newconst); return 0; } Py_DECREF(newconst); /* Write NOP NOP NOP NOP LOAD_CONST newconst */ memset(codestr, NOP, 4); codestr[4] = LOAD_CONST; SETARG(codestr, 4, len_consts); return 1; } static int fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) { PyObject *newconst=NULL, *v; Py_ssize_t len_consts; int opcode; /* Pre-conditions */ assert(PyList_CheckExact(consts)); assert(codestr[0] == LOAD_CONST); /* Create new constant */ v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); opcode = codestr[3]; switch (opcode) { case UNARY_NEGATIVE: /* Preserve the sign of -0.0 */ if (PyObject_IsTrue(v) == 1) newconst = PyNumber_Negative(v); break; case UNARY_CONVERT: newconst = PyObject_Repr(v); break; case UNARY_INVERT: newconst = PyNumber_Invert(v); break; default: /* Called with an unknown opcode */ PyErr_Format(PyExc_SystemError, "unexpected unary operation %d on a constant", opcode); return 0; } if (newconst == NULL) { PyErr_Clear(); return 0; } /* Append folded constant into consts table */ len_consts = PyList_GET_SIZE(consts); if (PyList_Append(consts, newconst)) { Py_DECREF(newconst); return 0; } Py_DECREF(newconst); /* Write NOP LOAD_CONST newconst */ codestr[0] = NOP; codestr[1] = LOAD_CONST; SETARG(codestr, 1, len_consts); return 1; }
/* * PyPgFunction_load_module - create and load the module * * This execute the module body in a new module object iff the module does not * already exist in sys.modules. * * The PL protocol checks are not done here because this could be called from * the code of another function. It's the caller's responsibility to ensure that * the appropriate checks are being made at the appropriate time. */ PyObj PyPgFunction_load_module(PyObj func) { PyObj modules, module, modname, d, code, evalr; int rv; Assert(func != NULL); Assert(PyPgFunction_Check(func)); modules = PyImport_GetModuleDict(); rv = PySequence_Contains(modules, PyPgFunction_GetPyUnicodeOid(func)); if (rv == -1) return(NULL); else if (rv == 1) { /* * If this returns NULL, it's probably some weird race condition... * The check above said it exists, so let's trust it. */ return(PyObject_GetItem(modules, PyPgFunction_GetPyUnicodeOid(func))); } /* * Hasn't been loaded into sys.modules yet. */ code = PyPgFunction_get_code(func); if (code == NULL) return(NULL); modname = PyPgFunction_GetPyUnicodeOid(func); Py_INCREF(modname); PyObject_StrBytes(&modname); if (modname == NULL) { Py_DECREF(code); return(NULL); } module = PyModule_New(PyBytes_AS_STRING(modname)); Py_DECREF(modname); if (module == NULL) { Py_DECREF(code); return(NULL); } d = PyModule_GetDict(module); if (PyDict_SetItemString(d, "__builtins__", Py_builtins_module) != 0) goto fail; /* * __loader__ PEP302 support. * This is what linecache uses to access the function's source */ if (PyDict_SetItemString(d, "__loader__", func) != 0) goto fail; if (PyDict_SetItemString(d, "__func__", func) != 0) goto fail; if (PyDict_SetItemString(d, "__file__", PyPgFunction_GetFilename(func)) != 0) goto fail; /* * Module has to exist in sys.modules before code evaluates. */ if (PyObject_SetItem(modules, PyPgFunction_GetPyUnicodeOid(func), module) != 0) goto fail; /* * Module context, therefore locals and globals are the same object. */ evalr = PyEval_EvalCode((PyCodeObject *) code, d, d); if (evalr == NULL) { /* * Code evaluation failed. Remove the junk module from sys.modules. */ PyObject_DelItem(modules, PyPgFunction_GetPyUnicodeOid(func)); goto fail; } Py_DECREF(evalr); Py_DECREF(code); return(module); fail: Py_DECREF(code); Py_DECREF(module); return(NULL); }
/* Implementation of baas2 */ static PyObject *__pyx_f_5baas2_bar(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_5baas2_bar(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_a; int __pyx_v_b; PyObject *__pyx_v_values; PyObject *__pyx_v_dummy; PyObject *__pyx_v_tup; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; int __pyx_4; static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; __pyx_v_values = Py_None; Py_INCREF(Py_None); __pyx_v_dummy = Py_None; Py_INCREF(Py_None); __pyx_v_tup = Py_None; Py_INCREF(Py_None); /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":4 */ __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;} __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;} __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); __pyx_1 = 0; __pyx_2 = 0; Py_DECREF(__pyx_v_values); __pyx_v_values = __pyx_3; __pyx_3 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":5 */ __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;} Py_DECREF(__pyx_v_dummy); __pyx_v_dummy = __pyx_1; __pyx_1 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":7 */ __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} __pyx_3 = PyObject_GetItem(__pyx_v_values, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_v_a = __pyx_4; /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":8 */ __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} __pyx_2 = PyObject_GetItem(__pyx_v_values, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_v_b = __pyx_4; /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":10 */ __pyx_1 = PyInt_FromLong(__pyx_v_a); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} __pyx_2 = PyInt_FromLong(__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); __pyx_1 = 0; __pyx_2 = 0; Py_DECREF(__pyx_v_tup); __pyx_v_tup = __pyx_3; __pyx_3 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/baas/baas2.pyx":11 */ if (__Pyx_PrintItem(__pyx_v_tup) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("baas2.bar"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_values); Py_DECREF(__pyx_v_dummy); Py_DECREF(__pyx_v_tup); return __pyx_r; }
static int __pyx_f_11inplace_lhs_f(void) { int __pyx_v_i; int __pyx_v_j; int __pyx_v_k; float __pyx_v_x; float __pyx_v_y; float __pyx_v_z; PyObject *__pyx_v_a; PyObject *__pyx_v_b; PyObject *__pyx_v_c; PyObject *__pyx_v_d; int __pyx_v_m[3]; struct __pyx_t_11inplace_lhs_S __pyx_v_s; int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; __pyx_v_a = Py_None; Py_INCREF(Py_None); __pyx_v_b = Py_None; Py_INCREF(Py_None); __pyx_v_c = Py_None; Py_INCREF(Py_None); __pyx_v_d = Py_None; Py_INCREF(Py_None); /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":11 */ __pyx_v_i += (__pyx_v_j + __pyx_v_k); /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":12 */ __pyx_v_x += (__pyx_v_y + __pyx_v_z); /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":13 */ __pyx_v_x += __pyx_v_i; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":14 */ __pyx_1 = PyNumber_Add(__pyx_v_b, __pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} __pyx_2 = PyNumber_InPlaceAdd(__pyx_v_a, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_a); __pyx_v_a = __pyx_2; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":15 */ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_g); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} __pyx_2 = PyNumber_InPlaceAdd(__pyx_1, __pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_g, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":16 */ (__pyx_v_m[__pyx_v_i]) += __pyx_v_j; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":17 */ __pyx_1 = PyNumber_Add(__pyx_v_b, __pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} __pyx_3 = PyObject_GetItem(__pyx_v_a, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} __pyx_4 = PyNumber_InPlaceAdd(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (PyObject_SetItem(__pyx_v_a, __pyx_2, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":18 */ __pyx_3 = PyNumber_Add(__pyx_v_b, __pyx_v_c); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} __pyx_1 = PyObject_GetItem(__pyx_v_a, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} __pyx_4 = PyNumber_InPlaceAdd(__pyx_1, __pyx_v_d); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; if (PyObject_SetItem(__pyx_v_a, __pyx_3, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":19 */ __pyx_2 = PyNumber_Add(__pyx_v_a, __pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} __pyx_1 = PyObject_GetItem(__pyx_2, __pyx_v_c); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} __pyx_4 = PyNumber_InPlaceAdd(__pyx_1, __pyx_v_d); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; if (PyObject_SetItem(__pyx_2, __pyx_v_c, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":20 */ __pyx_3 = PySequence_GetSlice(__pyx_v_a, __pyx_v_i, __pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} __pyx_1 = PyNumber_InPlaceAdd(__pyx_3, __pyx_v_b); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; if (PySequence_SetSlice(__pyx_v_a, __pyx_v_i, __pyx_v_j, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":21 */ __pyx_4 = PyNumber_Add(__pyx_v_a, __pyx_v_b); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} __pyx_2 = PySequence_GetSlice(__pyx_4, __pyx_v_i, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} __pyx_3 = PyNumber_InPlaceAdd(__pyx_2, __pyx_v_c); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (PySequence_SetSlice(__pyx_4, __pyx_v_i, __pyx_v_j, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":22 */ __pyx_1 = PyNumber_Add(__pyx_v_c, __pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_v_a, __pyx_n_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} __pyx_3 = PyNumber_InPlaceAdd(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (PyObject_SetAttr(__pyx_v_a, __pyx_n_b, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":23 */ __pyx_4 = PyNumber_Add(__pyx_v_a, __pyx_v_b); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_c); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_1 = PyNumber_InPlaceAdd(__pyx_2, __pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; if (PyObject_SetAttr(__pyx_4, __pyx_n_c, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/10/inplace_lhs.pyx":24 */ __pyx_v_s.q += __pyx_v_i; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("inplace_lhs.f"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_a); Py_DECREF(__pyx_v_b); Py_DECREF(__pyx_v_c); Py_DECREF(__pyx_v_d); return __pyx_r; }
static PyObject *__pyx_f_11closestpair_closest_pair(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyListObject *__pyx_v_points = 0; float __pyx_v_min_d; PyObject *__pyx_v_min_p1; PyObject *__pyx_v_min_p2; PyObject *__pyx_v_i; PyObject *__pyx_v_point; PyObject *__pyx_v_point2; PyObject *__pyx_v_d; PyObject *__pyx_v_split; PyObject *__pyx_v_d1; PyObject *__pyx_v_p11; PyObject *__pyx_v_p12; PyObject *__pyx_v_d2; PyObject *__pyx_v_p21; PyObject *__pyx_v_p22; PyObject *__pyx_v_points_in_strip; PyObject *__pyx_v_split_at; PyObject *__pyx_v_max_i; PyObject *__pyx_v_sd; PyObject *__pyx_r; Py_ssize_t __pyx_1; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; PyObject *__pyx_7 = 0; PyObject *__pyx_8 = 0; PyObject *__pyx_9 = 0; PyObject *__pyx_10 = 0; float __pyx_11; int __pyx_12; Py_ssize_t __pyx_13; static char *__pyx_argnames[] = {"points",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_points)) return 0; Py_INCREF(__pyx_v_points); __pyx_v_min_p1 = Py_None; Py_INCREF(Py_None); __pyx_v_min_p2 = Py_None; Py_INCREF(Py_None); __pyx_v_i = Py_None; Py_INCREF(Py_None); __pyx_v_point = Py_None; Py_INCREF(Py_None); __pyx_v_point2 = Py_None; Py_INCREF(Py_None); __pyx_v_d = Py_None; Py_INCREF(Py_None); __pyx_v_split = Py_None; Py_INCREF(Py_None); __pyx_v_d1 = Py_None; Py_INCREF(Py_None); __pyx_v_p11 = Py_None; Py_INCREF(Py_None); __pyx_v_p12 = Py_None; Py_INCREF(Py_None); __pyx_v_d2 = Py_None; Py_INCREF(Py_None); __pyx_v_p21 = Py_None; Py_INCREF(Py_None); __pyx_v_p22 = Py_None; Py_INCREF(Py_None); __pyx_v_points_in_strip = Py_None; Py_INCREF(Py_None); __pyx_v_split_at = Py_None; Py_INCREF(Py_None); __pyx_v_max_i = Py_None; Py_INCREF(Py_None); __pyx_v_sd = Py_None; Py_INCREF(Py_None); if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_points), (&PyList_Type), 1, "points")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":15 */ __pyx_1 = PyObject_Length(((PyObject *)__pyx_v_points)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} __pyx_2 = (__pyx_1 < 2); if (__pyx_2) { __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} Py_INCREF(__pyx_k1p); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k1p); __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} goto __pyx_L2; } __pyx_1 = PyObject_Length(((PyObject *)__pyx_v_points)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} __pyx_2 = 2 <= __pyx_1; if (__pyx_2) { __pyx_2 = __pyx_1 <= 6; } if (__pyx_2) { /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":18 */ __pyx_v_min_d = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":19 */ Py_INCREF(Py_None); Py_DECREF(__pyx_v_min_p1); __pyx_v_min_p1 = Py_None; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":20 */ Py_INCREF(Py_None); Py_DECREF(__pyx_v_min_p2); __pyx_v_min_p2 = Py_None; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":21 */ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_points)); PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_points)); __pyx_4 = PyObject_CallObject(((PyObject *)(&PyEnum_Type)), __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyObject_GetIter(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; for (;;) { __pyx_4 = PyIter_Next(__pyx_3); if (!__pyx_4) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} break; } __pyx_5 = PyObject_GetIter(__pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_4 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_v_i); __pyx_v_i = __pyx_4; __pyx_4 = 0; __pyx_4 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_v_point); __pyx_v_point = __pyx_4; __pyx_4 = 0; if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} __pyx_5 = PyNumber_Add(__pyx_v_i, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_1 = PyInt_AsSsize_t(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_4 = PySequence_GetSlice(((PyObject *)__pyx_v_points), __pyx_1, PY_SSIZE_T_MAX); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} __pyx_5 = PyObject_GetIter(__pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; for (;;) { __pyx_4 = PyIter_Next(__pyx_5); if (!__pyx_4) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} break; } Py_DECREF(__pyx_v_point2); __pyx_v_point2 = __pyx_4; __pyx_4 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":23 */ __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_distance); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_6 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_7 = PySequence_GetItem(__pyx_v_point, 1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_8 = PySequence_GetItem(__pyx_v_point2, 0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_9 = PySequence_GetItem(__pyx_v_point2, 1); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} __pyx_10 = PyTuple_New(4); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_10, 0, __pyx_6); PyTuple_SET_ITEM(__pyx_10, 1, __pyx_7); PyTuple_SET_ITEM(__pyx_10, 2, __pyx_8); PyTuple_SET_ITEM(__pyx_10, 3, __pyx_9); __pyx_6 = 0; __pyx_7 = 0; __pyx_8 = 0; __pyx_9 = 0; __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_10); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_10); __pyx_10 = 0; Py_DECREF(__pyx_v_d); __pyx_v_d = __pyx_6; __pyx_6 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":24 */ __pyx_2 = (__pyx_v_min_d == 0); if (!__pyx_2) { __pyx_7 = PyFloat_FromDouble(__pyx_v_min_d); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} if (PyObject_Cmp(__pyx_7, __pyx_v_d, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_7); __pyx_7 = 0; } if (__pyx_2) { /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":25 */ __pyx_11 = PyFloat_AsDouble(__pyx_v_d); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} __pyx_v_min_d = __pyx_11; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":26 */ Py_INCREF(__pyx_v_point); Py_DECREF(__pyx_v_min_p1); __pyx_v_min_p1 = __pyx_v_point; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":27 */ Py_INCREF(__pyx_v_point2); Py_DECREF(__pyx_v_min_p2); __pyx_v_min_p2 = __pyx_v_point2; goto __pyx_L7; } __pyx_L7:; } Py_DECREF(__pyx_5); __pyx_5 = 0; } Py_DECREF(__pyx_3); __pyx_3 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":28 */ __pyx_8 = PyFloat_FromDouble(__pyx_v_min_d); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} __pyx_9 = PyTuple_New(3); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_9, 0, __pyx_8); Py_INCREF(__pyx_v_min_p1); PyTuple_SET_ITEM(__pyx_9, 1, __pyx_v_min_p1); Py_INCREF(__pyx_v_min_p2); PyTuple_SET_ITEM(__pyx_9, 2, __pyx_v_min_p2); __pyx_8 = 0; __pyx_r = __pyx_9; __pyx_9 = 0; goto __pyx_L0; goto __pyx_L2; } /*else*/ { /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":30 */ __pyx_12 = PyList_Sort(((PyObject *)__pyx_v_points)); if (__pyx_12 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":32 */ __pyx_1 = PyObject_Length(((PyObject *)__pyx_v_points)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} __pyx_4 = PyInt_FromSsize_t((__pyx_1 / 2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} __pyx_10 = PyTuple_New(1); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_10, 0, __pyx_4); __pyx_4 = 0; __pyx_6 = PyObject_CallObject(((PyObject *)(&PyInt_Type)), __pyx_10); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} Py_DECREF(__pyx_10); __pyx_10 = 0; Py_DECREF(__pyx_v_split); __pyx_v_split = __pyx_6; __pyx_6 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":33 */ __pyx_7 = __Pyx_GetName(__pyx_m, __pyx_n_closest_pair); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} __pyx_1 = PyInt_AsSsize_t(__pyx_v_split); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} __pyx_5 = PySequence_GetSlice(((PyObject *)__pyx_v_points), 0, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5); __pyx_5 = 0; __pyx_8 = PyObject_CallObject(__pyx_7, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_9 = PyObject_GetIter(__pyx_8); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_8); __pyx_8 = 0; __pyx_4 = __Pyx_UnpackItem(__pyx_9); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_v_d1); __pyx_v_d1 = __pyx_4; __pyx_4 = 0; __pyx_10 = __Pyx_UnpackItem(__pyx_9); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_v_p11); __pyx_v_p11 = __pyx_10; __pyx_10 = 0; __pyx_6 = __Pyx_UnpackItem(__pyx_9); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_v_p12); __pyx_v_p12 = __pyx_6; __pyx_6 = 0; if (__Pyx_EndUnpack(__pyx_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_9); __pyx_9 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":34 */ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_closest_pair); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} __pyx_1 = PyInt_AsSsize_t(__pyx_v_split); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} __pyx_7 = PySequence_GetSlice(((PyObject *)__pyx_v_points), __pyx_1, PY_SSIZE_T_MAX); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_7); __pyx_7 = 0; __pyx_8 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = PyObject_GetIter(__pyx_8); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_8); __pyx_8 = 0; __pyx_10 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_v_d2); __pyx_v_d2 = __pyx_10; __pyx_10 = 0; __pyx_6 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_v_p21); __pyx_v_p21 = __pyx_6; __pyx_6 = 0; __pyx_9 = __Pyx_UnpackItem(__pyx_4); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_v_p22); __pyx_v_p22 = __pyx_9; __pyx_9 = 0; if (__Pyx_EndUnpack(__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":35 */ __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} Py_INCREF(__pyx_v_d1); PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_d1); Py_INCREF(__pyx_v_d2); PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_d2); __pyx_3 = PyObject_CallObject(__pyx_7, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_v_d); __pyx_v_d = __pyx_3; __pyx_3 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":37 */ __pyx_8 = PyList_New(0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} Py_DECREF(__pyx_v_points_in_strip); __pyx_v_points_in_strip = __pyx_8; __pyx_8 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":38 */ __pyx_10 = PyInt_FromLong(1); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} __pyx_6 = PyNumber_Subtract(__pyx_v_split, __pyx_10); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_10); __pyx_10 = 0; __pyx_9 = PyObject_GetItem(((PyObject *)__pyx_v_points), __pyx_6); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_4 = PySequence_GetItem(__pyx_9, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_9); __pyx_9 = 0; __pyx_7 = PyObject_GetItem(((PyObject *)__pyx_v_points), __pyx_v_split); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} __pyx_5 = PySequence_GetItem(__pyx_7, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; __pyx_3 = PyNumber_Add(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_8 = PyFloat_FromDouble(2.0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} __pyx_10 = PyNumber_Divide(__pyx_3, __pyx_8); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_8); __pyx_8 = 0; Py_DECREF(__pyx_v_split_at); __pyx_v_split_at = __pyx_10; __pyx_10 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":39 */ __pyx_6 = PyObject_GetIter(((PyObject *)__pyx_v_points)); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} for (;;) { __pyx_9 = PyIter_Next(__pyx_6); if (!__pyx_9) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} break; } Py_DECREF(__pyx_v_point); __pyx_v_point = __pyx_9; __pyx_9 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":40 */ __pyx_7 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;} __pyx_4 = PyNumber_Subtract(__pyx_v_split_at, __pyx_v_d); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;} if (PyObject_Cmp(__pyx_7, __pyx_4, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_7); __pyx_7 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_2) { goto __pyx_L8; goto __pyx_L10; } __pyx_5 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} __pyx_3 = PyNumber_Add(__pyx_v_split_at, __pyx_v_d); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} if (PyObject_Cmp(__pyx_5, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_2) { goto __pyx_L9; goto __pyx_L10; } __pyx_L10:; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":44 */ __pyx_8 = PyObject_GetAttr(__pyx_v_points_in_strip, __pyx_n_append); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} __pyx_10 = PySequence_GetItem(__pyx_v_point, 1); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} __pyx_9 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} __pyx_7 = PySequence_GetItem(__pyx_v_point, 2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_10); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_9); PyTuple_SET_ITEM(__pyx_4, 2, __pyx_7); __pyx_10 = 0; __pyx_9 = 0; __pyx_7 = 0; __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4); __pyx_4 = 0; __pyx_3 = PyObject_CallObject(__pyx_8, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} Py_DECREF(__pyx_8); __pyx_8 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_L8:; } __pyx_L9:; Py_DECREF(__pyx_6); __pyx_6 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":46 */ __pyx_10 = PyObject_GetAttr(__pyx_v_points_in_strip, __pyx_n_sort); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} __pyx_9 = PyObject_CallObject(__pyx_10, 0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} Py_DECREF(__pyx_10); __pyx_10 = 0; Py_DECREF(__pyx_9); __pyx_9 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":48 */ __pyx_v_min_d = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":49 */ Py_INCREF(Py_None); Py_DECREF(__pyx_v_min_p1); __pyx_v_min_p1 = Py_None; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":50 */ Py_INCREF(Py_None); Py_DECREF(__pyx_v_min_p2); __pyx_v_min_p2 = Py_None; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":51 */ __pyx_1 = PyObject_Length(__pyx_v_points_in_strip); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} __pyx_7 = PyInt_FromSsize_t(__pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} Py_DECREF(__pyx_v_max_i); __pyx_v_max_i = __pyx_7; __pyx_7 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":52 */ __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_INCREF(__pyx_v_points_in_strip); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_points_in_strip); __pyx_8 = PyObject_CallObject(((PyObject *)(&PyEnum_Type)), __pyx_4); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_5 = PyObject_GetIter(__pyx_8); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_8); __pyx_8 = 0; for (;;) { __pyx_3 = PyIter_Next(__pyx_5); if (!__pyx_3) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} break; } __pyx_6 = PyObject_GetIter(__pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_10 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_v_i); __pyx_v_i = __pyx_10; __pyx_10 = 0; __pyx_9 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_v_point); __pyx_v_point = __pyx_9; __pyx_9 = 0; if (__Pyx_EndUnpack(__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_4 = PyNumber_Add(__pyx_v_i, __pyx_7); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; __pyx_1 = PyInt_AsSsize_t(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(7); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_10 = PyNumber_Add(__pyx_v_i, __pyx_3); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_9 = PyTuple_New(2); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_INCREF(__pyx_v_max_i); PyTuple_SET_ITEM(__pyx_9, 0, __pyx_v_max_i); PyTuple_SET_ITEM(__pyx_9, 1, __pyx_10); __pyx_10 = 0; __pyx_6 = PyObject_CallObject(__pyx_8, __pyx_9); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_8); __pyx_8 = 0; Py_DECREF(__pyx_9); __pyx_9 = 0; __pyx_13 = PyInt_AsSsize_t(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_7 = PySequence_GetSlice(__pyx_v_points_in_strip, __pyx_1, __pyx_13); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_4 = PyObject_GetIter(__pyx_7); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; for (;;) { __pyx_3 = PyIter_Next(__pyx_4); if (!__pyx_3) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;} break; } Py_DECREF(__pyx_v_point2); __pyx_v_point2 = __pyx_3; __pyx_3 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":54 */ __pyx_10 = __Pyx_GetName(__pyx_m, __pyx_n_distance); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_8 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_9 = PySequence_GetItem(__pyx_v_point, 1); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_6 = PySequence_GetItem(__pyx_v_point2, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_7 = PySequence_GetItem(__pyx_v_point2, 1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_3 = PyTuple_New(4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_8); PyTuple_SET_ITEM(__pyx_3, 1, __pyx_9); PyTuple_SET_ITEM(__pyx_3, 2, __pyx_6); PyTuple_SET_ITEM(__pyx_3, 3, __pyx_7); __pyx_8 = 0; __pyx_9 = 0; __pyx_6 = 0; __pyx_7 = 0; __pyx_8 = PyObject_CallObject(__pyx_10, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} Py_DECREF(__pyx_10); __pyx_10 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_v_sd); __pyx_v_sd = __pyx_8; __pyx_8 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":55 */ __pyx_2 = (__pyx_v_min_d == 0); if (!__pyx_2) { __pyx_9 = PyFloat_FromDouble(__pyx_v_min_d); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;} if (PyObject_Cmp(__pyx_9, __pyx_v_sd, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_9); __pyx_9 = 0; } if (__pyx_2) { /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":56 */ __pyx_11 = PyFloat_AsDouble(__pyx_v_sd); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;} __pyx_v_min_d = __pyx_11; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":57 */ __pyx_6 = PySequence_GetItem(__pyx_v_point, 1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;} __pyx_7 = PySequence_GetItem(__pyx_v_point, 0); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;} __pyx_10 = PySequence_GetItem(__pyx_v_point, 2); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;} __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6); PyTuple_SET_ITEM(__pyx_3, 1, __pyx_7); PyTuple_SET_ITEM(__pyx_3, 2, __pyx_10); __pyx_6 = 0; __pyx_7 = 0; __pyx_10 = 0; Py_DECREF(__pyx_v_min_p1); __pyx_v_min_p1 = __pyx_3; __pyx_3 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":58 */ __pyx_8 = PySequence_GetItem(__pyx_v_point2, 1); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} __pyx_9 = PySequence_GetItem(__pyx_v_point2, 0); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} __pyx_6 = PySequence_GetItem(__pyx_v_point2, 2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} __pyx_7 = PyTuple_New(3); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_7, 0, __pyx_8); PyTuple_SET_ITEM(__pyx_7, 1, __pyx_9); PyTuple_SET_ITEM(__pyx_7, 2, __pyx_6); __pyx_8 = 0; __pyx_9 = 0; __pyx_6 = 0; Py_DECREF(__pyx_v_min_p2); __pyx_v_min_p2 = __pyx_7; __pyx_7 = 0; goto __pyx_L15; } __pyx_L15:; } Py_DECREF(__pyx_4); __pyx_4 = 0; } Py_DECREF(__pyx_5); __pyx_5 = 0; /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":59 */ __pyx_2 = (__pyx_v_min_d != 0); if (__pyx_2) { __pyx_10 = PyFloat_FromDouble(__pyx_v_min_d); if (!__pyx_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} if (PyObject_Cmp(__pyx_10, __pyx_v_d, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_10); __pyx_10 = 0; } if (__pyx_2) { __pyx_3 = PyFloat_FromDouble(__pyx_v_min_d); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;} __pyx_8 = PyTuple_New(3); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_8, 0, __pyx_3); Py_INCREF(__pyx_v_min_p1); PyTuple_SET_ITEM(__pyx_8, 1, __pyx_v_min_p1); Py_INCREF(__pyx_v_min_p2); PyTuple_SET_ITEM(__pyx_8, 2, __pyx_v_min_p2); __pyx_3 = 0; __pyx_r = __pyx_8; __pyx_8 = 0; goto __pyx_L0; goto __pyx_L16; } if (PyObject_Cmp(__pyx_v_d1, __pyx_v_d2, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; if (__pyx_2) { __pyx_9 = PyTuple_New(3); if (!__pyx_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;} Py_INCREF(__pyx_v_d1); PyTuple_SET_ITEM(__pyx_9, 0, __pyx_v_d1); Py_INCREF(__pyx_v_p11); PyTuple_SET_ITEM(__pyx_9, 1, __pyx_v_p11); Py_INCREF(__pyx_v_p12); PyTuple_SET_ITEM(__pyx_9, 2, __pyx_v_p12); __pyx_r = __pyx_9; __pyx_9 = 0; goto __pyx_L0; goto __pyx_L16; } /*else*/ { __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} Py_INCREF(__pyx_v_d2); PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_d2); Py_INCREF(__pyx_v_p21); PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_p21); Py_INCREF(__pyx_v_p22); PyTuple_SET_ITEM(__pyx_6, 2, __pyx_v_p22); __pyx_r = __pyx_6; __pyx_6 = 0; goto __pyx_L0; } __pyx_L16:; } __pyx_L2:; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); Py_XDECREF(__pyx_7); Py_XDECREF(__pyx_8); Py_XDECREF(__pyx_9); Py_XDECREF(__pyx_10); __Pyx_AddTraceback("closestpair.closest_pair"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_min_p1); Py_DECREF(__pyx_v_min_p2); Py_DECREF(__pyx_v_i); Py_DECREF(__pyx_v_point); Py_DECREF(__pyx_v_point2); Py_DECREF(__pyx_v_d); Py_DECREF(__pyx_v_split); Py_DECREF(__pyx_v_d1); Py_DECREF(__pyx_v_p11); Py_DECREF(__pyx_v_p12); Py_DECREF(__pyx_v_d2); Py_DECREF(__pyx_v_p21); Py_DECREF(__pyx_v_p22); Py_DECREF(__pyx_v_points_in_strip); Py_DECREF(__pyx_v_split_at); Py_DECREF(__pyx_v_max_i); Py_DECREF(__pyx_v_sd); Py_DECREF(__pyx_v_points); return __pyx_r; }
static int t_descriptor___set__(t_descriptor *self, t_item *item, PyObject *value) { if (item == NULL || (PyObject *) item == Py_None) { PyErr_SetObject(PyExc_AttributeError, (PyObject *) item); return -1; } else if (item->status & STALE) { PyErr_SetObject((PyObject *) StaleItemError, (PyObject *) item); return -1; } else if (value == NULL) return t_descriptor___delete__(self, item); else { t_attribute *attr = self->attr; if (attr != NULL) { int flags = attr->flags; t_values *attrDict = get_attrdict(item, flags); if (attrDict) { PyObject *oldValue = PyDict_GetItem(attrDict->dict, self->name); if (oldValue && oldValue->ob_type == ItemRef) oldValue = (PyObject *) ((t_itemref *) oldValue)->item; if (value == oldValue) return 0; if (flags & A_SINGLE && oldValue) { int eq = 0; if (flags & A_PROCESS_EQ) { if (attr->typeID != NULL) { PyObject *type = PyObject_GetItem(item->ref->view, attr->typeID); PyObject *result; if (!type) return -1; result = PyObject_CallMethodObjArgs(type, eqValues_NAME, value, oldValue, NULL); Py_DECREF(type); if (!result) return -1; eq = PyObject_IsTrue(result); Py_DECREF(result); } } else if (!(flags & A_PROCESS_SET)) { eq = PyObject_RichCompareBool(value, oldValue, Py_EQ); if (eq == -1) PyErr_Clear(); } if (eq == 1) return 0; } } value = PyObject_CallMethodObjArgs((PyObject *) item, setAttributeValue_NAME, self->name, value, attrDict ? (PyObject *) attrDict : Py_None, flags & A_REF ? attr->otherName : Py_None, Py_True, NULL); if (!value) return -1; Py_DECREF(value); return 0; } PyErr_SetObject(PyExc_AttributeError, self->name); return -1; } }
static PyObject * wrap_getitem(PyObject *wrapper, PyObject *v) { return PyObject_GetItem(Proxy_GET_OBJECT(wrapper), v); }
/* Implementation of index */ static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_5index_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_obj1 = 0; PyObject *__pyx_v_obj2 = 0; PyObject *__pyx_v_obj3 = 0; int __pyx_v_int1; int __pyx_v_int2; int __pyx_v_int3; float __pyx_v_flt1; float *__pyx_v_ptr1; int __pyx_v_array1[42]; PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_ssize_t __pyx_2; PyObject *__pyx_3 = 0; static char *__pyx_argnames[] = {"obj1","obj2","obj3",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_obj1, &__pyx_v_obj2, &__pyx_v_obj3)) return 0; Py_INCREF(__pyx_v_obj1); Py_INCREF(__pyx_v_obj2); Py_INCREF(__pyx_v_obj3); /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":5 */ __pyx_v_int1 = (__pyx_v_array1[__pyx_v_int2]); /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":6 */ __pyx_v_flt1 = (__pyx_v_ptr1[__pyx_v_int2]); /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":7 */ (__pyx_v_array1[__pyx_v_int1]) = __pyx_v_int2; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":8 */ (__pyx_v_ptr1[__pyx_v_int1]) = __pyx_v_int2; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":9 */ __pyx_1 = PyObject_GetItem(__pyx_v_obj2, __pyx_v_obj3); if (!__pyx_1) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1; } Py_DECREF(__pyx_v_obj1); __pyx_v_obj1 = __pyx_1; __pyx_1 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":10 */ __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj3); if (PyErr_Occurred()) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1; } __pyx_v_int1 = (__pyx_v_array1[__pyx_2]); /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":11 */ __pyx_1 = PyInt_FromLong(__pyx_v_int3); if (!__pyx_1) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1; } __pyx_3 = PyObject_GetItem(__pyx_v_obj2, __pyx_1); if (!__pyx_3) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1; } Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_obj1); __pyx_v_obj1 = __pyx_3; __pyx_3 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":12 */ if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_v_obj3) < 0) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1; } /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":13 */ __pyx_2 = PyInt_AsSsize_t(__pyx_v_obj2); if (PyErr_Occurred()) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1; } (__pyx_v_array1[__pyx_2]) = __pyx_v_int3; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":14 */ __pyx_1 = PyInt_FromLong(__pyx_v_int2); if (!__pyx_1) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1; } if (PyObject_SetItem(__pyx_v_obj1, __pyx_1, __pyx_v_obj3) < 0) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1; } Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/Local/Projects/D/Pyrex/Source/Tests/2/index.pyx":15 */ __pyx_3 = PyInt_FromLong(42); if (!__pyx_3) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1; } if (PyObject_SetItem(__pyx_v_obj1, __pyx_v_obj2, __pyx_3) < 0) { __pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1; } Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1: ; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("index.f"); __pyx_r = 0; __pyx_L0: ; Py_DECREF(__pyx_v_obj1); Py_DECREF(__pyx_v_obj2); Py_DECREF(__pyx_v_obj3); return __pyx_r; }
static PyObject * BaseRowProxy_subscript(BaseRowProxy *self, PyObject *key) { PyObject *processors, *values; PyObject *processor, *value, *processed_value; PyObject *row, *record, *result, *indexobject; PyObject *exc_module, *exception; char *cstr_key; long index; int key_fallback = 0; int tuple_check = 0; if (PyInt_CheckExact(key)) { index = PyInt_AS_LONG(key); } else if (PyLong_CheckExact(key)) { index = PyLong_AsLong(key); if ((index == -1) && PyErr_Occurred()) /* -1 can be either the actual value, or an error flag. */ return NULL; } else if (PySlice_Check(key)) { values = PyObject_GetItem(self->row, key); if (values == NULL) return NULL; processors = PyObject_GetItem(self->processors, key); if (processors == NULL) { Py_DECREF(values); return NULL; } result = BaseRowProxy_processvalues(values, processors, 1); Py_DECREF(values); Py_DECREF(processors); return result; } else { record = PyDict_GetItem((PyObject *)self->keymap, key); if (record == NULL) { record = PyObject_CallMethod(self->parent, "_key_fallback", "O", key); if (record == NULL) return NULL; key_fallback = 1; } indexobject = PyTuple_GetItem(record, 2); if (indexobject == NULL) return NULL; if (key_fallback) { Py_DECREF(record); } if (indexobject == Py_None) { exc_module = PyImport_ImportModule("sqlalchemy.exc"); if (exc_module == NULL) return NULL; exception = PyObject_GetAttrString(exc_module, "InvalidRequestError"); Py_DECREF(exc_module); if (exception == NULL) return NULL; cstr_key = PyString_AsString(key); if (cstr_key == NULL) return NULL; PyErr_Format(exception, "Ambiguous column name '%.200s' in result set! " "try 'use_labels' option on select statement.", cstr_key); return NULL; } index = PyInt_AsLong(indexobject); if ((index == -1) && PyErr_Occurred()) /* -1 can be either the actual value, or an error flag. */ return NULL; } processor = PyList_GetItem(self->processors, index); if (processor == NULL) return NULL; row = self->row; if (PyTuple_CheckExact(row)) { value = PyTuple_GetItem(row, index); tuple_check = 1; } else { value = PySequence_GetItem(row, index); tuple_check = 0; } if (value == NULL) return NULL; if (processor != Py_None) { processed_value = PyObject_CallFunctionObjArgs(processor, value, NULL); if (!tuple_check) { Py_DECREF(value); } return processed_value; } else { if (tuple_check) { Py_INCREF(value); } return value; } }
PyObject * Bytes_Format(PyObject *format, PyObject *args) { char *fmt, *res; Py_ssize_t arglen, argidx; Py_ssize_t reslen, rescnt, fmtcnt; int args_owned = 0; PyObject *result; PyObject *dict = NULL; if (format == NULL || !Bytes_Check(format) || args == NULL) { PyErr_BadInternalCall(); return NULL; } fmt = Bytes_AS_STRING(format); fmtcnt = Bytes_GET_SIZE(format); reslen = rescnt = fmtcnt + 100; result = Bytes_FromStringAndSize((char *)NULL, reslen); if (result == NULL) return NULL; res = Bytes_AsString(result); if (PyTuple_Check(args)) { arglen = PyTuple_GET_SIZE(args); argidx = 0; } else { arglen = -1; argidx = -2; } if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && !PyObject_TypeCheck(args, &Bytes_Type)) dict = args; while (--fmtcnt >= 0) { if (*fmt != '%') { if (--rescnt < 0) { rescnt = fmtcnt + 100; reslen += rescnt; if (_Bytes_Resize(&result, reslen)) return NULL; res = Bytes_AS_STRING(result) + reslen - rescnt; --rescnt; } *res++ = *fmt++; } else { /* Got a format specifier */ Py_ssize_t width = -1; int c = '\0'; PyObject *v = NULL; PyObject *temp = NULL; char *pbuf; Py_ssize_t len; fmt++; if (*fmt == '(') { char *keystart; Py_ssize_t keylen; PyObject *key; int pcount = 1; if (dict == NULL) { PyErr_SetString(PyExc_TypeError, "format requires a mapping"); goto error; } ++fmt; --fmtcnt; keystart = fmt; /* Skip over balanced parentheses */ while (pcount > 0 && --fmtcnt >= 0) { if (*fmt == ')') --pcount; else if (*fmt == '(') ++pcount; fmt++; } keylen = fmt - keystart - 1; if (fmtcnt < 0 || pcount > 0) { PyErr_SetString(PyExc_ValueError, "incomplete format key"); goto error; } key = Text_FromUTF8AndSize(keystart, keylen); if (key == NULL) goto error; if (args_owned) { Py_DECREF(args); args_owned = 0; } args = PyObject_GetItem(dict, key); Py_DECREF(key); if (args == NULL) { goto error; } args_owned = 1; arglen = -1; argidx = -2; } while (--fmtcnt >= 0) { c = *fmt++; break; } if (fmtcnt < 0) { PyErr_SetString(PyExc_ValueError, "incomplete format"); goto error; } if (c != '%') { v = getnextarg(args, arglen, &argidx); if (v == NULL) goto error; } switch (c) { case '%': pbuf = "%"; len = 1; break; case 's': /* only bytes! */ if (!Bytes_CheckExact(v)) { PyErr_Format(PyExc_ValueError, "only bytes values expected, got %s", Py_TYPE(v)->tp_name); goto error; } temp = v; Py_INCREF(v); pbuf = Bytes_AS_STRING(temp); len = Bytes_GET_SIZE(temp); break; default: PyErr_Format(PyExc_ValueError, "unsupported format character '%c' (0x%x) " "at index " FORMAT_CODE_PY_SSIZE_T, c, c, (Py_ssize_t)(fmt - 1 - Bytes_AsString(format))); goto error; } if (width < len) width = len; if (rescnt < width) { reslen -= rescnt; rescnt = width + fmtcnt + 100; reslen += rescnt; if (reslen < 0) { Py_DECREF(result); Py_XDECREF(temp); return PyErr_NoMemory(); } if (_Bytes_Resize(&result, reslen)) { Py_XDECREF(temp); return NULL; } res = Bytes_AS_STRING(result) + reslen - rescnt; } Py_MEMCPY(res, pbuf, len); res += len; rescnt -= len; while (--width >= len) { --rescnt; *res++ = ' '; } if (dict && (argidx < arglen) && c != '%') { PyErr_SetString(PyExc_TypeError, "not all arguments converted during string formatting"); Py_XDECREF(temp); goto error; } Py_XDECREF(temp); } /* '%' */ } /* until end */ if (argidx < arglen && !dict) { PyErr_SetString(PyExc_TypeError, "not all arguments converted during string formatting"); goto error; } if (args_owned) { Py_DECREF(args); } if (_Bytes_Resize(&result, reslen - rescnt)) return NULL; return result; error: Py_DECREF(result); if (args_owned) { Py_DECREF(args); } return NULL; }