From a9c38636651e869128a12df52c2cb05840a6f205 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 16 Jul 2015 17:34:32 +0200 Subject: [PATCH] * Fix inefficiency in StringStore.dump function --- spacy/strings.pyx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spacy/strings.pyx b/spacy/strings.pyx index 56df4d2f1..55f4760b4 100644 --- a/spacy/strings.pyx +++ b/spacy/strings.pyx @@ -108,15 +108,15 @@ cdef class StringStore: return &self.strings[i] def dump(self, loc): - strings = [] cdef Utf8Str* string cdef bytes py_string - for i in range(self.size): - string = &self.strings[i] - py_string = string.chars[:string.length] - strings.append(py_string.decode('utf8')) + cdef int i with codecs.open(loc, 'w', 'utf8') as file_: - file_.write(SEPARATOR.join(strings)) + for i in range(self.size): + string = &self.strings[i] + py_string = string.chars[:string.length] + file_.write(py_string.decode('utf8')) + file_.write(SEPARATOR) def load(self, loc): with codecs.open(loc, 'r', 'utf8') as file_: