From d82e6396cef0d56b141055cbbc3db792d272f202 Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Mon, 24 Dec 2012 13:23:49 +0100 Subject: Fix memory freeing --- python/src/_cdec.cpp | 36 ++- python/src/sa/_sa.c | 648 ++++++++++++++++++++++++------------------- python/src/sa/_sa.pxd | 4 + python/src/sa/float_list.pxi | 16 +- python/src/sa/int_list.pxi | 18 +- 5 files changed, 420 insertions(+), 302 deletions(-) diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp index 86a41763..17e47189 100644 --- a/python/src/_cdec.cpp +++ b/python/src/_cdec.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.1 on Sun Dec 23 21:56:58 2012 */ +/* Generated by Cython 0.17.1 on Mon Dec 24 12:57:08 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -450,7 +450,7 @@ struct __pyx_opt_args_5_cdec_as_str { char *error_msg; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":39 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":43 * cdef void read_mmaped(self, MemoryMap buf) * * cdef class FeatureVector: # <<<<<<<<<<<<<< @@ -504,7 +504,7 @@ struct __pyx_obj_5_cdec_Scorer { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":25 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":27 * cdef void read_mmaped(self, MemoryMap buf) * * cdef class IntList: # <<<<<<<<<<<<<< @@ -518,11 +518,12 @@ struct __pyx_obj_4cdec_2sa_3_sa_IntList { int increment; int len; int *arr; + int mmaped; PyObject *memory; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":43 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":47 * cdef FloatList values * * cdef class Phrase: # <<<<<<<<<<<<<< @@ -681,6 +682,14 @@ struct __pyx_obj_5_cdec_TRule { boost::shared_ptr *rule; }; + +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":53 + * cdef public int chunklen(self, int k) + * + * cdef class Rule: # <<<<<<<<<<<<<< + * cdef int lhs + * cdef readonly Phrase f, e + */ struct __pyx_obj_4cdec_2sa_3_sa_Rule { PyObject_HEAD int lhs; @@ -824,6 +833,7 @@ struct __pyx_obj_4cdec_2sa_3_sa_FloatList { int increment; int len; float *arr; + int mmaped; PyObject *memory; }; @@ -1274,6 +1284,7 @@ static struct __pyx_vtabstruct_5_cdec_Hypergraph *__pyx_vtabptr_5_cdec_Hypergrap */ struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList { + void (*_free_mem)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *); void (*set)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, int, float); void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); @@ -1296,7 +1307,7 @@ struct __pyx_vtabstruct_5_cdec_HypergraphNode { static struct __pyx_vtabstruct_5_cdec_HypergraphNode *__pyx_vtabptr_5_cdec_HypergraphNode; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":25 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":27 * cdef void read_mmaped(self, MemoryMap buf) * * cdef class IntList: # <<<<<<<<<<<<<< @@ -1309,6 +1320,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList { void (*_append)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int); void (*_extend_arr)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int *, int); void (*_clear)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *); + void (*_free_mem)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *); void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); void (*read_mmaped)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, struct __pyx_obj_4cdec_2sa_3_sa_MemoryMap *); @@ -1330,7 +1342,7 @@ struct __pyx_vtabstruct_5_cdec_HypergraphEdge { static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":43 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":47 * cdef FloatList values * * cdef class Phrase: # <<<<<<<<<<<<<< @@ -29511,12 +29523,12 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_vtabptr_4cdec_2sa_3_sa_MemoryMap = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_MemoryMap*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_MemoryMap->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_MemoryMap)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_4cdec_2sa_3_sa_FloatList = __Pyx_ImportType("cdec.sa._sa", "FloatList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FloatList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_vtabptr_4cdec_2sa_3_sa_FloatList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_FloatList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("cdec.sa._sa"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} diff --git a/python/src/sa/_sa.c b/python/src/sa/_sa.c index f0690237..f1c1e5ec 100644 --- a/python/src/sa/_sa.c +++ b/python/src/sa/_sa.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.1 on Sun Dec 23 22:31:04 2012 */ +/* Generated by Cython 0.17.1 on Mon Dec 24 12:55:10 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -638,7 +638,7 @@ struct __pyx_obj_3_sa___pyx_scope_struct_18_genexpr { }; -/* "_sa.pxd":25 +/* "_sa.pxd":27 * cdef void read_mmaped(self, MemoryMap buf) * * cdef class IntList: # <<<<<<<<<<<<<< @@ -652,6 +652,7 @@ struct __pyx_obj_3_sa_IntList { int increment; int len; int *arr; + int mmaped; PyObject *memory; }; @@ -821,7 +822,7 @@ struct __pyx_obj_3_sa_Alphabet { }; -/* "_sa.pxd":49 +/* "_sa.pxd":53 * cdef public int chunklen(self, int k) * * cdef class Rule: # <<<<<<<<<<<<<< @@ -939,7 +940,7 @@ struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext { }; -/* "_sa.pxd":39 +/* "_sa.pxd":43 * cdef void read_mmaped(self, MemoryMap buf) * * cdef class FeatureVector: # <<<<<<<<<<<<<< @@ -1262,7 +1263,7 @@ struct __pyx_obj_3_sa___pyx_scope_struct_13_genexpr { }; -/* "_sa.pxd":43 +/* "_sa.pxd":47 * cdef FloatList values * * cdef class Phrase: # <<<<<<<<<<<<<< @@ -1279,8 +1280,8 @@ struct __pyx_obj_3_sa_Phrase { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":38 - * free(self.arr) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":43 + * self._free_mem() * * def __iter__(self): # <<<<<<<<<<<<<< * cdef int i @@ -1372,6 +1373,7 @@ struct __pyx_obj_3_sa_FloatList { int increment; int len; float *arr; + int mmaped; PyObject *memory; }; @@ -1483,6 +1485,7 @@ struct __pyx_vtabstruct_3_sa_IntList { void (*_append)(struct __pyx_obj_3_sa_IntList *, int); void (*_extend_arr)(struct __pyx_obj_3_sa_IntList *, int *, int); void (*_clear)(struct __pyx_obj_3_sa_IntList *); + void (*_free_mem)(struct __pyx_obj_3_sa_IntList *); void (*write_handle)(struct __pyx_obj_3_sa_IntList *, FILE *); void (*read_handle)(struct __pyx_obj_3_sa_IntList *, FILE *); void (*read_mmaped)(struct __pyx_obj_3_sa_IntList *, struct __pyx_obj_3_sa_MemoryMap *); @@ -1558,6 +1561,7 @@ static struct __pyx_vtabstruct_3_sa_Scorer *__pyx_vtabptr_3_sa_Scorer; */ struct __pyx_vtabstruct_3_sa_FloatList { + void (*_free_mem)(struct __pyx_obj_3_sa_FloatList *); void (*set)(struct __pyx_obj_3_sa_FloatList *, int, float); void (*write_handle)(struct __pyx_obj_3_sa_FloatList *, FILE *); void (*read_handle)(struct __pyx_obj_3_sa_FloatList *, FILE *); @@ -3959,7 +3963,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ * self.len = initial_len * self.arr = malloc(size*sizeof(float)) # <<<<<<<<<<<<<< * memset(self.arr, 0, initial_len*sizeof(float)) - * self.memory = self + * self.mmaped = False */ __pyx_v_self->arr = ((float *)malloc((__pyx_v_size * (sizeof(float))))); @@ -3967,7 +3971,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ * self.len = initial_len * self.arr = malloc(size*sizeof(float)) * memset(self.arr, 0, initial_len*sizeof(float)) # <<<<<<<<<<<<<< - * self.memory = self + * self.mmaped = False * */ memset(__pyx_v_self->arr, 0, (__pyx_v_initial_len * (sizeof(float)))); @@ -3975,21 +3979,68 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":19 * self.arr = malloc(size*sizeof(float)) * memset(self.arr, 0, initial_len*sizeof(float)) - * self.memory = self # <<<<<<<<<<<<<< + * self.mmaped = False # <<<<<<<<<<<<<< * - * def __dealloc__(self): + * cdef void _free_mem(self): */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_self->memory); - __Pyx_DECREF(__pyx_v_self->memory); - __pyx_v_self->memory = ((PyObject *)__pyx_v_self); + __pyx_v_self->mmaped = 0; __pyx_r = 0; __Pyx_RefNannyFinishContext(); return __pyx_r; } +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":21 + * self.mmaped = False + * + * cdef void _free_mem(self): # <<<<<<<<<<<<<< + * if self.mmaped: + * self.memory = None + */ + +static void __pyx_f_3_sa_9FloatList__free_mem(struct __pyx_obj_3_sa_FloatList *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_free_mem", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":22 + * + * cdef void _free_mem(self): + * if self.mmaped: # <<<<<<<<<<<<<< + * self.memory = None + * else: + */ + if (__pyx_v_self->mmaped) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":23 + * cdef void _free_mem(self): + * if self.mmaped: + * self.memory = None # <<<<<<<<<<<<<< + * else: + * free(self.arr) + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->memory); + __Pyx_DECREF(__pyx_v_self->memory); + __pyx_v_self->memory = Py_None; + goto __pyx_L3; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":25 + * self.memory = None + * else: + * free(self.arr) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + free(__pyx_v_self->arr); + } + __pyx_L3:; + + __Pyx_RefNannyFinishContext(); +} + /* Python wrapper */ static void __pyx_pw_3_sa_9FloatList_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_3_sa_9FloatList_3__dealloc__(PyObject *__pyx_v_self) { @@ -3999,40 +4050,26 @@ static void __pyx_pw_3_sa_9FloatList_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":21 - * self.memory = self +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":27 + * free(self.arr) * * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self.memory is self: - * free(self.arr) + * self._free_mem() + * */ static void __pyx_pf_3_sa_9FloatList_2__dealloc__(struct __pyx_obj_3_sa_FloatList *__pyx_v_self) { __Pyx_RefNannyDeclarations - int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":22 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":28 * * def __dealloc__(self): - * if self.memory is self: # <<<<<<<<<<<<<< - * free(self.arr) - * - */ - __pyx_t_1 = (__pyx_v_self->memory == ((PyObject *)__pyx_v_self)); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":23 - * def __dealloc__(self): - * if self.memory is self: - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * * def __getitem__(self, i): */ - free(__pyx_v_self->arr); - goto __pyx_L3; - } - __pyx_L3:; + ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); __Pyx_RefNannyFinishContext(); } @@ -4048,8 +4085,8 @@ static PyObject *__pyx_pw_3_sa_9FloatList_5__getitem__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":25 - * free(self.arr) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":30 + * self._free_mem() * * def __getitem__(self, i): # <<<<<<<<<<<<<< * j = i @@ -4071,7 +4108,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":26 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":31 * * def __getitem__(self, i): * j = i # <<<<<<<<<<<<<< @@ -4081,28 +4118,28 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo __Pyx_INCREF(__pyx_v_i); __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":27 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":32 * def __getitem__(self, i): * j = i * if i<0: # <<<<<<<<<<<<<< * j = self.len + i * if j<0 or j>=self.len: */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":28 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":33 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_j); @@ -4112,22 +4149,22 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":29 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":34 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * return self.arr[j] */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_2) { - __pyx_t_3 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_j, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(__pyx_v_j, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_4; } else { @@ -4135,16 +4172,16 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo } if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":30 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":35 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) # <<<<<<<<<<<<<< * return self.arr[j] * */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); @@ -4152,25 +4189,25 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":31 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":36 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * return self.arr[j] # <<<<<<<<<<<<<< @@ -4178,8 +4215,8 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo * cdef void set(self, int i, float v): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_j); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->arr[__pyx_t_6])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_j); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->arr[__pyx_t_6])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4199,7 +4236,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":33 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":38 * return self.arr[j] * * cdef void set(self, int i, float v): # <<<<<<<<<<<<<< @@ -4221,7 +4258,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":34 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":39 * * cdef void set(self, int i, float v): * j = i # <<<<<<<<<<<<<< @@ -4230,7 +4267,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v */ __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":35 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":40 * cdef void set(self, int i, float v): * j = i * if i<0: # <<<<<<<<<<<<<< @@ -4240,7 +4277,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v __pyx_t_1 = (__pyx_v_i < 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":36 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":41 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< @@ -4252,7 +4289,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":37 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":42 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -4268,18 +4305,18 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v } if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":38 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":43 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) # <<<<<<<<<<<<<< * self.arr[j] = v * */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -4287,25 +4324,25 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":39 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":44 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * self.arr[j] = v # <<<<<<<<<<<<<< @@ -4335,7 +4372,7 @@ static int __pyx_pw_3_sa_9FloatList_7__setitem__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":41 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":46 * self.arr[j] = v * * def __setitem__(self, i, val): # <<<<<<<<<<<<<< @@ -4353,15 +4390,15 @@ static int __pyx_pf_3_sa_9FloatList_6__setitem__(struct __pyx_obj_3_sa_FloatList int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":42 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":47 * * def __setitem__(self, i, val): * self.set(i, val) # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->set(__pyx_v_self, __pyx_t_1, __pyx_t_2); __pyx_r = 0; @@ -4385,7 +4422,7 @@ static Py_ssize_t __pyx_pw_3_sa_9FloatList_9__len__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":44 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":49 * self.set(i, val) * * def __len__(self): # <<<<<<<<<<<<<< @@ -4398,7 +4435,7 @@ static Py_ssize_t __pyx_pf_3_sa_9FloatList_8__len__(struct __pyx_obj_3_sa_FloatL __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":45 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":50 * * def __len__(self): * return self.len # <<<<<<<<<<<<<< @@ -4422,7 +4459,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_11append(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append (wrapper)", 0); assert(__pyx_arg_val); { - __pyx_v_val = __pyx_PyFloat_AsFloat(__pyx_arg_val); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_val = __pyx_PyFloat_AsFloat(__pyx_arg_val); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4435,7 +4472,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_11append(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":47 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":52 * return self.len * * def append(self, float val): # <<<<<<<<<<<<<< @@ -4449,7 +4486,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi int __pyx_t_1; __Pyx_RefNannySetupContext("append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":48 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":53 * * def append(self, float val): * if self.len == self.size: # <<<<<<<<<<<<<< @@ -4459,7 +4496,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi __pyx_t_1 = (__pyx_v_self->len == __pyx_v_self->size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":49 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":54 * def append(self, float val): * if self.len == self.size: * self.size = self.size + self.increment # <<<<<<<<<<<<<< @@ -4468,7 +4505,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi */ __pyx_v_self->size = (__pyx_v_self->size + __pyx_v_self->increment); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":50 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":55 * if self.len == self.size: * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(float)) # <<<<<<<<<<<<<< @@ -4480,7 +4517,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":51 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":56 * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(float)) * self.arr[self.len] = val # <<<<<<<<<<<<<< @@ -4489,7 +4526,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi */ (__pyx_v_self->arr[__pyx_v_self->len]) = __pyx_v_val; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":52 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":57 * self.arr = realloc(self.arr, self.size*sizeof(float)) * self.arr[self.len] = val * self.len = self.len + 1 # <<<<<<<<<<<<<< @@ -4504,7 +4541,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":54 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":59 * self.len = self.len + 1 * * cdef void write_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -4516,7 +4553,7 @@ static void __pyx_f_3_sa_9FloatList_write_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":55 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":60 * * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< @@ -4525,7 +4562,7 @@ static void __pyx_f_3_sa_9FloatList_write_handle(struct __pyx_obj_3_sa_FloatList */ fwrite((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":56 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":61 * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) * fwrite(self.arr, sizeof(float), self.len, f) # <<<<<<<<<<<<<< @@ -4537,11 +4574,11 @@ static void __pyx_f_3_sa_9FloatList_write_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":58 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":63 * fwrite(self.arr, sizeof(float), self.len, f) * * cdef void read_handle(self, FILE* f): # <<<<<<<<<<<<<< - * free(self.arr) + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) */ @@ -4549,26 +4586,26 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":59 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":64 * * cdef void read_handle(self, FILE* f): - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(float)) */ - free(__pyx_v_self->arr); + ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":60 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":65 * cdef void read_handle(self, FILE* f): - * free(self.arr) + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< * self.arr = malloc(self.len * sizeof(float)) * self.size = self.len */ fread((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":61 - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":66 + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(float)) # <<<<<<<<<<<<<< * self.size = self.len @@ -4576,7 +4613,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ __pyx_v_self->arr = ((float *)malloc((__pyx_v_self->len * (sizeof(float))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":62 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":67 * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(float)) * self.size = self.len # <<<<<<<<<<<<<< @@ -4585,7 +4622,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ __pyx_v_self->size = __pyx_v_self->len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":63 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":68 * self.arr = malloc(self.len * sizeof(float)) * self.size = self.len * fread(self.arr, sizeof(float), self.len, f) # <<<<<<<<<<<<<< @@ -4597,11 +4634,11 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":65 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":70 * fread(self.arr, sizeof(float), self.len, f) * * cdef void read_mmaped(self, MemoryMap buf): # <<<<<<<<<<<<<< - * free(self.arr) + * self._free_mem() * self.size = self.len = buf.read_int() */ @@ -4610,37 +4647,46 @@ static void __pyx_f_3_sa_9FloatList_read_mmaped(struct __pyx_obj_3_sa_FloatList int __pyx_t_1; __Pyx_RefNannySetupContext("read_mmaped", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":66 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":71 * * cdef void read_mmaped(self, MemoryMap buf): - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * self.size = self.len = buf.read_int() * self.arr = buf.read_float_array(self.len) */ - free(__pyx_v_self->arr); + ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":67 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":72 * cdef void read_mmaped(self, MemoryMap buf): - * free(self.arr) + * self._free_mem() * self.size = self.len = buf.read_int() # <<<<<<<<<<<<<< * self.arr = buf.read_float_array(self.len) - * self.memory = buf + * self.mmaped = True */ __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_MemoryMap *)__pyx_v_buf->__pyx_vtab)->read_int(__pyx_v_buf); __pyx_v_self->size = __pyx_t_1; __pyx_v_self->len = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":68 - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":73 + * self._free_mem() * self.size = self.len = buf.read_int() * self.arr = buf.read_float_array(self.len) # <<<<<<<<<<<<<< + * self.mmaped = True * self.memory = buf */ __pyx_v_self->arr = ((struct __pyx_vtabstruct_3_sa_MemoryMap *)__pyx_v_buf->__pyx_vtab)->read_float_array(__pyx_v_buf, __pyx_v_self->len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":69 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":74 * self.size = self.len = buf.read_int() * self.arr = buf.read_float_array(self.len) + * self.mmaped = True # <<<<<<<<<<<<<< + * self.memory = buf + */ + __pyx_v_self->mmaped = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":75 + * self.arr = buf.read_float_array(self.len) + * self.mmaped = True * self.memory = buf # <<<<<<<<<<<<<< */ __Pyx_INCREF(((PyObject *)__pyx_v_buf)); @@ -4801,7 +4847,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx * self.len = initial_len * self.arr = malloc(size*sizeof(int)) # <<<<<<<<<<<<<< * memset(self.arr, 0, initial_len*sizeof(int)) - * self.memory = self + * self.mmaped = False */ __pyx_v_self->arr = ((int *)malloc((__pyx_v_size * (sizeof(int))))); @@ -4809,7 +4855,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx * self.len = initial_len * self.arr = malloc(size*sizeof(int)) * memset(self.arr, 0, initial_len*sizeof(int)) # <<<<<<<<<<<<<< - * self.memory = self + * self.mmaped = False * */ memset(__pyx_v_self->arr, 0, (__pyx_v_initial_len * (sizeof(int)))); @@ -4817,15 +4863,11 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":19 * self.arr = malloc(size*sizeof(int)) * memset(self.arr, 0, initial_len*sizeof(int)) - * self.memory = self # <<<<<<<<<<<<<< + * self.mmaped = False # <<<<<<<<<<<<<< * * def __repr__(self): */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_self->memory); - __Pyx_DECREF(__pyx_v_self->memory); - __pyx_v_self->memory = ((PyObject *)__pyx_v_self); + __pyx_v_self->mmaped = 0; __pyx_r = 0; __Pyx_RefNannyFinishContext(); @@ -4844,7 +4886,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_3__repr__(PyObject *__pyx_v_self) { } /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":21 - * self.memory = self + * self.mmaped = False * * def __repr__(self): # <<<<<<<<<<<<<< * return 'IntList(%s)' % list(self) @@ -5037,7 +5079,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6reset(struct __pyx_obj_3_sa_IntList *__ * def reset(self): * self.len = 0 # <<<<<<<<<<<<<< * - * def __dealloc__(self): + * cdef void _free_mem(self): */ __pyx_v_self->len = 0; @@ -5047,6 +5089,57 @@ static PyObject *__pyx_pf_3_sa_7IntList_6reset(struct __pyx_obj_3_sa_IntList *__ return __pyx_r; } +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":34 + * self.len = 0 + * + * cdef void _free_mem(self): # <<<<<<<<<<<<<< + * if self.mmaped: + * self.memory = None + */ + +static void __pyx_f_3_sa_7IntList__free_mem(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_free_mem", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":35 + * + * cdef void _free_mem(self): + * if self.mmaped: # <<<<<<<<<<<<<< + * self.memory = None + * else: + */ + if (__pyx_v_self->mmaped) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":36 + * cdef void _free_mem(self): + * if self.mmaped: + * self.memory = None # <<<<<<<<<<<<<< + * else: + * free(self.arr) + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_self->memory); + __Pyx_DECREF(__pyx_v_self->memory); + __pyx_v_self->memory = Py_None; + goto __pyx_L3; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":38 + * self.memory = None + * else: + * free(self.arr) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + free(__pyx_v_self->arr); + } + __pyx_L3:; + + __Pyx_RefNannyFinishContext(); +} + /* Python wrapper */ static void __pyx_pw_3_sa_7IntList_9__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_3_sa_7IntList_9__dealloc__(PyObject *__pyx_v_self) { @@ -5056,40 +5149,26 @@ static void __pyx_pw_3_sa_7IntList_9__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":34 - * self.len = 0 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":40 + * free(self.arr) * * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self.memory is self: - * free(self.arr) + * self._free_mem() + * */ static void __pyx_pf_3_sa_7IntList_8__dealloc__(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { __Pyx_RefNannyDeclarations - int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":35 - * - * def __dealloc__(self): - * if self.memory is self: # <<<<<<<<<<<<<< - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":41 * - */ - __pyx_t_1 = (__pyx_v_self->memory == ((PyObject *)__pyx_v_self)); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":36 * def __dealloc__(self): - * if self.memory is self: - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * * def __iter__(self): */ - free(__pyx_v_self->arr); - goto __pyx_L3; - } - __pyx_L3:; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); __Pyx_RefNannyFinishContext(); } @@ -5106,8 +5185,8 @@ static PyObject *__pyx_pw_3_sa_7IntList_11__iter__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":38 - * free(self.arr) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":43 + * self._free_mem() * * def __iter__(self): # <<<<<<<<<<<<<< * cdef int i @@ -5132,7 +5211,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_10__iter__(struct __pyx_obj_3_sa_IntList __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_7IntList_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_7IntList_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -5167,9 +5246,9 @@ static PyObject *__pyx_gb_3_sa_7IntList_12generator(__pyx_GeneratorObject *__pyx return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":40 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":45 * def __iter__(self): * cdef int i * for i in range(self.len): # <<<<<<<<<<<<<< @@ -5180,14 +5259,14 @@ static PyObject *__pyx_gb_3_sa_7IntList_12generator(__pyx_GeneratorObject *__pyx for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":46 * cdef int i * for i in range(self.len): * yield self.arr[i] # <<<<<<<<<<<<<< * * def __getitem__(self, index): */ - __pyx_t_3 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_self->arr[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_self->arr[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -5201,7 +5280,7 @@ static PyObject *__pyx_gb_3_sa_7IntList_12generator(__pyx_GeneratorObject *__pyx __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -5227,7 +5306,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_14__getitem__(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":43 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":48 * yield self.arr[i] * * def __getitem__(self, index): # <<<<<<<<<<<<<< @@ -5257,7 +5336,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":45 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":50 * def __getitem__(self, index): * cdef int i, j, k * if isinstance(index, int): # <<<<<<<<<<<<<< @@ -5270,17 +5349,17 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":46 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":51 * cdef int i, j, k * if isinstance(index, int): * j = index # <<<<<<<<<<<<<< * if j < 0: * j = self.len + j */ - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_j = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":47 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":52 * if isinstance(index, int): * j = index * if j < 0: # <<<<<<<<<<<<<< @@ -5290,7 +5369,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_2 = (__pyx_v_j < 0); if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":48 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":53 * j = index * if j < 0: * j = self.len + j # <<<<<<<<<<<<<< @@ -5302,7 +5381,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":49 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":54 * if j < 0: * j = self.len + j * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -5318,16 +5397,16 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":50 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":55 * j = self.len + j * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) # <<<<<<<<<<<<<< * return self.arr[j] * elif isinstance(index, slice): */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_index); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_index); @@ -5335,25 +5414,25 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":51 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":56 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) * return self.arr[j] # <<<<<<<<<<<<<< @@ -5361,7 +5440,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL * i = index.start */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_j])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_j])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5369,7 +5448,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":52 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":57 * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) * return self.arr[j] * elif isinstance(index, slice): # <<<<<<<<<<<<<< @@ -5382,33 +5461,33 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":53 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":58 * return self.arr[j] * elif isinstance(index, slice): * i = index.start # <<<<<<<<<<<<<< * j = index.stop * if i < 0: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":54 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":59 * elif isinstance(index, slice): * i = index.start * j = index.stop # <<<<<<<<<<<<<< * if i < 0: * i = self.len + i */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_j = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":55 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":60 * i = index.start * j = index.stop * if i < 0: # <<<<<<<<<<<<<< @@ -5418,7 +5497,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_5 = (__pyx_v_i < 0); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":56 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":61 * j = index.stop * if i < 0: * i = self.len + i # <<<<<<<<<<<<<< @@ -5430,7 +5509,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":57 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":62 * if i < 0: * i = self.len + i * if j < 0: # <<<<<<<<<<<<<< @@ -5440,7 +5519,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_5 = (__pyx_v_j < 0); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":63 * i = self.len + i * if j < 0: * j = self.len + j # <<<<<<<<<<<<<< @@ -5452,7 +5531,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":59 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":64 * if j < 0: * j = self.len + j * if i < 0 or i >= self.len or j < 0 or j > self.len: # <<<<<<<<<<<<<< @@ -5480,20 +5559,20 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":60 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":65 * j = self.len + j * if i < 0 or i >= self.len or j < 0 or j > self.len: * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) # <<<<<<<<<<<<<< * result = () * for k from i <= k < j: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_9 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -5504,25 +5583,25 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9)); __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":61 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":66 * if i < 0 or i >= self.len or j < 0 or j > self.len: * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) * result = () # <<<<<<<<<<<<<< @@ -5532,7 +5611,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); __pyx_v_result = __pyx_empty_tuple; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":62 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":67 * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) * result = () * for k from i <= k < j: # <<<<<<<<<<<<<< @@ -5542,21 +5621,21 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_3 = __pyx_v_j; for (__pyx_v_k = __pyx_v_i; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":63 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":68 * result = () * for k from i <= k < j: * result = result + (self.arr[k],) # <<<<<<<<<<<<<< * return result * else: */ - __pyx_t_9 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_k])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_k])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_result)); @@ -5564,7 +5643,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_9 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":69 * for k from i <= k < j: * result = result + (self.arr[k],) * return result # <<<<<<<<<<<<<< @@ -5579,26 +5658,26 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":66 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":71 * return result * else: * raise TypeError("Illegal key type %s for IntList" % type(index)) # <<<<<<<<<<<<<< * * cdef void set(self, int i, int val): */ - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)Py_TYPE(__pyx_v_index))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)Py_TYPE(__pyx_v_index))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9)); __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -5618,7 +5697,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_13__getitem__(struct __pyx_obj_3_sa_IntL return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":68 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":73 * raise TypeError("Illegal key type %s for IntList" % type(index)) * * cdef void set(self, int i, int val): # <<<<<<<<<<<<<< @@ -5640,7 +5719,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":69 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":74 * * cdef void set(self, int i, int val): * j = i # <<<<<<<<<<<<<< @@ -5649,7 +5728,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel */ __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":70 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":75 * cdef void set(self, int i, int val): * j = i * if i<0: # <<<<<<<<<<<<<< @@ -5659,7 +5738,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel __pyx_t_1 = (__pyx_v_i < 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":71 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":76 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< @@ -5671,7 +5750,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":72 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":77 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -5687,18 +5766,18 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel } if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":73 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":78 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (i, self.len)) # <<<<<<<<<<<<<< * self.arr[j] = val * */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -5706,25 +5785,25 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":74 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":79 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (i, self.len)) * self.arr[j] = val # <<<<<<<<<<<<<< @@ -5754,7 +5833,7 @@ static int __pyx_pw_3_sa_7IntList_16__setitem__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":76 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":81 * self.arr[j] = val * * def __setitem__(self, i, val): # <<<<<<<<<<<<<< @@ -5772,15 +5851,15 @@ static int __pyx_pf_3_sa_7IntList_15__setitem__(struct __pyx_obj_3_sa_IntList *_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":77 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":82 * * def __setitem__(self, i, val): * self.set(i, val) # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_val); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_val); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->set(__pyx_v_self, __pyx_t_1, __pyx_t_2); __pyx_r = 0; @@ -5804,7 +5883,7 @@ static Py_ssize_t __pyx_pw_3_sa_7IntList_18__len__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":79 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":84 * self.set(i, val) * * def __len__(self): # <<<<<<<<<<<<<< @@ -5817,7 +5896,7 @@ static Py_ssize_t __pyx_pf_3_sa_7IntList_17__len__(struct __pyx_obj_3_sa_IntList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":80 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":85 * * def __len__(self): * return self.len # <<<<<<<<<<<<<< @@ -5841,7 +5920,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_20append(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append (wrapper)", 0); assert(__pyx_arg_val); { - __pyx_v_val = __Pyx_PyInt_AsInt(__pyx_arg_val); if (unlikely((__pyx_v_val == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_val = __Pyx_PyInt_AsInt(__pyx_arg_val); if (unlikely((__pyx_v_val == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5854,7 +5933,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_20append(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":82 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":87 * return self.len * * def append(self, int val): # <<<<<<<<<<<<<< @@ -5867,7 +5946,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_19append(struct __pyx_obj_3_sa_IntList * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":83 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":88 * * def append(self, int val): * self._append(val) # <<<<<<<<<<<<<< @@ -5882,7 +5961,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_19append(struct __pyx_obj_3_sa_IntList * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":85 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":90 * self._append(val) * * cdef void _append(self, int val): # <<<<<<<<<<<<<< @@ -5895,7 +5974,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v int __pyx_t_1; __Pyx_RefNannySetupContext("_append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":86 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":91 * * cdef void _append(self, int val): * if self.len == self.size: # <<<<<<<<<<<<<< @@ -5905,7 +5984,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v __pyx_t_1 = (__pyx_v_self->len == __pyx_v_self->size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":87 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":92 * cdef void _append(self, int val): * if self.len == self.size: * self.size = self.size + self.increment # <<<<<<<<<<<<<< @@ -5914,7 +5993,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v */ __pyx_v_self->size = (__pyx_v_self->size + __pyx_v_self->increment); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":88 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":93 * if self.len == self.size: * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(int)) # <<<<<<<<<<<<<< @@ -5926,7 +6005,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":89 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":94 * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(int)) * self.arr[self.len] = val # <<<<<<<<<<<<<< @@ -5935,7 +6014,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v */ (__pyx_v_self->arr[__pyx_v_self->len]) = __pyx_v_val; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":90 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":95 * self.arr = realloc(self.arr, self.size*sizeof(int)) * self.arr[self.len] = val * self.len = self.len + 1 # <<<<<<<<<<<<<< @@ -5953,7 +6032,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_22extend(PyObject *__pyx_v_self, PyObjec PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("extend (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_3_sa_IntList, 1, "other", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_3_sa_IntList, 1, "other", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3_sa_7IntList_21extend(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((struct __pyx_obj_3_sa_IntList *)__pyx_v_other)); goto __pyx_L0; __pyx_L1_error:; @@ -5963,7 +6042,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_22extend(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":92 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":97 * self.len = self.len + 1 * * def extend(self, IntList other): # <<<<<<<<<<<<<< @@ -5976,7 +6055,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_21extend(struct __pyx_obj_3_sa_IntList * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("extend", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":93 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":98 * * def extend(self, IntList other): * self._extend_arr(other.arr, other.len) # <<<<<<<<<<<<<< @@ -5991,7 +6070,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_21extend(struct __pyx_obj_3_sa_IntList * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":95 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":100 * self._extend_arr(other.arr, other.len) * * cdef void _extend_arr(self, int* other, int other_len): # <<<<<<<<<<<<<< @@ -6004,7 +6083,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p int __pyx_t_1; __Pyx_RefNannySetupContext("_extend_arr", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":96 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":101 * * cdef void _extend_arr(self, int* other, int other_len): * if self.size < self.len + other_len: # <<<<<<<<<<<<<< @@ -6014,7 +6093,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p __pyx_t_1 = (__pyx_v_self->size < (__pyx_v_self->len + __pyx_v_other_len)); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":97 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":102 * cdef void _extend_arr(self, int* other, int other_len): * if self.size < self.len + other_len: * self.size = self.len + other_len # <<<<<<<<<<<<<< @@ -6023,7 +6102,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->size = (__pyx_v_self->len + __pyx_v_other_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":98 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":103 * if self.size < self.len + other_len: * self.size = self.len + other_len * self.arr = realloc(self.arr, self.size*sizeof(int)) # <<<<<<<<<<<<<< @@ -6035,7 +6114,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":99 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":104 * self.size = self.len + other_len * self.arr = realloc(self.arr, self.size*sizeof(int)) * memcpy(self.arr+self.len, other, other_len*sizeof(int)) # <<<<<<<<<<<<<< @@ -6044,7 +6123,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p */ memcpy((__pyx_v_self->arr + __pyx_v_self->len), __pyx_v_other, (__pyx_v_other_len * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":100 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":105 * self.arr = realloc(self.arr, self.size*sizeof(int)) * memcpy(self.arr+self.len, other, other_len*sizeof(int)) * self.len = self.len + other_len # <<<<<<<<<<<<<< @@ -6056,11 +6135,11 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":102 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":107 * self.len = self.len + other_len * * cdef void _clear(self): # <<<<<<<<<<<<<< - * free(self.arr) + * self._free_mem() * self.len = 0 */ @@ -6068,26 +6147,26 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_clear", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":103 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":108 * * cdef void _clear(self): - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * self.len = 0 * self.size = 0 */ - free(__pyx_v_self->arr); + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":104 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":109 * cdef void _clear(self): - * free(self.arr) + * self._free_mem() * self.len = 0 # <<<<<<<<<<<<<< * self.size = 0 * self.arr = malloc(0) */ __pyx_v_self->len = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":105 - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":110 + * self._free_mem() * self.len = 0 * self.size = 0 # <<<<<<<<<<<<<< * self.arr = malloc(0) @@ -6095,7 +6174,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ */ __pyx_v_self->size = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":106 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":111 * self.len = 0 * self.size = 0 * self.arr = malloc(0) # <<<<<<<<<<<<<< @@ -6107,7 +6186,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":108 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":113 * self.arr = malloc(0) * * cdef void write_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -6119,7 +6198,7 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":109 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":114 * * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< @@ -6128,7 +6207,7 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ */ fwrite((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":110 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":115 * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) * fwrite(self.arr, sizeof(int), self.len, f) # <<<<<<<<<<<<<< @@ -6140,11 +6219,11 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":112 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":117 * fwrite(self.arr, sizeof(int), self.len, f) * * cdef void read_handle(self, FILE* f): # <<<<<<<<<<<<<< - * free(self.arr) + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) */ @@ -6152,26 +6231,26 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":113 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":118 * * cdef void read_handle(self, FILE* f): - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(int)) */ - free(__pyx_v_self->arr); + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":114 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":119 * cdef void read_handle(self, FILE* f): - * free(self.arr) + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< * self.arr = malloc(self.len * sizeof(int)) * self.size = self.len */ fread((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":115 - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":120 + * self._free_mem() * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(int)) # <<<<<<<<<<<<<< * self.size = self.len @@ -6179,7 +6258,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->arr = ((int *)malloc((__pyx_v_self->len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":116 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":121 * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(int)) * self.size = self.len # <<<<<<<<<<<<<< @@ -6188,7 +6267,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->size = __pyx_v_self->len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":117 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":122 * self.arr = malloc(self.len * sizeof(int)) * self.size = self.len * fread(self.arr, sizeof(int), self.len, f) # <<<<<<<<<<<<<< @@ -6200,11 +6279,11 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":119 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":124 * fread(self.arr, sizeof(int), self.len, f) * * cdef void read_mmaped(self, MemoryMap buf): # <<<<<<<<<<<<<< - * free(self.arr) + * self._free_mem() * self.size = self.len = buf.read_int() */ @@ -6213,37 +6292,46 @@ static void __pyx_f_3_sa_7IntList_read_mmaped(struct __pyx_obj_3_sa_IntList *__p int __pyx_t_1; __Pyx_RefNannySetupContext("read_mmaped", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":120 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":125 * * cdef void read_mmaped(self, MemoryMap buf): - * free(self.arr) # <<<<<<<<<<<<<< + * self._free_mem() # <<<<<<<<<<<<<< * self.size = self.len = buf.read_int() * self.arr = buf.read_int_array(self.len) */ - free(__pyx_v_self->arr); + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->_free_mem(__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":121 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":126 * cdef void read_mmaped(self, MemoryMap buf): - * free(self.arr) + * self._free_mem() * self.size = self.len = buf.read_int() # <<<<<<<<<<<<<< * self.arr = buf.read_int_array(self.len) - * self.memory = buf + * self.mmaped = True */ __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_MemoryMap *)__pyx_v_buf->__pyx_vtab)->read_int(__pyx_v_buf); __pyx_v_self->size = __pyx_t_1; __pyx_v_self->len = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":122 - * free(self.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":127 + * self._free_mem() * self.size = self.len = buf.read_int() * self.arr = buf.read_int_array(self.len) # <<<<<<<<<<<<<< + * self.mmaped = True * self.memory = buf */ __pyx_v_self->arr = ((struct __pyx_vtabstruct_3_sa_MemoryMap *)__pyx_v_buf->__pyx_vtab)->read_int_array(__pyx_v_buf, __pyx_v_self->len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":123 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":128 * self.size = self.len = buf.read_int() * self.arr = buf.read_int_array(self.len) + * self.mmaped = True # <<<<<<<<<<<<<< + * self.memory = buf + */ + __pyx_v_self->mmaped = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":129 + * self.arr = buf.read_int_array(self.len) + * self.mmaped = True * self.memory = buf # <<<<<<<<<<<<<< */ __Pyx_INCREF(((PyObject *)__pyx_v_buf)); @@ -27399,7 +27487,7 @@ static PyObject *__pyx_pw_3_sa_4Rule_1f_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "_sa.pxd":51 +/* "_sa.pxd":55 * cdef class Rule: * cdef int lhs * cdef readonly Phrase f, e # <<<<<<<<<<<<<< @@ -67236,10 +67324,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_map = __Pyx_GetName(__pyx_b, __pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -68231,6 +68319,7 @@ PyMODINIT_FUNC PyInit__sa(void) if (__Pyx_SetAttrString(__pyx_m, "MemoryMap", (PyObject *)&__pyx_type_3_sa_MemoryMap) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_MemoryMap = &__pyx_type_3_sa_MemoryMap; __pyx_vtabptr_3_sa_FloatList = &__pyx_vtable_3_sa_FloatList; + __pyx_vtable_3_sa_FloatList._free_mem = (void (*)(struct __pyx_obj_3_sa_FloatList *))__pyx_f_3_sa_9FloatList__free_mem; __pyx_vtable_3_sa_FloatList.set = (void (*)(struct __pyx_obj_3_sa_FloatList *, int, float))__pyx_f_3_sa_9FloatList_set; __pyx_vtable_3_sa_FloatList.write_handle = (void (*)(struct __pyx_obj_3_sa_FloatList *, FILE *))__pyx_f_3_sa_9FloatList_write_handle; __pyx_vtable_3_sa_FloatList.read_handle = (void (*)(struct __pyx_obj_3_sa_FloatList *, FILE *))__pyx_f_3_sa_9FloatList_read_handle; @@ -68244,6 +68333,7 @@ PyMODINIT_FUNC PyInit__sa(void) __pyx_vtable_3_sa_IntList._append = (void (*)(struct __pyx_obj_3_sa_IntList *, int))__pyx_f_3_sa_7IntList__append; __pyx_vtable_3_sa_IntList._extend_arr = (void (*)(struct __pyx_obj_3_sa_IntList *, int *, int))__pyx_f_3_sa_7IntList__extend_arr; __pyx_vtable_3_sa_IntList._clear = (void (*)(struct __pyx_obj_3_sa_IntList *))__pyx_f_3_sa_7IntList__clear; + __pyx_vtable_3_sa_IntList._free_mem = (void (*)(struct __pyx_obj_3_sa_IntList *))__pyx_f_3_sa_7IntList__free_mem; __pyx_vtable_3_sa_IntList.write_handle = (void (*)(struct __pyx_obj_3_sa_IntList *, FILE *))__pyx_f_3_sa_7IntList_write_handle; __pyx_vtable_3_sa_IntList.read_handle = (void (*)(struct __pyx_obj_3_sa_IntList *, FILE *))__pyx_f_3_sa_7IntList_read_handle; __pyx_vtable_3_sa_IntList.read_mmaped = (void (*)(struct __pyx_obj_3_sa_IntList *, struct __pyx_obj_3_sa_MemoryMap *))__pyx_f_3_sa_7IntList_read_mmaped; @@ -68408,7 +68498,7 @@ PyMODINIT_FUNC PyInit__sa(void) if (__Pyx_SetVtable(__pyx_type_3_sa_Scorer.tp_dict, __pyx_vtabptr_3_sa_Scorer) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_3_sa_Scorer) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_Scorer = &__pyx_type_3_sa_Scorer; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa___pyx_scope_struct____iter__ = &__pyx_type_3_sa___pyx_scope_struct____iter__; if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_1_read_bitext) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa___pyx_scope_struct_1_read_bitext = &__pyx_type_3_sa___pyx_scope_struct_1_read_bitext; diff --git a/python/src/sa/_sa.pxd b/python/src/sa/_sa.pxd index 5c1fce27..da945f30 100644 --- a/python/src/sa/_sa.pxd +++ b/python/src/sa/_sa.pxd @@ -16,7 +16,9 @@ cdef class FloatList: cdef int increment cdef int len cdef float* arr + cdef bint mmaped cdef object memory + cdef void _free_mem(self) cdef void set(self, int i, float v) cdef void write_handle(self, FILE* f) cdef void read_handle(self, FILE* f) @@ -27,11 +29,13 @@ cdef class IntList: cdef int increment cdef int len cdef int* arr + cdef bint mmaped cdef object memory cdef void set(self, int i, int val) cdef void _append(self, int val) cdef void _extend_arr(self, int* other, int other_len) cdef void _clear(self) + cdef void _free_mem(self) cdef void write_handle(self, FILE* f) cdef void read_handle(self, FILE* f) cdef void read_mmaped(self, MemoryMap buf) diff --git a/python/src/sa/float_list.pxi b/python/src/sa/float_list.pxi index adc136be..a98487ac 100644 --- a/python/src/sa/float_list.pxi +++ b/python/src/sa/float_list.pxi @@ -16,12 +16,17 @@ cdef class FloatList: self.len = initial_len self.arr = malloc(size*sizeof(float)) memset(self.arr, 0, initial_len*sizeof(float)) - self.memory = self + self.mmaped = False - def __dealloc__(self): - if self.memory is self: + cdef void _free_mem(self): + if self.mmaped: + self.memory = None + else: free(self.arr) + def __dealloc__(self): + self._free_mem() + def __getitem__(self, i): j = i if i<0: @@ -56,14 +61,15 @@ cdef class FloatList: fwrite(self.arr, sizeof(float), self.len, f) cdef void read_handle(self, FILE* f): - free(self.arr) + self._free_mem() fread(&(self.len), sizeof(int), 1, f) self.arr = malloc(self.len * sizeof(float)) self.size = self.len fread(self.arr, sizeof(float), self.len, f) cdef void read_mmaped(self, MemoryMap buf): - free(self.arr) + self._free_mem() self.size = self.len = buf.read_int() self.arr = buf.read_float_array(self.len) + self.mmaped = True self.memory = buf diff --git a/python/src/sa/int_list.pxi b/python/src/sa/int_list.pxi index 8ccf7686..aa06953d 100644 --- a/python/src/sa/int_list.pxi +++ b/python/src/sa/int_list.pxi @@ -16,7 +16,7 @@ cdef class IntList: self.len = initial_len self.arr = malloc(size*sizeof(int)) memset(self.arr, 0, initial_len*sizeof(int)) - self.memory = self + self.mmaped = False def __repr__(self): return 'IntList(%s)' % list(self) @@ -31,10 +31,15 @@ cdef class IntList: def reset(self): self.len = 0 - def __dealloc__(self): - if self.memory is self: + cdef void _free_mem(self): + if self.mmaped: + self.memory = None + else: free(self.arr) + def __dealloc__(self): + self._free_mem() + def __iter__(self): cdef int i for i in range(self.len): @@ -100,7 +105,7 @@ cdef class IntList: self.len = self.len + other_len cdef void _clear(self): - free(self.arr) + self._free_mem() self.len = 0 self.size = 0 self.arr = malloc(0) @@ -110,14 +115,15 @@ cdef class IntList: fwrite(self.arr, sizeof(int), self.len, f) cdef void read_handle(self, FILE* f): - free(self.arr) + self._free_mem() fread(&(self.len), sizeof(int), 1, f) self.arr = malloc(self.len * sizeof(int)) self.size = self.len fread(self.arr, sizeof(int), self.len, f) cdef void read_mmaped(self, MemoryMap buf): - free(self.arr) + self._free_mem() self.size = self.len = buf.read_int() self.arr = buf.read_int_array(self.len) + self.mmaped = True self.memory = buf -- cgit v1.2.3