diff --git a/spacy/memory.pxd b/spacy/memory.pxd deleted file mode 100644 index dbe463c9c..000000000 --- a/spacy/memory.pxd +++ /dev/null @@ -1,12 +0,0 @@ -from libcpp.vector cimport vector -from cymem.cymem cimport Pool - -cdef class _Pool: - cdef vector[void*] _addresses - - cdef void* alloc(self, size_t number, size_t size) except NULL - cdef void* realloc(self, void* addr, size_t n) except NULL - - -cdef class Address: - cdef size_t addr diff --git a/spacy/memory.pyx b/spacy/memory.pyx deleted file mode 100644 index 0a4d82f34..000000000 --- a/spacy/memory.pyx +++ /dev/null @@ -1,41 +0,0 @@ -from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free -from libc.string cimport memset - -from libcpp.vector cimport vector - -from cymem cimport Pool - - -cdef class Pool: - def __cinit__(self): - pass - - def __dealloc__(self): - cdef void* addr - for addr in self._addresses: - PyMem_Free(addr) - - cdef void* alloc(self, size_t number, size_t size) except NULL: - cdef void* addr = PyMem_Malloc(number * size) - memset(addr, 0, number * size) - self._addresses.push_back(addr) - return addr - - cdef void* realloc(self, void* addr, size_t n) except NULL: - cdef size_t i - for i in range(self.size()): - if self._addresses[i] == addr: - self._addresses[i] = PyMem_Realloc(addr, n) - return self._addresses[i] - else: - raise MemoryError("Address to realloc not found in pool") - - -cdef class Address: - def __cinit__(self, size_t number, size_t size): - cdef void* addr = PyMem_Malloc(number * size) - memset(addr, 0, number * size) - self.addr = addr - - def __dealloc__(self): - PyMem_Free(self.addr)