Commits

Mikhail Korobov committed 26d2a0c

rebuild wrapper

  • Participants
  • Parent commits a7cae20

Comments (0)

Files changed (13)

src/_base_types.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"

src/_completer.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/dictionary.h"
 #include "../lib/dawgdic/guide-unit.h"
-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"

src/_dawg_builder.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"

src/_dictionary.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/dictionary.h"
 #ifdef _OPENMP

src/_dictionary_builder.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/dictionary.h"
 #include "../lib/dawgdic/dictionary-builder.h"

src/_dictionary_unit.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/guide.h"
 #ifdef _OPENMP

src/_guide_builder.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/dictionary.h"
 #include "../lib/dawgdic/guide-unit.h"

src/_guide_unit.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"

src/b64_decode.cpp

-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/b64/decode.h"
 #ifdef _OPENMP
-/* Generated by Cython 0.17 on Sat Sep  8 04:58:06 2012 */
+/* Generated by Cython 0.17 on Sat Sep  8 17:08:58 2012 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "stdexcept"
 #include "typeinfo"
 #include <istream>
+#include <fstream>
 #include <sstream>
 #include "../lib/dawgdic/base-types.h"
 #include "../lib/dawgdic/dawg.h"
 static const char *__pyx_f[] = {
   "dawg.pyx",
   "stringsource",
+  "stringsource",
 };
 
 /*--- Type declarations ---*/
 struct __pyx_opt_args_4dawg_10RecordDAWG_items;
 struct __pyx_opt_args_4dawg_7IntDAWG_get;
 
-/* "dawg.pyx":156
+/* "dawg.pyx":177
  *         del self.completer
  * 
  *     cpdef list keys(self, unicode prefix=""):             # <<<<<<<<<<<<<<
   PyObject *prefix;
 };
 
-/* "dawg.pyx":249
+/* "dawg.pyx":305
  *         return res
  * 
  *     cpdef get(self, key, default=None):             # <<<<<<<<<<<<<<
   PyObject *__pyx_default;
 };
 
-/* "dawg.pyx":303
+/* "dawg.pyx":359
  * 
  * 
  *     cpdef list items(self, unicode prefix=""):             # <<<<<<<<<<<<<<
   PyObject *prefix;
 };
 
-/* "dawg.pyx":343
+/* "dawg.pyx":399
  *         return res
  * 
  *     cpdef list keys(self, unicode prefix=""):             # <<<<<<<<<<<<<<
   PyObject *prefix;
 };
 
-/* "dawg.pyx":408
+/* "dawg.pyx":464
  * 
  * 
  *     cpdef list items(self, unicode prefix=""):             # <<<<<<<<<<<<<<
   PyObject *prefix;
 };
 
-/* "dawg.pyx":454
+/* "dawg.pyx":510
  *         return res
  * 
  *     cpdef get(self, key, default=None):             # <<<<<<<<<<<<<<
   PyObject *__pyx_default;
 };
 
-/* "dawg.pyx":384
+/* "dawg.pyx":440
  *     cdef _struct
  * 
  *     def __init__(self, fmt, arg=None, input_is_sorted=False):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":427
+/* "dawg.pyx":483
  * 
  *         if isinstance(arg, collections.Mapping):
  *             iterable = ((key, arg[key]) for key in arg)             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":21
+/* "dawg.pyx":23
  * from binascii import a2b_base64, b2a_base64
  * 
  * cdef class DAWG:             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":137
+/* "dawg.pyx":158
  * 
  * 
  * cdef class CompletionDAWG(DAWG):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":214
+/* "dawg.pyx":270
  * DEF MAX_VALUE_SIZE = 32768
  * 
  * cdef class BytesDAWG(CompletionDAWG):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":399
+/* "dawg.pyx":455
  *             arg = []
  * 
  *         keys = ((d[0], self._struct.pack(*d[1])) for d in arg)             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":223
+/* "dawg.pyx":279
  *     """
  * 
  *     def __init__(self, arg=None, input_is_sorted=False):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":418
+/* "dawg.pyx":474
  *     It can store integer values for unicode keys.
  *     """
  *     def __init__(self, arg=None, input_is_sorted=False):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":413
+/* "dawg.pyx":469
  * 
  * 
  * cdef class IntDAWG(DAWG):             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":230
+/* "dawg.pyx":286
  *             arg = []
  * 
  *         keys = (self._raw_key(d[0], d[1]) for d in arg)             # <<<<<<<<<<<<<<
 };
 
 
-/* "dawg.pyx":367
+/* "dawg.pyx":423
  * 
  * 
  * cdef class RecordDAWG(BytesDAWG):             # <<<<<<<<<<<<<<
 
 
 
-/* "dawg.pyx":21
+/* "dawg.pyx":23
  * from binascii import a2b_base64, b2a_base64
  * 
  * cdef class DAWG:             # <<<<<<<<<<<<<<
 static struct __pyx_vtabstruct_4dawg_DAWG *__pyx_vtabptr_4dawg_DAWG;
 
 
-/* "dawg.pyx":137
+/* "dawg.pyx":158
  * 
  * 
  * cdef class CompletionDAWG(DAWG):             # <<<<<<<<<<<<<<
 static struct __pyx_vtabstruct_4dawg_CompletionDAWG *__pyx_vtabptr_4dawg_CompletionDAWG;
 
 
-/* "dawg.pyx":214
+/* "dawg.pyx":270
  * DEF MAX_VALUE_SIZE = 32768
  * 
  * cdef class BytesDAWG(CompletionDAWG):             # <<<<<<<<<<<<<<
 static struct __pyx_vtabstruct_4dawg_BytesDAWG *__pyx_vtabptr_4dawg_BytesDAWG;
 
 
-/* "dawg.pyx":367
+/* "dawg.pyx":423
  * 
  * 
  * cdef class RecordDAWG(BytesDAWG):             # <<<<<<<<<<<<<<
 static struct __pyx_vtabstruct_4dawg_RecordDAWG *__pyx_vtabptr_4dawg_RecordDAWG;
 
 
-/* "dawg.pyx":413
+/* "dawg.pyx":469
  * 
  * 
  * cdef class IntDAWG(DAWG):             # <<<<<<<<<<<<<<
 static PyTypeObject *__pyx_ptype_4dawg___pyx_scope_struct_4___init__ = 0;
 static PyTypeObject *__pyx_ptype_4dawg___pyx_scope_struct_5_genexpr = 0;
 static PyObject *__pyx_convert_string_to_py_(const std::string &); /*proto*/
+static std::string __pyx_convert_string_from_py_(PyObject *); /*proto*/
 #define __Pyx_MODULE_NAME "dawg"
 int __pyx_module_is_main_dawg = 0;
 
 static PyObject *__pyx_pf_4dawg_14CompletionDAWG_4keys(struct __pyx_obj_4dawg_CompletionDAWG *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */
 static PyObject *__pyx_pf_4dawg_14CompletionDAWG_6tobytes(struct __pyx_obj_4dawg_CompletionDAWG *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_4dawg_14CompletionDAWG_8frombytes(struct __pyx_obj_4dawg_CompletionDAWG *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
+static PyObject *__pyx_pf_4dawg_14CompletionDAWG_10load(struct __pyx_obj_4dawg_CompletionDAWG *__pyx_v_self, PyObject *__pyx_v_path); /* proto */
 static PyObject *__pyx_pf_4dawg_9BytesDAWG_8__init___genexpr(PyObject *__pyx_self); /* proto */
 static int __pyx_pf_4dawg_9BytesDAWG___init__(struct __pyx_obj_4dawg_BytesDAWG *__pyx_v_self, PyObject *__pyx_v_arg, PyObject *__pyx_v_input_is_sorted); /* proto */
 static PyObject *__pyx_pf_4dawg_9BytesDAWG_2_raw_key(struct __pyx_obj_4dawg_BytesDAWG *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_payload); /* proto */
 static PyObject *__pyx_pf_4dawg_7IntDAWG_10b_get_value(struct __pyx_obj_4dawg_IntDAWG *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
 static char __pyx_k_2[] = "_build_from_iterable";
 static char __pyx_k_4[] = "Invalid data format";
-static char __pyx_k_9[] = "Error building completion information";
-static char __pyx_k_11[] = "";
-static char __pyx_k_12[] = "Invalid data format: can't load _dawg.Dictionary";
-static char __pyx_k_14[] = "Invalid data format: can't load _dawg.Guide";
-static char __pyx_k_17[] = "\377";
-static char __pyx_k_20[] = "Negative values are not supported";
-static char __pyx_k__rb[] = "rb";
+static char __pyx_k_6[] = "getfilesystemencoding";
+static char __pyx_k_10[] = "Error building completion information";
+static char __pyx_k_12[] = "";
+static char __pyx_k_13[] = "Invalid data format: can't load _dawg.Dictionary";
+static char __pyx_k_15[] = "Invalid data format: can't load _dawg.Guide";
+static char __pyx_k_20[] = "\377";
+static char __pyx_k_23[] = "Negative values are not supported";
 static char __pyx_k__wb[] = "wb";
 static char __pyx_k__arg[] = "arg";
 static char __pyx_k__fmt[] = "fmt";
 static char __pyx_k__get[] = "get";
 static char __pyx_k__key[] = "key";
+static char __pyx_k__sys[] = "sys";
 static char __pyx_k__keys[] = "keys";
 static char __pyx_k__open[] = "open";
 static char __pyx_k__pack[] = "pack";
 static char __pyx_k__b_get_value[] = "b_get_value";
 static char __pyx_k__collections[] = "collections";
 static char __pyx_k__input_is_sorted[] = "input_is_sorted";
-static PyObject *__pyx_kp_u_11;
+static PyObject *__pyx_kp_u_10;
 static PyObject *__pyx_kp_u_12;
-static PyObject *__pyx_kp_u_14;
-static PyObject *__pyx_kp_b_17;
+static PyObject *__pyx_kp_u_13;
+static PyObject *__pyx_kp_u_15;
 static PyObject *__pyx_n_s_2;
-static PyObject *__pyx_kp_u_20;
+static PyObject *__pyx_kp_b_20;
+static PyObject *__pyx_kp_u_23;
 static PyObject *__pyx_kp_u_4;
-static PyObject *__pyx_kp_u_9;
+static PyObject *__pyx_n_s_6;
 static PyObject *__pyx_n_s__Exception;
 static PyObject *__pyx_n_s__IOError;
 static PyObject *__pyx_n_s__KeyError;
 static PyObject *__pyx_n_s__payload;
 static PyObject *__pyx_n_s__prefix;
 static PyObject *__pyx_n_s__range;
-static PyObject *__pyx_n_u__rb;
 static PyObject *__pyx_n_s__read;
 static PyObject *__pyx_n_s__sorted;
 static PyObject *__pyx_n_s__struct;
 static PyObject *__pyx_n_s__super;
+static PyObject *__pyx_n_s__sys;
 static PyObject *__pyx_n_s__tobytes;
 static PyObject *__pyx_n_s__unpack;
 static PyObject *__pyx_n_u__utf8;
 static PyObject *__pyx_int_0;
 static PyObject *__pyx_int_neg_1;
 static PyObject *__pyx_k_1;
-static PyObject *__pyx_k_8;
-static PyObject *__pyx_k_16;
-static PyObject *__pyx_k_18;
+static PyObject *__pyx_k_9;
 static PyObject *__pyx_k_19;
+static PyObject *__pyx_k_21;
+static PyObject *__pyx_k_22;
 static PyObject *__pyx_k_tuple_3;
 static PyObject *__pyx_k_tuple_5;
-static PyObject *__pyx_k_tuple_6;
 static PyObject *__pyx_k_tuple_7;
-static PyObject *__pyx_k_tuple_10;
-static PyObject *__pyx_k_tuple_13;
-static PyObject *__pyx_k_tuple_15;
-static PyObject *__pyx_k_tuple_21;
-static PyObject *__pyx_k_tuple_22;
+static PyObject *__pyx_k_tuple_8;
+static PyObject *__pyx_k_tuple_11;
+static PyObject *__pyx_k_tuple_14;
+static PyObject *__pyx_k_tuple_16;
+static PyObject *__pyx_k_tuple_17;
+static PyObject *__pyx_k_tuple_18;
+static PyObject *__pyx_k_tuple_24;
+static PyObject *__pyx_k_tuple_25;
 
 /* Python wrapper */
 static void __pyx_pw_4dawg_4DAWG_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
   __Pyx_RefNannyFinishContext();
 }
 
-/* "dawg.pyx":28
+/* "dawg.pyx":30
  *     cdef _dawg.Dawg dawg
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 28);
-
-  /* "dawg.pyx":29
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 30);
+
+  /* "dawg.pyx":31
  * 
  *     def __dealloc__(self):
  *         self.dct.Clear()             # <<<<<<<<<<<<<<
  */
   __pyx_v_self->dct.Clear();
 
-  /* "dawg.pyx":30
+  /* "dawg.pyx":32
  *     def __dealloc__(self):
  *         self.dct.Clear()
  *         self.dawg.Clear()             # <<<<<<<<<<<<<<
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__arg,&__pyx_n_s__input_is_sorted,0};
     PyObject* values[2] = {0,0};
 
-    /* "dawg.pyx":32
+    /* "dawg.pyx":34
  *         self.dawg.Clear()
  * 
  *     def __init__(self, arg=None, input_is_sorted=False):             # <<<<<<<<<<<<<<
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("dawg.DAWG.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 32);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 34);
   __Pyx_INCREF(__pyx_v_arg);
 
-  /* "dawg.pyx":33
+  /* "dawg.pyx":35
  * 
  *     def __init__(self, arg=None, input_is_sorted=False):
  *         if arg is None:             # <<<<<<<<<<<<<<
   __pyx_t_1 = (__pyx_v_arg == Py_None);
   if (__pyx_t_1) {
 
-    /* "dawg.pyx":34
+    /* "dawg.pyx":36
  *     def __init__(self, arg=None, input_is_sorted=False):
  *         if arg is None:
  *             arg = []             # <<<<<<<<<<<<<<
  *         if not input_is_sorted:
  *             arg = sorted(arg)
  */
-    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_arg);
     __pyx_v_arg = ((PyObject *)__pyx_t_2);
   }
   __pyx_L3:;
 
-  /* "dawg.pyx":35
+  /* "dawg.pyx":37
  *         if arg is None:
  *             arg = []
  *         if not input_is_sorted:             # <<<<<<<<<<<<<<
  *             arg = sorted(arg)
  *         self._build_from_iterable(arg)
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_input_is_sorted); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_input_is_sorted); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_3 = (!__pyx_t_1);
   if (__pyx_t_3) {
 
-    /* "dawg.pyx":36
+    /* "dawg.pyx":38
  *             arg = []
  *         if not input_is_sorted:
  *             arg = sorted(arg)             # <<<<<<<<<<<<<<
  *         self._build_from_iterable(arg)
  * 
  */
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_arg);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_arg);
     __Pyx_GIVEREF(__pyx_v_arg);
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_v_arg);
   }
   __pyx_L4:;
 
-  /* "dawg.pyx":37
+  /* "dawg.pyx":39
  *         if not input_is_sorted:
  *             arg = sorted(arg)
  *         self._build_from_iterable(arg)             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_v_arg);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_arg);
   __Pyx_GIVEREF(__pyx_v_arg);
-  __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":40
+/* "dawg.pyx":42
  * 
  * 
  *     def _build_from_iterable(self, iterable):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_build_from_iterable", 0);
-  __Pyx_TraceCall("_build_from_iterable", __pyx_f[0], 40);
-
-  /* "dawg.pyx":44
+  __Pyx_TraceCall("_build_from_iterable", __pyx_f[0], 42);
+
+  /* "dawg.pyx":46
  * 
  *         cdef bytes b_key
  *         for key in iterable:             # <<<<<<<<<<<<<<
     __pyx_t_1 = __pyx_v_iterable; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
     __pyx_t_3 = NULL;
   } else {
-    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_iterable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_iterable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
   }
     if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
       if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
       if (unlikely(!__pyx_t_4)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
     __pyx_v_key = __pyx_t_4;
     __pyx_t_4 = 0;
 
-    /* "dawg.pyx":45
+    /* "dawg.pyx":47
  *         cdef bytes b_key
  *         for key in iterable:
  *             if isinstance(key, unicode):             # <<<<<<<<<<<<<<
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_5) {
 
-      /* "dawg.pyx":46
+      /* "dawg.pyx":48
  *         for key in iterable:
  *             if isinstance(key, unicode):
  *                 b_key = key.encode('utf8')             # <<<<<<<<<<<<<<
  *             else:
  *                 b_key = key
  */
-      __pyx_t_4 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_XDECREF(((PyObject *)__pyx_v_b_key));
       __pyx_v_b_key = ((PyObject*)__pyx_t_6);
       __pyx_t_6 = 0;
     }
     /*else*/ {
 
-      /* "dawg.pyx":48
+      /* "dawg.pyx":50
  *                 b_key = key.encode('utf8')
  *             else:
  *                 b_key = key             # <<<<<<<<<<<<<<
  *             dawg_builder.Insert(b_key)
  * 
  */
-      if (!(likely(PyBytes_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (!(likely(PyBytes_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_INCREF(__pyx_v_key);
       __Pyx_XDECREF(((PyObject *)__pyx_v_b_key));
       __pyx_v_b_key = ((PyObject*)__pyx_v_key);
     }
     __pyx_L5:;
 
-    /* "dawg.pyx":49
+    /* "dawg.pyx":51
  *             else:
  *                 b_key = key
  *             dawg_builder.Insert(b_key)             # <<<<<<<<<<<<<<
  * 
  *         dawg_builder.Finish(&self.dawg)
  */
-    __pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_b_key)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_b_key)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_dawg_builder.Insert(__pyx_t_7);
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "dawg.pyx":51
+  /* "dawg.pyx":53
  *             dawg_builder.Insert(b_key)
  * 
  *         dawg_builder.Finish(&self.dawg)             # <<<<<<<<<<<<<<
  */
   __pyx_v_dawg_builder.Finish((&__pyx_v_self->dawg));
 
-  /* "dawg.pyx":52
+  /* "dawg.pyx":54
  * 
  *         dawg_builder.Finish(&self.dawg)
  *         _dictionary_builder.Build(self.dawg, &(self.dct))             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "dawg.pyx":54
+/* "dawg.pyx":56
  *         _dictionary_builder.Build(self.dawg, &(self.dct))
  * 
  *     def __contains__(self, key):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__contains__", 0);
-  __Pyx_TraceCall("__contains__", __pyx_f[0], 54);
-
-  /* "dawg.pyx":55
+  __Pyx_TraceCall("__contains__", __pyx_f[0], 56);
+
+  /* "dawg.pyx":57
  * 
  *     def __contains__(self, key):
  *         if isinstance(key, unicode):             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "dawg.pyx":56
+    /* "dawg.pyx":58
  *     def __contains__(self, key):
  *         if isinstance(key, unicode):
  *             return self.has_key(key)             # <<<<<<<<<<<<<<
  *         return self.b_has_key(key)
  * 
  */
-    if (!(likely(PyUnicode_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (!(likely(PyUnicode_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected unicode, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_1 = __pyx_v_key;
     __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->has_key(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->has_key(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_r = __pyx_t_2;
     goto __pyx_L0;
   }
   __pyx_L3:;
 
-  /* "dawg.pyx":57
+  /* "dawg.pyx":59
  *         if isinstance(key, unicode):
  *             return self.has_key(key)
  *         return self.b_has_key(key)             # <<<<<<<<<<<<<<
  * 
  *     cpdef bint has_key(self, unicode key) except -1:
  */
-  if (!(likely(PyBytes_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(__pyx_v_key))||((__pyx_v_key) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_1 = __pyx_v_key;
   __Pyx_INCREF(__pyx_t_1);
-  __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_r = __pyx_t_2;
   goto __pyx_L0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":59
+/* "dawg.pyx":61
  *         return self.b_has_key(key)
  * 
  *     cpdef bint has_key(self, unicode key) except -1:             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("has_key", 0);
-  __Pyx_TraceCall("has_key", __pyx_f[0], 59);
+  __Pyx_TraceCall("has_key", __pyx_f[0], 61);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__has_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__has_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4dawg_4DAWG_9has_key)) {
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(((PyObject *)__pyx_v_key));
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key));
       __Pyx_GIVEREF(((PyObject *)__pyx_v_key));
-      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_r = __pyx_t_4;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "dawg.pyx":60
+  /* "dawg.pyx":62
  * 
  *     cpdef bint has_key(self, unicode key) except -1:
  *         cdef bytes b_key = key.encode('utf8')             # <<<<<<<<<<<<<<
  */
   if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
     PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "encode");
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_1 = ((PyObject *)PyUnicode_AsUTF8String(__pyx_v_key)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_1 = ((PyObject *)PyUnicode_AsUTF8String(__pyx_v_key)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (!(likely(PyBytes_CheckExact(((PyObject *)__pyx_t_1)))||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(((PyObject *)__pyx_t_1))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(((PyObject *)__pyx_t_1)))||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(((PyObject *)__pyx_t_1))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_b_key = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "dawg.pyx":61
+  /* "dawg.pyx":63
  *     cpdef bint has_key(self, unicode key) except -1:
  *         cdef bytes b_key = key.encode('utf8')
  *         return self.b_has_key(b_key)             # <<<<<<<<<<<<<<
  * 
  *     cpdef bint b_has_key(self, bytes key) except -1:
  */
-  __pyx_t_4 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, __pyx_v_b_key, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, __pyx_v_b_key, 0); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_t_4;
   goto __pyx_L0;
 
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("has_key (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_4dawg_4DAWG_8has_key(((struct __pyx_obj_4dawg_DAWG *)__pyx_v_self), ((PyObject*)__pyx_v_key));
   goto __pyx_L0;
   __pyx_L1_error:;
   return __pyx_r;
 }
 
-/* "dawg.pyx":59
+/* "dawg.pyx":61
  *         return self.b_has_key(key)
  * 
  *     cpdef bint has_key(self, unicode key) except -1:             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("has_key", 0);
-  __Pyx_TraceCall("has_key", __pyx_f[0], 59);
+  __Pyx_TraceCall("has_key", __pyx_f[0], 61);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->has_key(__pyx_v_self, __pyx_v_key, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->has_key(__pyx_v_self, __pyx_v_key, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":63
+/* "dawg.pyx":65
  *         return self.b_has_key(b_key)
  * 
  *     cpdef bint b_has_key(self, bytes key) except -1:             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("b_has_key", 0);
-  __Pyx_TraceCall("b_has_key", __pyx_f[0], 63);
+  __Pyx_TraceCall("b_has_key", __pyx_f[0], 65);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__b_has_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__b_has_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4dawg_4DAWG_11b_has_key)) {
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(((PyObject *)__pyx_v_key));
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_key));
       __Pyx_GIVEREF(((PyObject *)__pyx_v_key));
-      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_r = __pyx_t_4;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "dawg.pyx":64
+  /* "dawg.pyx":66
  * 
  *     cpdef bint b_has_key(self, bytes key) except -1:
  *         return self.dct.Contains(key)             # <<<<<<<<<<<<<<
  * 
  *     cpdef bytes tobytes(self):
  */
-  __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_v_self->dct.Contains(__pyx_t_5);
   goto __pyx_L0;
 
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("b_has_key (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_4dawg_4DAWG_10b_has_key(((struct __pyx_obj_4dawg_DAWG *)__pyx_v_self), ((PyObject*)__pyx_v_key));
   goto __pyx_L0;
   __pyx_L1_error:;
   return __pyx_r;
 }
 
-/* "dawg.pyx":63
+/* "dawg.pyx":65
  *         return self.b_has_key(b_key)
  * 
  *     cpdef bint b_has_key(self, bytes key) except -1:             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("b_has_key", 0);
-  __Pyx_TraceCall("b_has_key", __pyx_f[0], 63);
+  __Pyx_TraceCall("b_has_key", __pyx_f[0], 65);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, __pyx_v_key, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->b_has_key(__pyx_v_self, __pyx_v_key, 1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":66
+/* "dawg.pyx":68
  *         return self.dct.Contains(key)
  * 
  *     cpdef bytes tobytes(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("tobytes", 0);
-  __Pyx_TraceCall("tobytes", __pyx_f[0], 66);
+  __Pyx_TraceCall("tobytes", __pyx_f[0], 68);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tobytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tobytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4dawg_4DAWG_13tobytes)) {
       __Pyx_XDECREF(((PyObject *)__pyx_r));
-      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_r = ((PyObject*)__pyx_t_2);
       __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "dawg.pyx":71
+  /* "dawg.pyx":73
  *         """
  *         cdef stringstream stream
  *         self.dct.Write(<ostream *> &stream)             # <<<<<<<<<<<<<<
  *         cdef bytes res = stream.str()
  *         return res
  */
-  try {__pyx_t_3 = __pyx_v_self->dct.Write(((std::ostream *)(&__pyx_v_stream)));} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
-
-  /* "dawg.pyx":72
+  try {__pyx_t_3 = __pyx_v_self->dct.Write(((std::ostream *)(&__pyx_v_stream)));} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+
+  /* "dawg.pyx":74
  *         cdef stringstream stream
  *         self.dct.Write(<ostream *> &stream)
  *         cdef bytes res = stream.str()             # <<<<<<<<<<<<<<
  *         return res
  * 
  */
-  __pyx_t_1 = __pyx_convert_string_to_py_(__pyx_v_stream.str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_convert_string_to_py_(__pyx_v_stream.str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_v_res = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "dawg.pyx":73
+  /* "dawg.pyx":75
  *         self.dct.Write(<ostream *> &stream)
  *         cdef bytes res = stream.str()
  *         return res             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "dawg.pyx":66
+/* "dawg.pyx":68
  *         return self.dct.Contains(key)
  * 
  *     cpdef bytes tobytes(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("tobytes", 0);
-  __Pyx_TraceCall("tobytes", __pyx_f[0], 66);
+  __Pyx_TraceCall("tobytes", __pyx_f[0], 68);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":75
+/* "dawg.pyx":77
  *         return res
  * 
  *     cpdef frombytes(self, bytes data):             # <<<<<<<<<<<<<<
 
 static PyObject *__pyx_pw_4dawg_4DAWG_15frombytes(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
 static PyObject *__pyx_f_4dawg_4DAWG_frombytes(struct __pyx_obj_4dawg_DAWG *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) {
-  char *__pyx_v_c_data;
-  std::stringstream __pyx_v_stream;
+  std::string __pyx_v_s_data;
+  std::stringstream *__pyx_v_stream;
   int __pyx_v_res;
   PyObject *__pyx_r = NULL;
   __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   PyObject *__pyx_t_3 = NULL;
-  char *__pyx_t_4;
-  Py_ssize_t __pyx_t_5;
-  int __pyx_t_6;
+  std::string __pyx_t_4;
+  int __pyx_t_5;
   int __pyx_lineno = 0;
   const char *__pyx_filename = NULL;
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("frombytes", 0);
-  __Pyx_TraceCall("frombytes", __pyx_f[0], 75);
+  __Pyx_TraceCall("frombytes", __pyx_f[0], 77);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__frombytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__frombytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4dawg_4DAWG_15frombytes)) {
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(((PyObject *)__pyx_v_data));
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
       __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
-      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
       __pyx_r = __pyx_t_3;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "dawg.pyx":79
- *         Loads DAWG from bytes ``data``.
+  /* "dawg.pyx":85
+ *         using ``.load``).
  *         """
- *         cdef char* c_data = data             # <<<<<<<<<<<<<<
- *         cdef stringstream stream
- *         stream.write(c_data, len(data))
- */
-  __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_c_data = __pyx_t_4;
-
-  /* "dawg.pyx":81
- *         cdef char* c_data = data
- *         cdef stringstream stream
- *         stream.write(c_data, len(data))             # <<<<<<<<<<<<<<
- *         stream.seekg(0)
- * 
- */
-  if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_5 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_data)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_stream.write(__pyx_v_c_data, __pyx_t_5);
-
-  /* "dawg.pyx":82
- *         cdef stringstream stream
- *         stream.write(c_data, len(data))
- *         stream.seekg(0)             # <<<<<<<<<<<<<<
- * 
- *         res = self.dct.Read(<istream *> &stream)
- */
-  __pyx_v_stream.seekg(0);
-
-  /* "dawg.pyx":84
- *         stream.seekg(0)
- * 
- *         res = self.dct.Read(<istream *> &stream)             # <<<<<<<<<<<<<<
- *         if not res:
- *             self.dct.Clear()
- */
-  try {__pyx_t_6 = __pyx_v_self->dct.Read(((std::istream *)(&__pyx_v_stream)));} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
-  __pyx_v_res = __pyx_t_6;
-
-  /* "dawg.pyx":85
- * 
- *         res = self.dct.Read(<istream *> &stream)
- *         if not res:             # <<<<<<<<<<<<<<
- *             self.dct.Clear()
- *             raise IOError("Invalid data format")
- */
-  __pyx_t_6 = (!__pyx_v_res);
-  if (__pyx_t_6) {
-
-    /* "dawg.pyx":86
- *         res = self.dct.Read(<istream *> &stream)
- *         if not res:
- *             self.dct.Clear()             # <<<<<<<<<<<<<<
- *             raise IOError("Invalid data format")
- * 
- */
-    __pyx_v_self->dct.Clear();
-
-    /* "dawg.pyx":87
- *         if not res:
- *             self.dct.Clear()
- *             raise IOError("Invalid data format")             # <<<<<<<<<<<<<<
- * 
- *         return self
- */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *         cdef string s_data = data             # <<<<<<<<<<<<<<
+ *         cdef stringstream* stream = new stringstream(s_data)
+ * 
+ */
+  __pyx_t_4 = __pyx_convert_string_from_py_(((PyObject *)__pyx_v_data)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_s_data = __pyx_t_4;
+
+  /* "dawg.pyx":86
+ *         """
+ *         cdef string s_data = data
+ *         cdef stringstream* stream = new stringstream(s_data)             # <<<<<<<<<<<<<<
+ * 
+ *         try:
+ */
+  __pyx_v_stream = new std::stringstream(__pyx_v_s_data);
+
+  /* "dawg.pyx":88
+ *         cdef stringstream* stream = new stringstream(s_data)
+ * 
+ *         try:             # <<<<<<<<<<<<<<
+ *             res = self.dct.Read(<istream *> stream)
+ * 
+ */
+  /*try:*/ {
+
+    /* "dawg.pyx":89
+ * 
+ *         try:
+ *             res = self.dct.Read(<istream *> stream)             # <<<<<<<<<<<<<<
+ * 
+ *             if not res:
+ */
+    try {__pyx_t_5 = __pyx_v_self->dct.Read(((std::istream *)__pyx_v_stream));} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L4;}}
+    __pyx_v_res = __pyx_t_5;
+
+    /* "dawg.pyx":91
+ *             res = self.dct.Read(<istream *> stream)
+ * 
+ *             if not res:             # <<<<<<<<<<<<<<
+ *                 self.dct.Clear()
+ *                 raise IOError("Invalid data format")
+ */
+    __pyx_t_5 = (!__pyx_v_res);
+    if (__pyx_t_5) {
+
+      /* "dawg.pyx":92
+ * 
+ *             if not res:
+ *                 self.dct.Clear()             # <<<<<<<<<<<<<<
+ *                 raise IOError("Invalid data format")
+ * 
+ */
+      __pyx_v_self->dct.Clear();
+
+      /* "dawg.pyx":93
+ *             if not res:
+ *                 self.dct.Clear()
+ *                 raise IOError("Invalid data format")             # <<<<<<<<<<<<<<
+ * 
+ *             return self
+ */
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L4;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L4;}
+      goto __pyx_L6;
+    }
+    __pyx_L6:;
+
+    /* "dawg.pyx":95
+ *                 raise IOError("Invalid data format")
+ * 
+ *             return self             # <<<<<<<<<<<<<<
+ *         finally:
+ *             del stream
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(((PyObject *)__pyx_v_self));
+    __pyx_r = ((PyObject *)__pyx_v_self);
     goto __pyx_L3;
   }
-  __pyx_L3:;
-
-  /* "dawg.pyx":89
- *             raise IOError("Invalid data format")
- * 
- *         return self             # <<<<<<<<<<<<<<
+
+  /* "dawg.pyx":97
+ *             return self
+ *         finally:
+ *             del stream             # <<<<<<<<<<<<<<
  * 
  *     def read(self, f):
  */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(((PyObject *)__pyx_v_self));
-  __pyx_r = ((PyObject *)__pyx_v_self);
-  goto __pyx_L0;
+  /*finally:*/ {
+    int __pyx_why;
+    PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
+    int __pyx_exc_lineno;
+    __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
+    __pyx_why = 0; goto __pyx_L5;
+    __pyx_L3: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
+    __pyx_why = 3; goto __pyx_L5;
+    __pyx_L4: {
+      __pyx_why = 4;
+      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
+      __pyx_exc_lineno = __pyx_lineno;
+      goto __pyx_L5;
+    }
+    __pyx_L5:;
+    delete __pyx_v_stream;
+    switch (__pyx_why) {
+      case 3: goto __pyx_L0;
+      case 4: {
+        __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
+        __pyx_lineno = __pyx_exc_lineno;
+        __pyx_exc_type = 0;
+        __pyx_exc_value = 0;
+        __pyx_exc_tb = 0;
+        goto __pyx_L1_error;
+      }
+    }
+  }
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
 
 /* Python wrapper */
 static PyObject *__pyx_pw_4dawg_4DAWG_15frombytes(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
-static char __pyx_doc_4dawg_4DAWG_14frombytes[] = "\n        Loads DAWG from bytes ``data``.\n        ";
+static char __pyx_doc_4dawg_4DAWG_14frombytes[] = "\n        Loads DAWG from bytes ``data``.\n\n        FIXME: it seems there is a memory leak here (DAWG uses 3x memory\n        when loaded using ``.frombytes`` compared to DAWG loaded\n        using ``.load``).\n        ";
 static PyObject *__pyx_pw_4dawg_4DAWG_15frombytes(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("frombytes (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_4dawg_4DAWG_14frombytes(((struct __pyx_obj_4dawg_DAWG *)__pyx_v_self), ((PyObject*)__pyx_v_data));
   goto __pyx_L0;
   __pyx_L1_error:;
   return __pyx_r;
 }
 
-/* "dawg.pyx":75
+/* "dawg.pyx":77
  *         return res
  * 
  *     cpdef frombytes(self, bytes data):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("frombytes", 0);
-  __Pyx_TraceCall("frombytes", __pyx_f[0], 75);
+  __Pyx_TraceCall("frombytes", __pyx_f[0], 77);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, __pyx_v_data, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, __pyx_v_data, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":91
- *         return self
+/* "dawg.pyx":99
+ *             del stream
  * 
  *     def read(self, f):             # <<<<<<<<<<<<<<
  *         """
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("read", 0);
-  __Pyx_TraceCall("read", __pyx_f[0], 91);
-
-  /* "dawg.pyx":97
+  __Pyx_TraceCall("read", __pyx_f[0], 99);
+
+  /* "dawg.pyx":105
  *         FIXME: this method should'n read the whole stream.
  *         """
  *         self.frombytes(f.read())             # <<<<<<<<<<<<<<
  * 
  *     def write(self, f):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":99
+/* "dawg.pyx":107
  *         self.frombytes(f.read())
  * 
  *     def write(self, f):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write", 0);
-  __Pyx_TraceCall("write", __pyx_f[0], 99);
-
-  /* "dawg.pyx":103
+  __Pyx_TraceCall("write", __pyx_f[0], 107);
+
+  /* "dawg.pyx":111
  *         Writes DAWG to a file-like object.
  *         """
  *         f.write(self.tobytes())             # <<<<<<<<<<<<<<
  * 
  *     def load(self, path):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":105
+/* "dawg.pyx":113
  *         f.write(self.tobytes())
  * 
  *     def load(self, path):             # <<<<<<<<<<<<<<
  */
 
 static PyObject *__pyx_pf_4dawg_4DAWG_20load(struct __pyx_obj_4dawg_DAWG *__pyx_v_self, PyObject *__pyx_v_path) {
-  PyObject *__pyx_v_f = NULL;
+  std::ifstream __pyx_v_stream;
+  int __pyx_v_res;
   PyObject *__pyx_r = NULL;
   __Pyx_RefNannyDeclarations
   PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_2;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
-  PyObject *__pyx_t_5 = NULL;
-  PyObject *__pyx_t_6 = NULL;
-  PyObject *__pyx_t_7 = NULL;
-  PyObject *__pyx_t_8 = NULL;
-  int __pyx_t_9;
-  PyObject *__pyx_t_10 = NULL;
-  int __pyx_t_11;
+  char *__pyx_t_5;
   int __pyx_lineno = 0;
   const char *__pyx_filename = NULL;
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("load", 0);
-  __Pyx_TraceCall("load", __pyx_f[0], 105);
-
-  /* "dawg.pyx":109
+  __Pyx_TraceCall("load", __pyx_f[0], 113);
+  __Pyx_INCREF(__pyx_v_path);
+
+  /* "dawg.pyx":117
  *         Loads DAWG from a file.
  *         """
- *         with open(path, 'rb') as f:             # <<<<<<<<<<<<<<
- *             self.read(f)
- * 
- */
-  /*with:*/ {
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *         if isinstance(path, unicode):             # <<<<<<<<<<<<<<
+ *             path = path.encode(sys.getfilesystemencoding())
+ * 
+ */
+  __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_path, __pyx_t_1); 
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (__pyx_t_2) {
+
+    /* "dawg.pyx":118
+ *         """
+ *         if isinstance(path, unicode):
+ *             path = path.encode(sys.getfilesystemencoding())             # <<<<<<<<<<<<<<
+ * 
+ *         cdef ifstream stream
+ */
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_path, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(__pyx_v_path);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_path);
-    __Pyx_GIVEREF(__pyx_v_path);
-    __Pyx_INCREF(((PyObject *)__pyx_n_u__rb));
-    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_u__rb));
-    __Pyx_GIVEREF(((PyObject *)__pyx_n_u__rb));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    /*try:*/ {
-      {
-        __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
-        __Pyx_XGOTREF(__pyx_t_5);
-        __Pyx_XGOTREF(__pyx_t_6);
-        __Pyx_XGOTREF(__pyx_t_7);
-        /*try:*/ {
-          __Pyx_INCREF(__pyx_t_4);
-          __pyx_v_f = __pyx_t_4;
-          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
-          /* "dawg.pyx":110
- *         """
- *         with open(path, 'rb') as f:
- *             self.read(f)             # <<<<<<<<<<<<<<
- * 
- *     def save(self, path):
- */
-          __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-          __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-          __Pyx_GOTREF(__pyx_t_2);
-          __Pyx_INCREF(__pyx_v_f);
-          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f);
-          __Pyx_GIVEREF(__pyx_v_f);
-          __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-          __Pyx_GOTREF(__pyx_t_1);
-          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        }
-        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
-        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
-        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
-        goto __pyx_L14_try_end;
-        __pyx_L7_error:;
-        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-        /* "dawg.pyx":109
- *         Loads DAWG from a file.
- *         """
- *         with open(path, 'rb') as f:             # <<<<<<<<<<<<<<
- *             self.read(f)
- * 
- */
-        /*except:*/ {
-          __Pyx_AddTraceback("dawg.DAWG.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
-          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-          __Pyx_GOTREF(__pyx_t_1);
-          __Pyx_GOTREF(__pyx_t_2);
-          __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-          __Pyx_GOTREF(__pyx_t_8);
-          __Pyx_INCREF(__pyx_t_1);
-          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
-          __Pyx_GIVEREF(__pyx_t_1);
-          __Pyx_INCREF(__pyx_t_2);
-          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
-          __Pyx_GIVEREF(__pyx_t_2);
-          __Pyx_INCREF(__pyx_t_4);
-          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_4);
-          __Pyx_GIVEREF(__pyx_t_4);
-          __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL);
-          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-          if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-          __Pyx_GOTREF(__pyx_t_10);
-          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10);
-          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-          if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-          __pyx_t_11 = (!__pyx_t_9);
-          if (__pyx_t_11) {
-            __Pyx_GIVEREF(__pyx_t_1);
-            __Pyx_GIVEREF(__pyx_t_2);
-            __Pyx_GIVEREF(__pyx_t_4);
-            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_4);
-            __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0; 
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-            goto __pyx_L18;
-          }
-          __pyx_L18:;
-          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-          goto __pyx_L8_exception_handled;
-        }
-        __pyx_L9_except_error:;
-        __Pyx_XGIVEREF(__pyx_t_5);
-        __Pyx_XGIVEREF(__pyx_t_6);
-        __Pyx_XGIVEREF(__pyx_t_7);
-        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
-        goto __pyx_L1_error;
-        __pyx_L8_exception_handled:;
-        __Pyx_XGIVEREF(__pyx_t_5);
-        __Pyx_XGIVEREF(__pyx_t_6);
-        __Pyx_XGIVEREF(__pyx_t_7);
-        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
-        __pyx_L14_try_end:;
-      }
-    }
-    /*finally:*/ {
-      if (__pyx_t_3) {
-        __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_6, NULL);
-        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7);
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      }
-    }
-    goto __pyx_L19;
-    __pyx_L3_error:;
+    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_v_path);
+    __pyx_v_path = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "dawg.pyx":121
+ * 
+ *         cdef ifstream stream
+ *         stream.open(path, iostream.binary)             # <<<<<<<<<<<<<<
+ * 
+ *         res = self.dct.Read(<istream*> &stream)
+ */
+  __pyx_t_5 = PyBytes_AsString(__pyx_v_path); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  try {__pyx_v_stream.open(__pyx_t_5, std::stringstream::binary);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+
+  /* "dawg.pyx":123
+ *         stream.open(path, iostream.binary)
+ * 
+ *         res = self.dct.Read(<istream*> &stream)             # <<<<<<<<<<<<<<
+ * 
+ *         stream.close()
+ */
+  try {__pyx_t_2 = __pyx_v_self->dct.Read(((std::istream *)(&__pyx_v_stream)));} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+  __pyx_v_res = __pyx_t_2;
+
+  /* "dawg.pyx":125
+ *         res = self.dct.Read(<istream*> &stream)
+ * 
+ *         stream.close()             # <<<<<<<<<<<<<<
+ * 
+ *         if not res:
+ */
+  try {__pyx_v_stream.close();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+
+  /* "dawg.pyx":127
+ *         stream.close()
+ * 
+ *         if not res:             # <<<<<<<<<<<<<<
+ *             self.dct.Clear()
+ *             raise IOError("Invalid data format")
+ */
+  __pyx_t_2 = (!__pyx_v_res);
+  if (__pyx_t_2) {
+
+    /* "dawg.pyx":128
+ * 
+ *         if not res:
+ *             self.dct.Clear()             # <<<<<<<<<<<<<<
+ *             raise IOError("Invalid data format")
+ * 
+ */
+    __pyx_v_self->dct.Clear();
+
+    /* "dawg.pyx":129
+ *         if not res:
+ *             self.dct.Clear()
+ *             raise IOError("Invalid data format")             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    goto __pyx_L1_error;
-    __pyx_L19:;
-  }
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_XDECREF(__pyx_t_8);
   __Pyx_AddTraceback("dawg.DAWG.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_XDECREF(__pyx_v_f);
+  __Pyx_XDECREF(__pyx_v_path);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "dawg.pyx":112
- *             self.read(f)
+/* "dawg.pyx":133
+ * 
  * 
  *     def save(self, path):             # <<<<<<<<<<<<<<
  *         """
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("save", 0);
-  __Pyx_TraceCall("save", __pyx_f[0], 112);
-
-  /* "dawg.pyx":116
+  __Pyx_TraceCall("save", __pyx_f[0], 133);
+
+  /* "dawg.pyx":137
  *         Saves DAWG to a file.
  *         """
  *         with open(path, 'wb') as f:             # <<<<<<<<<<<<<<
  * 
  */
   /*with:*/ {
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_path);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_path);
     __Pyx_INCREF(((PyObject *)__pyx_n_u__wb));
     PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_u__wb));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_u__wb));
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
           __pyx_v_f = __pyx_t_4;
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-          /* "dawg.pyx":117
+          /* "dawg.pyx":138
  *         """
  *         with open(path, 'wb') as f:
  *             self.write(f)             # <<<<<<<<<<<<<<
  * 
  *     # pickling support
  */
-          __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+          __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_INCREF(__pyx_v_f);
           PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f);
           __Pyx_GIVEREF(__pyx_v_f);
-          __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+          __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-        /* "dawg.pyx":116
+        /* "dawg.pyx":137
  *         Saves DAWG to a file.
  *         """
  *         with open(path, 'wb') as f:             # <<<<<<<<<<<<<<
  */
         /*except:*/ {
           __Pyx_AddTraceback("dawg.DAWG.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
-          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_INCREF(__pyx_t_1);
           PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
           __Pyx_GIVEREF(__pyx_t_4);
           __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL);
           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-          if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+          if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
           __Pyx_GOTREF(__pyx_t_10);
           __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10);
           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-          if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+          if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
           __pyx_t_11 = (!__pyx_t_9);
           if (__pyx_t_11) {
             __Pyx_GIVEREF(__pyx_t_1);
             __Pyx_GIVEREF(__pyx_t_4);
             __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_4);
             __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0; 
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
             goto __pyx_L18;
           }
           __pyx_L18:;
     }
     /*finally:*/ {
       if (__pyx_t_3) {
-        __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_7, NULL);
+        __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_8, NULL);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
     }
     goto __pyx_L19;
   return __pyx_r;
 }
 
-/* "dawg.pyx":120
+/* "dawg.pyx":141
  * 
  *     # pickling support
  *     def __reduce__(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__reduce__", 0);
-  __Pyx_TraceCall("__reduce__", __pyx_f[0], 120);
-
-  /* "dawg.pyx":121
+  __Pyx_TraceCall("__reduce__", __pyx_f[0], 141);
+
+  /* "dawg.pyx":142
  *     # pickling support
  *     def __reduce__(self):
  *         return self.__class__, tuple(), self.tobytes()             # <<<<<<<<<<<<<<
  *     def __setstate__(self, state):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->tobytes(__pyx_v_self, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   return __pyx_r;
 }
 
-/* "dawg.pyx":123
+/* "dawg.pyx":144
  *         return self.__class__, tuple(), self.tobytes()
  * 
  *     def __setstate__(self, state):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__setstate__", 0);
-  __Pyx_TraceCall("__setstate__", __pyx_f[0], 123);
-
-  /* "dawg.pyx":124
+  __Pyx_TraceCall("__setstate__", __pyx_f[0], 144);
+
+  /* "dawg.pyx":145
  * 
  *     def __setstate__(self, state):
  *         self.frombytes(state)             # <<<<<<<<<<<<<<
  * 
  *     # half-internal methods
  */
-  if (!(likely(PyBytes_CheckExact(__pyx_v_state))||((__pyx_v_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_state)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(__pyx_v_state))||((__pyx_v_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_state)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_1 = __pyx_v_state;
   __Pyx_INCREF(__pyx_t_1);
-  __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((struct __pyx_vtabstruct_4dawg_DAWG *)__pyx_v_self->__pyx_vtab)->frombytes(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":127
+/* "dawg.pyx":148
  * 
  *     # half-internal methods
  *     def _size(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_size", 0);
-  __Pyx_TraceCall("_size", __pyx_f[0], 127);
-
-  /* "dawg.pyx":128
+  __Pyx_TraceCall("_size", __pyx_f[0], 148);
+
+  /* "dawg.pyx":149
  *     # half-internal methods
  *     def _size(self):
  *         return self.dct.size()             # <<<<<<<<<<<<<<
  *     def _total_size(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":130
+/* "dawg.pyx":151
  *         return self.dct.size()
  * 
  *     def _total_size(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_total_size", 0);
-  __Pyx_TraceCall("_total_size", __pyx_f[0], 130);
-
-  /* "dawg.pyx":131
+  __Pyx_TraceCall("_total_size", __pyx_f[0], 151);
+
+  /* "dawg.pyx":152
  * 
  *     def _total_size(self):
  *         return self.dct.total_size()             # <<<<<<<<<<<<<<
  *     def _file_size(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.total_size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.total_size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   return __pyx_r;
 }
 
-/* "dawg.pyx":133
+/* "dawg.pyx":154
  *         return self.dct.total_size()
  * 
  *     def _file_size(self):             # <<<<<<<<<<<<<<
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_file_size", 0);
-  __Pyx_TraceCall("_file_size", __pyx_f[0], 133);
-
-  /* "dawg.pyx":134
+  __Pyx_TraceCall("_file_size", __pyx_f[0], 154);
+
+  /* "dawg.pyx":155
  * 
  *     def _file_size(self):
  *         return self.dct.file_size()             # <<<<<<<<<<<<<<
  * 
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.file_size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_dawgdic__SizeType(__pyx_v_self->dct.file_size()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__arg,&__pyx_n_s__input_is_sorted,0};
     PyObject* values[2] = {0,0};
 
-    /* "dawg.pyx":144
+    /* "dawg.pyx":165
  *     cdef Completer* completer