/* Generated by Cython 0.17.1 on Mon Nov 26 20:17:06 2012 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define PyIndex_Check(o)     (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__plyvel___plyvel
#define __PYX_HAVE_API__plyvel___plyvel
#include "stdint.h"
#include "stdlib.h"
#include "string.h"
#include <string>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include "leveldb/db.h"
#include "leveldb/status.h"
#include "leveldb/options.h"
#include "leveldb/slice.h"
#include "leveldb/write_batch.h"
#include "leveldb/iterator.h"
#include "leveldb/comparator.h"
#include "leveldb/filter_policy.h"
#include "leveldb/cache.h"
#include "comparator.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))

#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "_plyvel.pyx",
  "stringsource",
  "stringsource",
};

/*--- Type declarations ---*/
struct __pyx_obj_6plyvel_7_plyvel_DB;
struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB;
struct __pyx_obj_6plyvel_7_plyvel_Iterator;
struct __pyx_obj_6plyvel_7_plyvel_WriteBatch;
struct __pyx_obj_6plyvel_7_plyvel_Snapshot;

/* "plyvel/_plyvel.pyx":588
 * #
 * 
 * cdef enum IteratorState:             # <<<<<<<<<<<<<<
 *     BEFORE_START
 *     AFTER_STOP
 */
enum __pyx_t_6plyvel_7_plyvel_IteratorState {
  __pyx_e_6plyvel_7_plyvel_BEFORE_START,
  __pyx_e_6plyvel_7_plyvel_AFTER_STOP,
  __pyx_e_6plyvel_7_plyvel_IN_BETWEEN,
  __pyx_e_6plyvel_7_plyvel_IN_BETWEEN_ALREADY_POSITIONED
};

/* "plyvel/_plyvel.pyx":595
 * 
 * 
 * cdef enum IteratorDirection:             # <<<<<<<<<<<<<<
 *     FORWARD
 *     REVERSE
 */
enum __pyx_t_6plyvel_7_plyvel_IteratorDirection {
  __pyx_e_6plyvel_7_plyvel_FORWARD,
  __pyx_e_6plyvel_7_plyvel_REVERSE
};

/* "plyvel/_plyvel.pyx":205
 * 
 * @cython.final
 * cdef class DB:             # <<<<<<<<<<<<<<
 *     cdef leveldb.DB* _db
 *     cdef Options options
 */
struct __pyx_obj_6plyvel_7_plyvel_DB {
  PyObject_HEAD
  struct __pyx_vtabstruct_6plyvel_7_plyvel_DB *__pyx_vtab;
  leveldb::DB *_db;
  leveldb::Options options;
  PyObject *lock;
  PyObject *iterators;
};


/* "plyvel/_plyvel.pyx":421
 * 
 * 
 * cdef class PrefixedDB:             # <<<<<<<<<<<<<<
 *     cdef readonly DB db
 *     cdef readonly bytes prefix
 */
struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB {
  PyObject_HEAD
  struct __pyx_obj_6plyvel_7_plyvel_DB *db;
  PyObject *prefix;
};


/* "plyvel/_plyvel.pyx":601
 * 
 * @cython.final
 * cdef class Iterator:             # <<<<<<<<<<<<<<
 *     cdef DB db
 *     cdef leveldb.Iterator* _iter
 */
struct __pyx_obj_6plyvel_7_plyvel_Iterator {
  PyObject_HEAD
  struct __pyx_vtabstruct_6plyvel_7_plyvel_Iterator *__pyx_vtab;
  struct __pyx_obj_6plyvel_7_plyvel_DB *db;
  leveldb::Iterator *_iter;
  enum __pyx_t_6plyvel_7_plyvel_IteratorDirection direction;
  enum __pyx_t_6plyvel_7_plyvel_IteratorState state;
  leveldb::Comparator *comparator;
  PyObject *start;
  PyObject *stop;
  leveldb::Slice start_slice;
  leveldb::Slice stop_slice;
  bool include_start;
  bool include_stop;
  bool include_key;
  bool include_value;
  int skip_key_bytes;
  PyObject *__weakref__;
};


/* "plyvel/_plyvel.pyx":504
 * 
 * @cython.final
 * cdef class WriteBatch:             # <<<<<<<<<<<<<<
 *     cdef leveldb.WriteBatch* _write_batch
 *     cdef WriteOptions write_options
 */
struct __pyx_obj_6plyvel_7_plyvel_WriteBatch {
  PyObject_HEAD
  leveldb::WriteBatch *_write_batch;
  leveldb::WriteOptions write_options;
  struct __pyx_obj_6plyvel_7_plyvel_DB *db;
  PyObject *prefix;
  bool transaction;
};


/* "plyvel/_plyvel.pyx":919
 * 
 * @cython.final
 * cdef class Snapshot:             # <<<<<<<<<<<<<<
 *     cdef leveldb.Snapshot* _snapshot
 *     cdef DB db
 */
struct __pyx_obj_6plyvel_7_plyvel_Snapshot {
  PyObject_HEAD
  leveldb::Snapshot *_snapshot;
  struct __pyx_obj_6plyvel_7_plyvel_DB *db;
  PyObject *prefix;
};



/* "plyvel/_plyvel.pyx":205
 * 
 * @cython.final
 * cdef class DB:             # <<<<<<<<<<<<<<
 *     cdef leveldb.DB* _db
 *     cdef Options options
 */

struct __pyx_vtabstruct_6plyvel_7_plyvel_DB {
  PyObject *(*close)(struct __pyx_obj_6plyvel_7_plyvel_DB *, int __pyx_skip_dispatch);
  PyObject *(*_register_iterator)(struct __pyx_obj_6plyvel_7_plyvel_DB *, struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
};
static struct __pyx_vtabstruct_6plyvel_7_plyvel_DB *__pyx_vtabptr_6plyvel_7_plyvel_DB;
static PyObject *__pyx_f_6plyvel_7_plyvel_2DB_close(struct __pyx_obj_6plyvel_7_plyvel_DB *, int __pyx_skip_dispatch);
static PyObject *__pyx_f_6plyvel_7_plyvel_2DB__register_iterator(struct __pyx_obj_6plyvel_7_plyvel_DB *, struct __pyx_obj_6plyvel_7_plyvel_Iterator *);


/* "plyvel/_plyvel.pyx":601
 * 
 * @cython.final
 * cdef class Iterator:             # <<<<<<<<<<<<<<
 *     cdef DB db
 *     cdef leveldb.Iterator* _iter
 */

struct __pyx_vtabstruct_6plyvel_7_plyvel_Iterator {
  PyObject *(*close)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
  PyObject *(*current)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
  PyObject *(*real_next)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
  PyObject *(*real_prev)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
};
static struct __pyx_vtabstruct_6plyvel_7_plyvel_Iterator *__pyx_vtabptr_6plyvel_7_plyvel_Iterator;
static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_close(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_current(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_real_next(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_real_prev(struct __pyx_obj_6plyvel_7_plyvel_Iterator *);
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
        PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
        PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {  /* inlined PySequence_GetItem() */
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (unlikely(l < 0)) return NULL;
                i += l;
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {  /* inlined PySequence_SetItem() */
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (unlikely(l < 0)) return -1;
                i += l;
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (PySequence_Check(o) && !PyDict_Check(o)) {
#else
    if (PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#define __Pyx_PyCallable_Check(obj)   ((obj)->ob_type->tp_call != NULL)
#else
#define __Pyx_PyCallable_Check(obj)   PyCallable_Check(obj)
#endif

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

static CYTHON_INLINE void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#include <new>

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_check_binary_version(void);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/


/* Module declarations from 'cython' */

/* Module declarations from 'libc.stdint' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libcpp.string' */

/* Module declarations from 'libcpp' */

/* Module declarations from 'plyvel.leveldb' */

/* Module declarations from 'plyvel.comparator' */

/* Module declarations from 'plyvel._plyvel' */
static PyTypeObject *__pyx_ptype_6plyvel_7_plyvel_DB = 0;
static PyTypeObject *__pyx_ptype_6plyvel_7_plyvel_PrefixedDB = 0;
static PyTypeObject *__pyx_ptype_6plyvel_7_plyvel_WriteBatch = 0;
static PyTypeObject *__pyx_ptype_6plyvel_7_plyvel_Iterator = 0;
static PyTypeObject *__pyx_ptype_6plyvel_7_plyvel_Snapshot = 0;
static int __pyx_f_6plyvel_7_plyvel_raise_for_status(leveldb::Status); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_6plyvel_7_plyvel_db_get(struct __pyx_obj_6plyvel_7_plyvel_DB *, PyObject *, leveldb::ReadOptions); /*proto*/
static PyObject *__pyx_f_6plyvel_7_plyvel_to_file_system_name(PyObject *); /*proto*/
static PyObject *__pyx_f_6plyvel_7_plyvel_bytes_increment(PyObject *); /*proto*/
static int __pyx_f_6plyvel_7_plyvel_parse_options(leveldb::Options *, bool, bool, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *, PyObject *); /*proto*/
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 "plyvel._plyvel"
int __pyx_module_is_main_plyvel___plyvel = 0;

/* Implementation of 'plyvel._plyvel' */
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_UnicodeEncodeError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_bytearray;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_StopIteration;
static int __pyx_pf_6plyvel_7_plyvel_2DB___init__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_name, bool __pyx_v_create_if_missing, bool __pyx_v_error_if_exists, PyObject *__pyx_v_paranoid_checks, PyObject *__pyx_v_write_buffer_size, PyObject *__pyx_v_max_open_files, PyObject *__pyx_v_lru_cache_size, PyObject *__pyx_v_block_size, PyObject *__pyx_v_block_restart_interval, PyObject *__pyx_v_compression, int __pyx_v_bloom_filter_bits, PyObject *__pyx_v_comparator, PyObject *__pyx_v_comparator_name); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_2close(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_6closed___get__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self); /* proto */
static void __pyx_pf_6plyvel_7_plyvel_2DB_4__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_6get(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_8put(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_10delete(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_12write_batch(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_transaction, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_14__iter__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_16iterator(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_18snapshot(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_20get_property(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_22compact_range(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_stop); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_24approximate_size(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_stop); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_26approximate_sizes(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_ranges); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_28prefixed_db(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */
static int __pyx_pf_6plyvel_7_plyvel_10PrefixedDB___init__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_db, PyObject *__pyx_v_prefix); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2get(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_4put(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6delete(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_8write_batch(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_transaction, PyObject *__pyx_v_sync); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_10__iter__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_12iterator(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_14snapshot(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_16prefixed_db(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_prefix); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2db___get__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6prefix___get__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_repair_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_paranoid_checks, PyObject *__pyx_v_write_buffer_size, PyObject *__pyx_v_max_open_files, PyObject *__pyx_v_lru_cache_size, PyObject *__pyx_v_block_size, PyObject *__pyx_v_block_restart_interval, PyObject *__pyx_v_compression, int __pyx_v_bloom_filter_bits, PyObject *__pyx_v_comparator, PyObject *__pyx_v_comparator_name); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_2destroy_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name); /* proto */
static int __pyx_pf_6plyvel_7_plyvel_10WriteBatch___init__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_prefix, bool __pyx_v_transaction, PyObject *__pyx_v_sync); /* proto */
static void __pyx_pf_6plyvel_7_plyvel_10WriteBatch_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_4put(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_6delete(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_8clear(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_10write(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_12__enter__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_14__exit__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_val, CYTHON_UNUSED PyObject *__pyx_v_exc_tb); /* proto */
static int __pyx_pf_6plyvel_7_plyvel_8Iterator___init__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_key_prefix, bool __pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, bool __pyx_v_include_start, bool __pyx_v_include_stop, PyObject *__pyx_v_prefix, bool __pyx_v_include_key, bool __pyx_v_include_value, bool __pyx_v_verify_checksums, bool __pyx_v_fill_cache, struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_snapshot); /* proto */
static void __pyx_pf_6plyvel_7_plyvel_8Iterator_2__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_4__iter__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_6__next__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_8prev(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_10seek_to_start(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_12seek_to_stop(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_14seek(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self, PyObject *__pyx_v_target); /* proto */
static int __pyx_pf_6plyvel_7_plyvel_8Snapshot___init__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_prefix); /* proto */
static void __pyx_pf_6plyvel_7_plyvel_8Snapshot_2__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_4get(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_6__iter__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_8iterator(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache); /* proto */
static char __pyx_k_1[] = "'name' arg must be a byte string or a unicode string";
static char __pyx_k_3[] = "getfilesystemencoding";
static char __pyx_k_4[] = "Cannot convert unicode 'name' to a file system name: %s";
static char __pyx_k_5[] = "UTF-8";
static char __pyx_k_7[] = "'compression' must be None or a string";
static char __pyx_k_9[] = "'compression' must be None or 'snappy'";
static char __pyx_k_11[] = "'comparator' and 'comparator_name' must be specified together";
static char __pyx_k_13[] = "custom comparator object must be callable";
static char __pyx_k_15[] = "block_restart_interval";
static char __pyx_k_17[] = "Cannot operate on closed LevelDB database";
static char __pyx_k_33[] = "Start and stop of range must be byte strings";
static char __pyx_k_48[] = "'prefix' cannot be used together with 'start' or 'stop'";
static char __pyx_k_63[] = "db: plyvel._plyvel.DB";
static char __pyx_k_64[] = "prefix: bytes";
static char __pyx_k_65[] = "\nPlyvel, a Python LevelDB interface.\n\nUse plyvel.DB() to create or open a database.\n";
static char __pyx_k_66[] = "%d.%d";
static char __pyx_k_67[] = "plyvel._plyvel";
static char __pyx_k_70[] = "/home/uws/Projects/LevelDB/plyvel/plyvel/_plyvel.pyx";
static char __pyx_k__db[] = "db";
static char __pyx_k__id[] = "id";
static char __pyx_k__st[] = "st";
static char __pyx_k__get[] = "get";
static char __pyx_k__key[] = "key";
static char __pyx_k__put[] = "put";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__Lock[] = "Lock";
static char __pyx_k__name[] = "name";
static char __pyx_k__stop[] = "stop";
static char __pyx_k__sync[] = "sync";
static char __pyx_k__Error[] = "Error";
static char __pyx_k__ascii[] = "ascii";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__range[] = "range";
static char __pyx_k__start[] = "start";
static char __pyx_k__value[] = "value";
static char __pyx_k__write[] = "write";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__delete[] = "delete";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__exc_tb[] = "exc_tb";
static char __pyx_k__fsname[] = "fsname";
static char __pyx_k__prefix[] = "prefix";
static char __pyx_k__snappy[] = "snappy";
static char __pyx_k__values[] = "values";
static char __pyx_k__xrange[] = "xrange";
static char __pyx_k__IOError[] = "IOError";
static char __pyx_k__exc_val[] = "exc_val";
static char __pyx_k__options[] = "options";
static char __pyx_k__reverse[] = "reverse";
static char __pyx_k__weakref[] = "weakref";
static char __pyx_k____exit__[] = "__exit__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__exc_type[] = "exc_type";
static char __pyx_k__iterator[] = "iterator";
static char __pyx_k__snapshot[] = "snapshot";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____enter__[] = "__enter__";
static char __pyx_k__bytearray[] = "bytearray";
static char __pyx_k__repair_db[] = "repair_db";
static char __pyx_k__threading[] = "threading";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__block_size[] = "block_size";
static char __pyx_k__comparator[] = "comparator";
static char __pyx_k__destroy_db[] = "destroy_db";
static char __pyx_k__fill_cache[] = "fill_cache";
static char __pyx_k__itervalues[] = "itervalues";
static char __pyx_k__key_prefix[] = "key_prefix";
static char __pyx_k__compression[] = "compression";
static char __pyx_k__include_key[] = "include_key";
static char __pyx_k__transaction[] = "transaction";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__include_stop[] = "include_stop";
static char __pyx_k__seek_to_stop[] = "seek_to_stop";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k__include_start[] = "include_start";
static char __pyx_k__include_value[] = "include_value";
static char __pyx_k__seek_to_start[] = "seek_to_start";
static char __pyx_k__AttributeError[] = "AttributeError";
static char __pyx_k__lru_cache_size[] = "lru_cache_size";
static char __pyx_k__max_open_files[] = "max_open_files";
static char __pyx_k__CorruptionError[] = "CorruptionError";
static char __pyx_k__comparator_name[] = "comparator_name";
static char __pyx_k__error_if_exists[] = "error_if_exists";
static char __pyx_k__paranoid_checks[] = "paranoid_checks";
static char __pyx_k__verify_checksums[] = "verify_checksums";
static char __pyx_k__approximate_sizes[] = "approximate_sizes";
static char __pyx_k__bloom_filter_bits[] = "bloom_filter_bits";
static char __pyx_k__create_if_missing[] = "create_if_missing";
static char __pyx_k__write_buffer_size[] = "write_buffer_size";
static char __pyx_k__UnicodeEncodeError[] = "UnicodeEncodeError";
static char __pyx_k__WeakValueDictionary[] = "WeakValueDictionary";
static char __pyx_k____leveldb_version__[] = "__leveldb_version__";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_n_s_15;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_n_s_3;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_48;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_66;
static PyObject *__pyx_n_s_67;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_70;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__AttributeError;
static PyObject *__pyx_n_s__CorruptionError;
static PyObject *__pyx_n_s__Error;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__IOError;
static PyObject *__pyx_n_s__Lock;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__UnicodeEncodeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s__WeakValueDictionary;
static PyObject *__pyx_n_s____enter__;
static PyObject *__pyx_n_s____exit__;
static PyObject *__pyx_n_s____leveldb_version__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__approximate_sizes;
static PyObject *__pyx_n_s__ascii;
static PyObject *__pyx_n_s__block_size;
static PyObject *__pyx_n_s__bloom_filter_bits;
static PyObject *__pyx_n_s__bytearray;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__comparator;
static PyObject *__pyx_n_s__comparator_name;
static PyObject *__pyx_n_s__compression;
static PyObject *__pyx_n_s__create_if_missing;
static PyObject *__pyx_n_s__db;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__delete;
static PyObject *__pyx_n_s__destroy_db;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__error_if_exists;
static PyObject *__pyx_n_s__exc_tb;
static PyObject *__pyx_n_s__exc_type;
static PyObject *__pyx_n_s__exc_val;
static PyObject *__pyx_n_s__fill_cache;
static PyObject *__pyx_n_s__fsname;
static PyObject *__pyx_n_s__get;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__include_key;
static PyObject *__pyx_n_s__include_start;
static PyObject *__pyx_n_s__include_stop;
static PyObject *__pyx_n_s__include_value;
static PyObject *__pyx_n_s__iterator;
static PyObject *__pyx_n_s__itervalues;
static PyObject *__pyx_n_s__key;
static PyObject *__pyx_n_s__key_prefix;
static PyObject *__pyx_n_s__lru_cache_size;
static PyObject *__pyx_n_s__max_open_files;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__options;
static PyObject *__pyx_n_s__paranoid_checks;
static PyObject *__pyx_n_s__prefix;
static PyObject *__pyx_n_s__put;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__repair_db;
static PyObject *__pyx_n_s__reverse;
static PyObject *__pyx_n_s__seek_to_start;
static PyObject *__pyx_n_s__seek_to_stop;
static PyObject *__pyx_n_s__snappy;
static PyObject *__pyx_n_u__snappy;
static PyObject *__pyx_n_s__snapshot;
static PyObject *__pyx_n_s__st;
static PyObject *__pyx_n_s__start;
static PyObject *__pyx_n_s__stop;
static PyObject *__pyx_n_s__sync;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__threading;
static PyObject *__pyx_n_s__transaction;
static PyObject *__pyx_n_s__value;
static PyObject *__pyx_n_s__values;
static PyObject *__pyx_n_s__verify_checksums;
static PyObject *__pyx_n_s__weakref;
static PyObject *__pyx_n_s__write;
static PyObject *__pyx_n_s__write_buffer_size;
static PyObject *__pyx_n_s__xrange;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_255;
static PyObject *__pyx_k_21;
static PyObject *__pyx_k_24;
static PyObject *__pyx_k_25;
static PyObject *__pyx_k_26;
static PyObject *__pyx_k_27;
static PyObject *__pyx_k_28;
static PyObject *__pyx_k_35;
static PyObject *__pyx_k_36;
static PyObject *__pyx_k_37;
static PyObject *__pyx_k_38;
static PyObject *__pyx_k_39;
static PyObject *__pyx_k_40;
static PyObject *__pyx_k_58;
static PyObject *__pyx_k_59;
static PyObject *__pyx_k_60;
static PyObject *__pyx_k_61;
static PyObject *__pyx_k_62;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_8;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_12;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_18;
static PyObject *__pyx_k_tuple_19;
static PyObject *__pyx_k_tuple_20;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_29;
static PyObject *__pyx_k_tuple_30;
static PyObject *__pyx_k_tuple_31;
static PyObject *__pyx_k_tuple_32;
static PyObject *__pyx_k_tuple_34;
static PyObject *__pyx_k_tuple_41;
static PyObject *__pyx_k_tuple_42;
static PyObject *__pyx_k_tuple_43;
static PyObject *__pyx_k_tuple_44;
static PyObject *__pyx_k_tuple_45;
static PyObject *__pyx_k_tuple_46;
static PyObject *__pyx_k_tuple_47;
static PyObject *__pyx_k_tuple_49;
static PyObject *__pyx_k_tuple_50;
static PyObject *__pyx_k_tuple_51;
static PyObject *__pyx_k_tuple_52;
static PyObject *__pyx_k_tuple_53;
static PyObject *__pyx_k_tuple_54;
static PyObject *__pyx_k_tuple_55;
static PyObject *__pyx_k_tuple_56;
static PyObject *__pyx_k_tuple_57;
static PyObject *__pyx_k_tuple_68;
static PyObject *__pyx_k_tuple_71;
static PyObject *__pyx_k_codeobj_69;
static PyObject *__pyx_k_codeobj_72;

/* "plyvel/_plyvel.pyx":70
 * 
 * 
 * cdef int raise_for_status(Status st) except -1:             # <<<<<<<<<<<<<<
 *     if st.ok():
 *         return 0
 */

static int __pyx_f_6plyvel_7_plyvel_raise_for_status(leveldb::Status __pyx_v_st) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  bool __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("raise_for_status", 0);

  /* "plyvel/_plyvel.pyx":71
 * 
 * cdef int raise_for_status(Status st) except -1:
 *     if st.ok():             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
  __pyx_t_1 = __pyx_v_st.ok();
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":72
 * cdef int raise_for_status(Status st) except -1:
 *     if st.ok():
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     if st.IsIOError():
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":74
 *         return 0
 * 
 *     if st.IsIOError():             # <<<<<<<<<<<<<<
 *         raise IOError(st.ToString())
 * 
 */
  __pyx_t_1 = __pyx_v_st.IsIOError();
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":75
 * 
 *     if st.IsIOError():
 *         raise IOError(st.ToString())             # <<<<<<<<<<<<<<
 * 
 *     if st.IsCorruption():
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__IOError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_convert_string_to_py_(__pyx_v_st.ToString()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":77
 *         raise IOError(st.ToString())
 * 
 *     if st.IsCorruption():             # <<<<<<<<<<<<<<
 *         raise CorruptionError(st.ToString())
 * 
 */
  __pyx_t_1 = __pyx_v_st.IsCorruption();
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":78
 * 
 *     if st.IsCorruption():
 *         raise CorruptionError(st.ToString())             # <<<<<<<<<<<<<<
 * 
 *     # Generic fallback
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__CorruptionError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __pyx_convert_string_to_py_(__pyx_v_st.ToString()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":81
 * 
 *     # Generic fallback
 *     raise Error(st.ToString())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __pyx_convert_string_to_py_(__pyx_v_st.ToString()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plyvel._plyvel.raise_for_status", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":88
 * #
 * 
 * cdef inline db_get(DB db, bytes key, ReadOptions read_options):             # <<<<<<<<<<<<<<
 *     cdef string value
 *     cdef Status st
 */

static CYTHON_INLINE PyObject *__pyx_f_6plyvel_7_plyvel_db_get(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_key, leveldb::ReadOptions __pyx_v_read_options) {
  std::string __pyx_v_value;
  leveldb::Status __pyx_v_st;
  leveldb::Slice __pyx_v_key_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  const char *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  bool __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("db_get", 0);

  /* "plyvel/_plyvel.pyx":91
 *     cdef string value
 *     cdef Status st
 *     cdef Slice key_slice = Slice(key, len(key))             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key_slice = leveldb::Slice(__pyx_t_1, __pyx_t_2);

  /* "plyvel/_plyvel.pyx":93
 *     cdef Slice key_slice = Slice(key, len(key))
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = db._db.Get(read_options, key_slice, &value)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":94
 * 
 *     with nogil:
 *         st = db._db.Get(read_options, key_slice, &value)             # <<<<<<<<<<<<<<
 * 
 *     if st.IsNotFound():
 */
        __pyx_v_st = __pyx_v_db->_db->Get(__pyx_v_read_options, __pyx_v_key_slice, (&__pyx_v_value));
      }

      /* "plyvel/_plyvel.pyx":93
 *     cdef Slice key_slice = Slice(key, len(key))
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = db._db.Get(read_options, key_slice, &value)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":96
 *         st = db._db.Get(read_options, key_slice, &value)
 * 
 *     if st.IsNotFound():             # <<<<<<<<<<<<<<
 *         return None
 *     raise_for_status(st)
 */
  __pyx_t_3 = __pyx_v_st.IsNotFound();
  if (__pyx_t_3) {

    /* "plyvel/_plyvel.pyx":97
 * 
 *     if st.IsNotFound():
 *         return None             # <<<<<<<<<<<<<<
 *     raise_for_status(st)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "plyvel/_plyvel.pyx":98
 *     if st.IsNotFound():
 *         return None
 *     raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 *     return value
 */
  __pyx_t_4 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":100
 *     raise_for_status(st)
 * 
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_convert_string_to_py_(__pyx_v_value); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_r = ((PyObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plyvel._plyvel.db_get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":103
 * 
 * 
 * cdef bytes to_file_system_name(name):             # <<<<<<<<<<<<<<
 *     if isinstance(name, bytes):
 *         return name
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_to_file_system_name(PyObject *__pyx_v_name) {
  PyObject *__pyx_v_encoding = NULL;
  PyObject *__pyx_v_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  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;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("to_file_system_name", 0);

  /* "plyvel/_plyvel.pyx":104
 * 
 * cdef bytes to_file_system_name(name):
 *     if isinstance(name, bytes):             # <<<<<<<<<<<<<<
 *         return name
 * 
 */
  __pyx_t_1 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_name, __pyx_t_1); 
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "plyvel/_plyvel.pyx":105
 * cdef bytes to_file_system_name(name):
 *     if isinstance(name, bytes):
 *         return name             # <<<<<<<<<<<<<<
 * 
 *     if not isinstance(name, unicode):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(PyBytes_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_name)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_name);
    __pyx_r = ((PyObject*)__pyx_v_name);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":107
 *         return name
 * 
 *     if not isinstance(name, unicode):             # <<<<<<<<<<<<<<
 *         raise TypeError(
 *             "'name' arg must be a byte string or a unicode string")
 */
  __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_name, __pyx_t_1); 
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "plyvel/_plyvel.pyx":108
 * 
 *     if not isinstance(name, unicode):
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             "'name' arg must be a byte string or a unicode string")
 * 
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __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 = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":111
 *             "'name' arg must be a byte string or a unicode string")
 * 
 *     encoding = sys.getfilesystemencoding() or 'ascii'             # <<<<<<<<<<<<<<
 *     try:
 *         return name.encode(encoding)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); 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_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); 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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_3) {
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii));
    __pyx_t_4 = __pyx_n_s__ascii;
  } else {
    __pyx_t_4 = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_v_encoding = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "plyvel/_plyvel.pyx":112
 * 
 *     encoding = sys.getfilesystemencoding() or 'ascii'
 *     try:             # <<<<<<<<<<<<<<
 *         return name.encode(encoding)
 *     except UnicodeEncodeError as exc:
 */
  {
    __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:*/ {

      /* "plyvel/_plyvel.pyx":113
 *     encoding = sys.getfilesystemencoding() or 'ascii'
 *     try:
 *         return name.encode(encoding)             # <<<<<<<<<<<<<<
 *     except UnicodeEncodeError as exc:
 *         raise ValueError(
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_4 = PyObject_GetAttr(__pyx_v_name, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_encoding);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_encoding);
      __Pyx_GIVEREF(__pyx_v_encoding);
      __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      if (!(likely(PyBytes_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_8)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __pyx_r = ((PyObject*)__pyx_t_8);
      __pyx_t_8 = 0;
      goto __pyx_L9_try_return;
    }
    __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_L12_try_end;
    __pyx_L9_try_return:;
    __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_L0;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "plyvel/_plyvel.pyx":114
 *     try:
 *         return name.encode(encoding)
 *     except UnicodeEncodeError as exc:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "Cannot convert unicode 'name' to a file system name: %s" % exc)
 */
    __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("plyvel._plyvel.to_file_system_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_exc = __pyx_t_1;

      /* "plyvel/_plyvel.pyx":116
 *     except UnicodeEncodeError as exc:
 *         raise ValueError(
 *             "Cannot convert unicode 'name' to a file system name: %s" % exc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_exc); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_10));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
      __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_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_L6_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_L12_try_end:;
  }

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("plyvel._plyvel.to_file_system_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_encoding);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":119
 * 
 * 
 * cdef bytes bytes_increment(bytes s):             # <<<<<<<<<<<<<<
 *     # Increment the last byte that is not 0xff, and returned a new byte
 *     # string truncated after the position that was incremented. We use
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_bytes_increment(PyObject *__pyx_v_s) {
  PyObject *__pyx_v_b = NULL;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bytes_increment", 0);

  /* "plyvel/_plyvel.pyx":125
 *     # works the same in Python 2 and Python 3.
 * 
 *     b = bytearray(s)             # <<<<<<<<<<<<<<
 *     cdef int i = len(s) - 1
 *     while i >= 0:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_s));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_s));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_s));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_bytearray, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_b = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":126
 * 
 *     b = bytearray(s)
 *     cdef int i = len(s) - 1             # <<<<<<<<<<<<<<
 *     while i >= 0:
 *         if b[i] == 0xff:
 */
  if (unlikely(((PyObject *)__pyx_v_s) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_s)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_i = (__pyx_t_3 - 1);

  /* "plyvel/_plyvel.pyx":127
 *     b = bytearray(s)
 *     cdef int i = len(s) - 1
 *     while i >= 0:             # <<<<<<<<<<<<<<
 *         if b[i] == 0xff:
 *             i = i - 1
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_i >= 0);
    if (!__pyx_t_4) break;

    /* "plyvel/_plyvel.pyx":128
 *     cdef int i = len(s) - 1
 *     while i >= 0:
 *         if b[i] == 0xff:             # <<<<<<<<<<<<<<
 *             i = i - 1
 *             continue
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_255, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "plyvel/_plyvel.pyx":129
 *     while i >= 0:
 *         if b[i] == 0xff:
 *             i = i - 1             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
      __pyx_v_i = (__pyx_v_i - 1);

      /* "plyvel/_plyvel.pyx":130
 *         if b[i] == 0xff:
 *             i = i - 1
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         # Found byte smaller than 0xff: increment and truncate
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "plyvel/_plyvel.pyx":133
 * 
 *         # Found byte smaller than 0xff: increment and truncate
 *         b[i] += 1             # <<<<<<<<<<<<<<
 *         return bytes(b[:i + 1])
 * 
 */
    __pyx_t_5 = __pyx_v_i;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_b, __pyx_t_5, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_SetItemInt(__pyx_v_b, __pyx_t_5, __pyx_t_2, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "plyvel/_plyvel.pyx":134
 *         # Found byte smaller than 0xff: increment and truncate
 *         b[i] += 1
 *         return bytes(b[:i + 1])             # <<<<<<<<<<<<<<
 * 
 *     # Input contained only 0xff bytes
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_b, 0, (__pyx_v_i + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    __pyx_L3_continue:;
  }

  /* "plyvel/_plyvel.pyx":137
 * 
 *     # Input contained only 0xff bytes
 *     return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(Py_None);
  __pyx_r = ((PyObject*)Py_None);
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.bytes_increment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":140
 * 
 * 
 * cdef int parse_options(Options *options, bool create_if_missing,             # <<<<<<<<<<<<<<
 *                        bool error_if_exists, object paranoid_checks,
 *                        object write_buffer_size, object max_open_files,
 */

static int __pyx_f_6plyvel_7_plyvel_parse_options(leveldb::Options *__pyx_v_options, bool __pyx_v_create_if_missing, bool __pyx_v_error_if_exists, PyObject *__pyx_v_paranoid_checks, PyObject *__pyx_v_write_buffer_size, PyObject *__pyx_v_max_open_files, PyObject *__pyx_v_lru_cache_size, PyObject *__pyx_v_block_size, PyObject *__pyx_v_block_restart_interval, PyObject *__pyx_v_compression, int __pyx_v_bloom_filter_bits, PyObject *__pyx_v_comparator, PyObject *__pyx_v_comparator_name) {
  int __pyx_v_c_lru_cache_size;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bool __pyx_t_2;
  size_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  const char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("parse_options", 0);
  __Pyx_INCREF(__pyx_v_compression);

  /* "plyvel/_plyvel.pyx":149
 *     cdef int c_lru_cache_size
 * 
 *     options.create_if_missing = create_if_missing             # <<<<<<<<<<<<<<
 *     options.error_if_exists = error_if_exists
 * 
 */
  __pyx_v_options->create_if_missing = __pyx_v_create_if_missing;

  /* "plyvel/_plyvel.pyx":150
 * 
 *     options.create_if_missing = create_if_missing
 *     options.error_if_exists = error_if_exists             # <<<<<<<<<<<<<<
 * 
 *     if paranoid_checks is not None:
 */
  __pyx_v_options->error_if_exists = __pyx_v_error_if_exists;

  /* "plyvel/_plyvel.pyx":152
 *     options.error_if_exists = error_if_exists
 * 
 *     if paranoid_checks is not None:             # <<<<<<<<<<<<<<
 *         options.paranoid_checks = paranoid_checks
 * 
 */
  __pyx_t_1 = (__pyx_v_paranoid_checks != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":153
 * 
 *     if paranoid_checks is not None:
 *         options.paranoid_checks = paranoid_checks             # <<<<<<<<<<<<<<
 * 
 *     if write_buffer_size is not None:
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_paranoid_checks); if (unlikely((__pyx_t_2 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_options->paranoid_checks = __pyx_t_2;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":155
 *         options.paranoid_checks = paranoid_checks
 * 
 *     if write_buffer_size is not None:             # <<<<<<<<<<<<<<
 *         options.write_buffer_size = write_buffer_size
 * 
 */
  __pyx_t_1 = (__pyx_v_write_buffer_size != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":156
 * 
 *     if write_buffer_size is not None:
 *         options.write_buffer_size = write_buffer_size             # <<<<<<<<<<<<<<
 * 
 *     if max_open_files is not None:
 */
    __pyx_t_3 = __Pyx_PyInt_AsSize_t(__pyx_v_write_buffer_size); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_options->write_buffer_size = __pyx_t_3;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":158
 *         options.write_buffer_size = write_buffer_size
 * 
 *     if max_open_files is not None:             # <<<<<<<<<<<<<<
 *         options.max_open_files = max_open_files
 * 
 */
  __pyx_t_1 = (__pyx_v_max_open_files != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":159
 * 
 *     if max_open_files is not None:
 *         options.max_open_files = max_open_files             # <<<<<<<<<<<<<<
 * 
 *     if lru_cache_size is not None:
 */
    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_max_open_files); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_options->max_open_files = __pyx_t_4;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":161
 *         options.max_open_files = max_open_files
 * 
 *     if lru_cache_size is not None:             # <<<<<<<<<<<<<<
 *         c_lru_cache_size = lru_cache_size
 *         with nogil:
 */
  __pyx_t_1 = (__pyx_v_lru_cache_size != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":162
 * 
 *     if lru_cache_size is not None:
 *         c_lru_cache_size = lru_cache_size             # <<<<<<<<<<<<<<
 *         with nogil:
 *             options.block_cache = NewLRUCache(c_lru_cache_size)
 */
    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_lru_cache_size); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_c_lru_cache_size = __pyx_t_4;

    /* "plyvel/_plyvel.pyx":163
 *     if lru_cache_size is not None:
 *         c_lru_cache_size = lru_cache_size
 *         with nogil:             # <<<<<<<<<<<<<<
 *             options.block_cache = NewLRUCache(c_lru_cache_size)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "plyvel/_plyvel.pyx":164
 *         c_lru_cache_size = lru_cache_size
 *         with nogil:
 *             options.block_cache = NewLRUCache(c_lru_cache_size)             # <<<<<<<<<<<<<<
 * 
 *     if block_size is not None:
 */
          __pyx_v_options->block_cache = leveldb::NewLRUCache(__pyx_v_c_lru_cache_size);
        }

        /* "plyvel/_plyvel.pyx":163
 *     if lru_cache_size is not None:
 *         c_lru_cache_size = lru_cache_size
 *         with nogil:             # <<<<<<<<<<<<<<
 *             options.block_cache = NewLRUCache(c_lru_cache_size)
 * 
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "plyvel/_plyvel.pyx":166
 *             options.block_cache = NewLRUCache(c_lru_cache_size)
 * 
 *     if block_size is not None:             # <<<<<<<<<<<<<<
 *         options.block_size = block_size
 * 
 */
  __pyx_t_1 = (__pyx_v_block_size != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":167
 * 
 *     if block_size is not None:
 *         options.block_size = block_size             # <<<<<<<<<<<<<<
 * 
 *     if block_restart_interval is not None:
 */
    __pyx_t_3 = __Pyx_PyInt_AsSize_t(__pyx_v_block_size); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_options->block_size = __pyx_t_3;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "plyvel/_plyvel.pyx":169
 *         options.block_size = block_size
 * 
 *     if block_restart_interval is not None:             # <<<<<<<<<<<<<<
 *         options.block_restart_interval = block_restart_interval
 * 
 */
  __pyx_t_1 = (__pyx_v_block_restart_interval != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":170
 * 
 *     if block_restart_interval is not None:
 *         options.block_restart_interval = block_restart_interval             # <<<<<<<<<<<<<<
 * 
 *     if compression is None:
 */
    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_block_restart_interval); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_options->block_restart_interval = __pyx_t_4;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "plyvel/_plyvel.pyx":172
 *         options.block_restart_interval = block_restart_interval
 * 
 *     if compression is None:             # <<<<<<<<<<<<<<
 *         options.compression = leveldb.kNoCompression
 *     else:
 */
  __pyx_t_1 = (__pyx_v_compression == Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":173
 * 
 *     if compression is None:
 *         options.compression = leveldb.kNoCompression             # <<<<<<<<<<<<<<
 *     else:
 *         if isinstance(compression, bytes):
 */
    __pyx_v_options->compression = leveldb::kNoCompression;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":175
 *         options.compression = leveldb.kNoCompression
 *     else:
 *         if isinstance(compression, bytes):             # <<<<<<<<<<<<<<
 *             compression = compression.decode('UTF-8')
 *         if not isinstance(compression, unicode):
 */
    __pyx_t_5 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_compression, __pyx_t_5); 
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":176
 *     else:
 *         if isinstance(compression, bytes):
 *             compression = compression.decode('UTF-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(compression, unicode):
 *             raise TypeError("'compression' must be None or a string")
 */
      __pyx_t_5 = PyObject_GetAttr(__pyx_v_compression, __pyx_n_s__decode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_compression);
      __pyx_v_compression = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "plyvel/_plyvel.pyx":177
 *         if isinstance(compression, bytes):
 *             compression = compression.decode('UTF-8')
 *         if not isinstance(compression, unicode):             # <<<<<<<<<<<<<<
 *             raise TypeError("'compression' must be None or a string")
 *         if compression == u'snappy':
 */
    __pyx_t_6 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_compression, __pyx_t_6); 
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = (!__pyx_t_1);
    if (__pyx_t_7) {

      /* "plyvel/_plyvel.pyx":178
 *             compression = compression.decode('UTF-8')
 *         if not isinstance(compression, unicode):
 *             raise TypeError("'compression' must be None or a string")             # <<<<<<<<<<<<<<
 *         if compression == u'snappy':
 *             options.compression = leveldb.kSnappyCompression
 */
      __pyx_t_6 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "plyvel/_plyvel.pyx":179
 *         if not isinstance(compression, unicode):
 *             raise TypeError("'compression' must be None or a string")
 *         if compression == u'snappy':             # <<<<<<<<<<<<<<
 *             options.compression = leveldb.kSnappyCompression
 *         else:
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_compression, ((PyObject *)__pyx_n_u__snappy), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_7) {

      /* "plyvel/_plyvel.pyx":180
 *             raise TypeError("'compression' must be None or a string")
 *         if compression == u'snappy':
 *             options.compression = leveldb.kSnappyCompression             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("'compression' must be None or 'snappy'")
 */
      __pyx_v_options->compression = leveldb::kSnappyCompression;
      goto __pyx_L15;
    }
    /*else*/ {

      /* "plyvel/_plyvel.pyx":182
 *             options.compression = leveldb.kSnappyCompression
 *         else:
 *             raise ValueError("'compression' must be None or 'snappy'")             # <<<<<<<<<<<<<<
 * 
 *     if bloom_filter_bits > 0:
 */
      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L15:;
  }
  __pyx_L12:;

  /* "plyvel/_plyvel.pyx":184
 *             raise ValueError("'compression' must be None or 'snappy'")
 * 
 *     if bloom_filter_bits > 0:             # <<<<<<<<<<<<<<
 *         with nogil:
 *             options.filter_policy = NewBloomFilterPolicy(bloom_filter_bits)
 */
  __pyx_t_7 = (__pyx_v_bloom_filter_bits > 0);
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":185
 * 
 *     if bloom_filter_bits > 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             options.filter_policy = NewBloomFilterPolicy(bloom_filter_bits)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "plyvel/_plyvel.pyx":186
 *     if bloom_filter_bits > 0:
 *         with nogil:
 *             options.filter_policy = NewBloomFilterPolicy(bloom_filter_bits)             # <<<<<<<<<<<<<<
 * 
 *     if (comparator is None) != (comparator_name is None):
 */
          __pyx_v_options->filter_policy = leveldb::NewBloomFilterPolicy(__pyx_v_bloom_filter_bits);
        }

        /* "plyvel/_plyvel.pyx":185
 * 
 *     if bloom_filter_bits > 0:
 *         with nogil:             # <<<<<<<<<<<<<<
 *             options.filter_policy = NewBloomFilterPolicy(bloom_filter_bits)
 * 
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "plyvel/_plyvel.pyx":188
 *             options.filter_policy = NewBloomFilterPolicy(bloom_filter_bits)
 * 
 *     if (comparator is None) != (comparator_name is None):             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "'comparator' and 'comparator_name' must be specified together")
 */
  __pyx_t_7 = (__pyx_v_comparator == Py_None);
  __pyx_t_1 = (__pyx_v_comparator_name == ((PyObject*)Py_None));
  __pyx_t_8 = (__pyx_t_7 != __pyx_t_1);
  if (__pyx_t_8) {

    /* "plyvel/_plyvel.pyx":189
 * 
 *     if (comparator is None) != (comparator_name is None):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'comparator' and 'comparator_name' must be specified together")
 * 
 */
    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L20;
  }
  __pyx_L20:;

  /* "plyvel/_plyvel.pyx":192
 *             "'comparator' and 'comparator_name' must be specified together")
 * 
 *     if comparator is not None:             # <<<<<<<<<<<<<<
 *         if not callable(comparator):
 *             raise TypeError("custom comparator object must be callable")
 */
  __pyx_t_8 = (__pyx_v_comparator != Py_None);
  if (__pyx_t_8) {

    /* "plyvel/_plyvel.pyx":193
 * 
 *     if comparator is not None:
 *         if not callable(comparator):             # <<<<<<<<<<<<<<
 *             raise TypeError("custom comparator object must be callable")
 * 
 */
    __pyx_t_8 = __Pyx_PyCallable_Check(__pyx_v_comparator); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = (!__pyx_t_8);
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":194
 *     if comparator is not None:
 *         if not callable(comparator):
 *             raise TypeError("custom comparator object must be callable")             # <<<<<<<<<<<<<<
 * 
 *         options.comparator = NewPlyvelCallbackComparator(
 */
      __pyx_t_6 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L22;
    }
    __pyx_L22:;

    /* "plyvel/_plyvel.pyx":197
 * 
 *         options.comparator = NewPlyvelCallbackComparator(
 *             comparator_name, comparator)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_9 = PyBytes_AsString(((PyObject *)__pyx_v_comparator_name)); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plyvel/_plyvel.pyx":196
 *             raise TypeError("custom comparator object must be callable")
 * 
 *         options.comparator = NewPlyvelCallbackComparator(             # <<<<<<<<<<<<<<
 *             comparator_name, comparator)
 * 
 */
    __pyx_v_options->comparator = NewPlyvelCallbackComparator(__pyx_t_9, __pyx_v_comparator);
    goto __pyx_L21;
  }
  __pyx_L21:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plyvel._plyvel.parse_options", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_compression);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6plyvel_7_plyvel_2DB_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6plyvel_7_plyvel_2DB_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  bool __pyx_v_create_if_missing;
  bool __pyx_v_error_if_exists;
  PyObject *__pyx_v_paranoid_checks = 0;
  PyObject *__pyx_v_write_buffer_size = 0;
  PyObject *__pyx_v_max_open_files = 0;
  PyObject *__pyx_v_lru_cache_size = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_block_restart_interval = 0;
  PyObject *__pyx_v_compression = 0;
  int __pyx_v_bloom_filter_bits;
  PyObject *__pyx_v_comparator = 0;
  PyObject *__pyx_v_comparator_name = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__create_if_missing,&__pyx_n_s__error_if_exists,&__pyx_n_s__paranoid_checks,&__pyx_n_s__write_buffer_size,&__pyx_n_s__max_open_files,&__pyx_n_s__lru_cache_size,&__pyx_n_s__block_size,&__pyx_n_s_15,&__pyx_n_s__compression,&__pyx_n_s__bloom_filter_bits,&__pyx_n_s__comparator,&__pyx_n_s__comparator_name,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};

    /* "plyvel/_plyvel.pyx":212
 * 
 *     def __init__(self, name, *, bool create_if_missing=False,
 *                  bool error_if_exists=False, paranoid_checks=None,             # <<<<<<<<<<<<<<
 *                  write_buffer_size=None, max_open_files=None,
 *                  lru_cache_size=None, block_size=None,
 */
    values[3] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":213
 *     def __init__(self, name, *, bool create_if_missing=False,
 *                  bool error_if_exists=False, paranoid_checks=None,
 *                  write_buffer_size=None, max_open_files=None,             # <<<<<<<<<<<<<<
 *                  lru_cache_size=None, block_size=None,
 *                  block_restart_interval=None, compression='snappy',
 */
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":214
 *                  bool error_if_exists=False, paranoid_checks=None,
 *                  write_buffer_size=None, max_open_files=None,
 *                  lru_cache_size=None, block_size=None,             # <<<<<<<<<<<<<<
 *                  block_restart_interval=None, compression='snappy',
 *                  int bloom_filter_bits=0, object comparator=None,
 */
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":215
 *                  write_buffer_size=None, max_open_files=None,
 *                  lru_cache_size=None, block_size=None,
 *                  block_restart_interval=None, compression='snappy',             # <<<<<<<<<<<<<<
 *                  int bloom_filter_bits=0, object comparator=None,
 *                  bytes comparator_name=None):
 */
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject *)__pyx_n_s__snappy);

    /* "plyvel/_plyvel.pyx":216
 *                  lru_cache_size=None, block_size=None,
 *                  block_restart_interval=None, compression='snappy',
 *                  int bloom_filter_bits=0, object comparator=None,             # <<<<<<<<<<<<<<
 *                  bytes comparator_name=None):
 *         cdef Status st
 */
    values[11] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":217
 *                  block_restart_interval=None, compression='snappy',
 *                  int bloom_filter_bits=0, object comparator=None,
 *                  bytes comparator_name=None):             # <<<<<<<<<<<<<<
 *         cdef Status st
 *         cdef string fsname
 */
    values[12] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args > 0 && likely(kw_args <= 12)) {
        Py_ssize_t index;
        for (index = 1; index < 13 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      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 = 211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_name = values[0];
    if (values[1]) {
      __pyx_v_create_if_missing = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_create_if_missing == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "plyvel/_plyvel.pyx":211
 *     cdef object iterators
 * 
 *     def __init__(self, name, *, bool create_if_missing=False,             # <<<<<<<<<<<<<<
 *                  bool error_if_exists=False, paranoid_checks=None,
 *                  write_buffer_size=None, max_open_files=None,
 */
      __pyx_v_create_if_missing = ((bool)0);
    }
    if (values[2]) {
      __pyx_v_error_if_exists = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_error_if_exists == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "plyvel/_plyvel.pyx":212
 * 
 *     def __init__(self, name, *, bool create_if_missing=False,
 *                  bool error_if_exists=False, paranoid_checks=None,             # <<<<<<<<<<<<<<
 *                  write_buffer_size=None, max_open_files=None,
 *                  lru_cache_size=None, block_size=None,
 */
      __pyx_v_error_if_exists = ((bool)0);
    }
    __pyx_v_paranoid_checks = values[3];
    __pyx_v_write_buffer_size = values[4];
    __pyx_v_max_open_files = values[5];
    __pyx_v_lru_cache_size = values[6];
    __pyx_v_block_size = values[7];
    __pyx_v_block_restart_interval = values[8];
    __pyx_v_compression = values[9];
    if (values[10]) {
      __pyx_v_bloom_filter_bits = __Pyx_PyInt_AsInt(values[10]); if (unlikely((__pyx_v_bloom_filter_bits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_bloom_filter_bits = ((int)0);
    }
    __pyx_v_comparator = values[11];
    __pyx_v_comparator_name = ((PyObject*)values[12]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comparator_name), (&PyBytes_Type), 1, "comparator_name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB___init__(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_name, __pyx_v_create_if_missing, __pyx_v_error_if_exists, __pyx_v_paranoid_checks, __pyx_v_write_buffer_size, __pyx_v_max_open_files, __pyx_v_lru_cache_size, __pyx_v_block_size, __pyx_v_block_restart_interval, __pyx_v_compression, __pyx_v_bloom_filter_bits, __pyx_v_comparator, __pyx_v_comparator_name);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":211
 *     cdef object iterators
 * 
 *     def __init__(self, name, *, bool create_if_missing=False,             # <<<<<<<<<<<<<<
 *                  bool error_if_exists=False, paranoid_checks=None,
 *                  write_buffer_size=None, max_open_files=None,
 */

static int __pyx_pf_6plyvel_7_plyvel_2DB___init__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_name, bool __pyx_v_create_if_missing, bool __pyx_v_error_if_exists, PyObject *__pyx_v_paranoid_checks, PyObject *__pyx_v_write_buffer_size, PyObject *__pyx_v_max_open_files, PyObject *__pyx_v_lru_cache_size, PyObject *__pyx_v_block_size, PyObject *__pyx_v_block_restart_interval, PyObject *__pyx_v_compression, int __pyx_v_bloom_filter_bits, PyObject *__pyx_v_comparator, PyObject *__pyx_v_comparator_name) {
  leveldb::Status __pyx_v_st;
  std::string __pyx_v_fsname;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  std::string __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "plyvel/_plyvel.pyx":221
 *         cdef string fsname
 * 
 *         fsname = to_file_system_name(name)             # <<<<<<<<<<<<<<
 *         parse_options(
 *             &self.options, create_if_missing, error_if_exists, paranoid_checks,
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_6plyvel_7_plyvel_to_file_system_name(__pyx_v_name)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fsname = __pyx_t_2;

  /* "plyvel/_plyvel.pyx":226
 *             write_buffer_size, max_open_files, lru_cache_size, block_size,
 *             block_restart_interval, compression, bloom_filter_bits, comparator,
 *             comparator_name)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             st = leveldb.DB_Open(self.options, fsname, &self._db)
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_parse_options((&__pyx_v_self->options), __pyx_v_create_if_missing, __pyx_v_error_if_exists, __pyx_v_paranoid_checks, __pyx_v_write_buffer_size, __pyx_v_max_open_files, __pyx_v_lru_cache_size, __pyx_v_block_size, __pyx_v_block_restart_interval, __pyx_v_compression, __pyx_v_bloom_filter_bits, __pyx_v_comparator, __pyx_v_comparator_name); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":227
 *             block_restart_interval, compression, bloom_filter_bits, comparator,
 *             comparator_name)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = leveldb.DB_Open(self.options, fsname, &self._db)
 *         raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":228
 *             comparator_name)
 *         with nogil:
 *             st = leveldb.DB_Open(self.options, fsname, &self._db)             # <<<<<<<<<<<<<<
 *         raise_for_status(st)
 * 
 */
        __pyx_v_st = leveldb::DB::Open(__pyx_v_self->options, __pyx_v_fsname, (&__pyx_v_self->_db));
      }

      /* "plyvel/_plyvel.pyx":227
 *             block_restart_interval, compression, bloom_filter_bits, comparator,
 *             comparator_name)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = leveldb.DB_Open(self.options, fsname, &self._db)
 *         raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":229
 *         with nogil:
 *             st = leveldb.DB_Open(self.options, fsname, &self._db)
 *         raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 *         # Keep weak references to open iterators, since deleting a C++
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":237
 *         # only available since Python 2.7. Instead we'll just use the
 *         # object's id() as the key.
 *         self.lock = threading.Lock()             # <<<<<<<<<<<<<<
 *         self.iterators = weakref.WeakValueDictionary()
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__threading); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__Lock); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plyvel/_plyvel.pyx":238
 *         # object's id() as the key.
 *         self.lock = threading.Lock()
 *         self.iterators = weakref.WeakValueDictionary()             # <<<<<<<<<<<<<<
 * 
 *     cpdef close(self):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__weakref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__WeakValueDictionary); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->iterators);
  __Pyx_DECREF(__pyx_v_self->iterators);
  __pyx_v_self->iterators = __pyx_t_1;
  __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plyvel._plyvel.DB.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":240
 *         self.iterators = weakref.WeakValueDictionary()
 * 
 *     cpdef close(self):             # <<<<<<<<<<<<<<
 *         # If the constructor raised an exception (and hence never
 *         # completed), self.iterators can be None. In that case no
 */

static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_6plyvel_7_plyvel_2DB_close(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_iterator = 0;
  PyObject *__pyx_v_itervalues = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close", 0);

  /* "plyvel/_plyvel.pyx":246
 *         # produced any used.
 *         cdef Iterator iterator
 *         if self.iterators is not None:             # <<<<<<<<<<<<<<
 *             with self.lock:
 *                 try:
 */
  __pyx_t_1 = (__pyx_v_self->iterators != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":247
 *         cdef Iterator iterator
 *         if self.iterators is not None:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 try:
 *                     itervalues = self.iterators.itervalues  # Python 2
 */
    /*with:*/ {
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self->lock, __pyx_n_s____exit__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self->lock, __pyx_n_s____enter__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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:*/ {

            /* "plyvel/_plyvel.pyx":248
 *         if self.iterators is not None:
 *             with self.lock:
 *                 try:             # <<<<<<<<<<<<<<
 *                     itervalues = self.iterators.itervalues  # Python 2
 *                 except AttributeError:
 */
            {
              __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
              __Pyx_XGOTREF(__pyx_t_8);
              __Pyx_XGOTREF(__pyx_t_9);
              __Pyx_XGOTREF(__pyx_t_10);
              /*try:*/ {

                /* "plyvel/_plyvel.pyx":249
 *             with self.lock:
 *                 try:
 *                     itervalues = self.iterators.itervalues  # Python 2             # <<<<<<<<<<<<<<
 *                 except AttributeError:
 *                     itervalues = self.iterators.values  # Python 3
 */
                __pyx_t_4 = PyObject_GetAttr(__pyx_v_self->iterators, __pyx_n_s__itervalues); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L16_error;}
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_v_itervalues = __pyx_t_4;
                __pyx_t_4 = 0;
              }
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              goto __pyx_L23_try_end;
              __pyx_L16_error:;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "plyvel/_plyvel.pyx":250
 *                 try:
 *                     itervalues = self.iterators.itervalues  # Python 2
 *                 except AttributeError:             # <<<<<<<<<<<<<<
 *                     itervalues = self.iterators.values  # Python 3
 * 
 */
              __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
              if (__pyx_t_11) {
                __Pyx_AddTraceback("plyvel._plyvel.DB.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_GOTREF(__pyx_t_12);

                /* "plyvel/_plyvel.pyx":251
 *                     itervalues = self.iterators.itervalues  # Python 2
 *                 except AttributeError:
 *                     itervalues = self.iterators.values  # Python 3             # <<<<<<<<<<<<<<
 * 
 *                 for iterator in itervalues():
 */
                __pyx_t_13 = PyObject_GetAttr(__pyx_v_self->iterators, __pyx_n_s__values); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L18_except_error;}
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_XDECREF(__pyx_v_itervalues);
                __pyx_v_itervalues = __pyx_t_13;
                __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                goto __pyx_L17_exception_handled;
              }
              __pyx_L18_except_error:;
              __Pyx_XGIVEREF(__pyx_t_8);
              __Pyx_XGIVEREF(__pyx_t_9);
              __Pyx_XGIVEREF(__pyx_t_10);
              __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
              goto __pyx_L8_error;
              __pyx_L17_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_8);
              __Pyx_XGIVEREF(__pyx_t_9);
              __Pyx_XGIVEREF(__pyx_t_10);
              __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
              __pyx_L23_try_end:;
            }

            /* "plyvel/_plyvel.pyx":253
 *                     itervalues = self.iterators.values  # Python 3
 * 
 *                 for iterator in itervalues():             # <<<<<<<<<<<<<<
 *                     iterator.close()
 * 
 */
            __pyx_t_12 = PyObject_Call(__pyx_v_itervalues, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_GOTREF(__pyx_t_12);
            if (PyList_CheckExact(__pyx_t_12) || PyTuple_CheckExact(__pyx_t_12)) {
              __pyx_t_3 = __pyx_t_12; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0;
              __pyx_t_15 = NULL;
            } else {
              __pyx_t_14 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_15 = Py_TYPE(__pyx_t_3)->tp_iternext;
            }
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            for (;;) {
              if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_3)) {
                if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_12 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_12); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
                #else
                __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
                #endif
              } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_3)) {
                if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_12); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
                #else
                __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
                #endif
              } else {
                __pyx_t_12 = __pyx_t_15(__pyx_t_3);
                if (unlikely(!__pyx_t_12)) {
                  if (PyErr_Occurred()) {
                    if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
                    else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_12);
              }
              if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_6plyvel_7_plyvel_Iterator))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
              __Pyx_XDECREF(((PyObject *)__pyx_v_iterator));
              __pyx_v_iterator = ((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_t_12);
              __pyx_t_12 = 0;

              /* "plyvel/_plyvel.pyx":254
 * 
 *                 for iterator in itervalues():
 *                     iterator.close()             # <<<<<<<<<<<<<<
 * 
 *                 self.iterators.clear()
 */
              __pyx_t_12 = __pyx_f_6plyvel_7_plyvel_8Iterator_close(__pyx_v_iterator); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "plyvel/_plyvel.pyx":256
 *                     iterator.close()
 * 
 *                 self.iterators.clear()             # <<<<<<<<<<<<<<
 * 
 *         if self._db is not NULL:
 */
            __pyx_t_3 = PyObject_GetAttr(__pyx_v_self->iterators, __pyx_n_s__clear); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_12 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_L15_try_end;
          __pyx_L8_error:;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "plyvel/_plyvel.pyx":247
 *         cdef Iterator iterator
 *         if self.iterators is not None:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 try:
 *                     itervalues = self.iterators.itervalues  # Python 2
 */
          /*except:*/ {
            __Pyx_AddTraceback("plyvel._plyvel.DB.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_12);
            PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_3);
            PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_10 = PyObject_Call(__pyx_t_2, __pyx_t_13, NULL);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
            __pyx_t_16 = (!__pyx_t_1);
            if (__pyx_t_16) {
              __Pyx_GIVEREF(__pyx_t_12);
              __Pyx_GIVEREF(__pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_4);
              __Pyx_ErrRestore(__pyx_t_12, __pyx_t_3, __pyx_t_4);
              __pyx_t_12 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
              goto __pyx_L30;
            }
            __pyx_L30:;
            __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L9_exception_handled;
          }
          __pyx_L10_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_L9_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_L15_try_end:;
        }
      }
      /*finally:*/ {
        if (__pyx_t_2) {
          __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_k_tuple_16, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
      }
      goto __pyx_L31;
      __pyx_L4_error:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L1_error;
      __pyx_L31:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":258
 *                 self.iterators.clear()
 * 
 *         if self._db is not NULL:             # <<<<<<<<<<<<<<
 *             del self._db
 *             self._db = NULL
 */
  __pyx_t_16 = (__pyx_v_self->_db != NULL);
  if (__pyx_t_16) {

    /* "plyvel/_plyvel.pyx":259
 * 
 *         if self._db is not NULL:
 *             del self._db             # <<<<<<<<<<<<<<
 *             self._db = NULL
 * 
 */
    delete __pyx_v_self->_db;

    /* "plyvel/_plyvel.pyx":260
 *         if self._db is not NULL:
 *             del self._db
 *             self._db = NULL             # <<<<<<<<<<<<<<
 * 
 *         if self.options.block_cache is not NULL:
 */
    __pyx_v_self->_db = NULL;
    goto __pyx_L32;
  }
  __pyx_L32:;

  /* "plyvel/_plyvel.pyx":262
 *             self._db = NULL
 * 
 *         if self.options.block_cache is not NULL:             # <<<<<<<<<<<<<<
 *             del self.options.block_cache
 *             self.options.block_cache = NULL
 */
  __pyx_t_16 = (__pyx_v_self->options.block_cache != NULL);
  if (__pyx_t_16) {

    /* "plyvel/_plyvel.pyx":263
 * 
 *         if self.options.block_cache is not NULL:
 *             del self.options.block_cache             # <<<<<<<<<<<<<<
 *             self.options.block_cache = NULL
 * 
 */
    delete __pyx_v_self->options.block_cache;

    /* "plyvel/_plyvel.pyx":264
 *         if self.options.block_cache is not NULL:
 *             del self.options.block_cache
 *             self.options.block_cache = NULL             # <<<<<<<<<<<<<<
 * 
 *         if self.options.filter_policy is not NULL:
 */
    __pyx_v_self->options.block_cache = NULL;
    goto __pyx_L33;
  }
  __pyx_L33:;

  /* "plyvel/_plyvel.pyx":266
 *             self.options.block_cache = NULL
 * 
 *         if self.options.filter_policy is not NULL:             # <<<<<<<<<<<<<<
 *             del self.options.filter_policy
 *             self.options.filter_policy = NULL
 */
  __pyx_t_16 = (__pyx_v_self->options.filter_policy != NULL);
  if (__pyx_t_16) {

    /* "plyvel/_plyvel.pyx":267
 * 
 *         if self.options.filter_policy is not NULL:
 *             del self.options.filter_policy             # <<<<<<<<<<<<<<
 *             self.options.filter_policy = NULL
 * 
 */
    delete __pyx_v_self->options.filter_policy;

    /* "plyvel/_plyvel.pyx":268
 *         if self.options.filter_policy is not NULL:
 *             del self.options.filter_policy
 *             self.options.filter_policy = NULL             # <<<<<<<<<<<<<<
 * 
 *         if self.options.comparator is not NULL:
 */
    __pyx_v_self->options.filter_policy = NULL;
    goto __pyx_L34;
  }
  __pyx_L34:;

  /* "plyvel/_plyvel.pyx":270
 *             self.options.filter_policy = NULL
 * 
 *         if self.options.comparator is not NULL:             # <<<<<<<<<<<<<<
 *             # The built-in BytewiseComparator must not be deleted
 *             if self.options.comparator is not BytewiseComparator():
 */
  __pyx_t_16 = (__pyx_v_self->options.comparator != NULL);
  if (__pyx_t_16) {

    /* "plyvel/_plyvel.pyx":272
 *         if self.options.comparator is not NULL:
 *             # The built-in BytewiseComparator must not be deleted
 *             if self.options.comparator is not BytewiseComparator():             # <<<<<<<<<<<<<<
 *                 del self.options.comparator
 *                 self.options.comparator = NULL
 */
    __pyx_t_16 = (__pyx_v_self->options.comparator != leveldb::BytewiseComparator());
    if (__pyx_t_16) {

      /* "plyvel/_plyvel.pyx":273
 *             # The built-in BytewiseComparator must not be deleted
 *             if self.options.comparator is not BytewiseComparator():
 *                 del self.options.comparator             # <<<<<<<<<<<<<<
 *                 self.options.comparator = NULL
 * 
 */
      delete __pyx_v_self->options.comparator;

      /* "plyvel/_plyvel.pyx":274
 *             if self.options.comparator is not BytewiseComparator():
 *                 del self.options.comparator
 *                 self.options.comparator = NULL             # <<<<<<<<<<<<<<
 * 
 *     property closed:
 */
      __pyx_v_self->options.comparator = NULL;
      goto __pyx_L36;
    }
    __pyx_L36:;
    goto __pyx_L35;
  }
  __pyx_L35:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("plyvel._plyvel.DB.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_iterator);
  __Pyx_XDECREF(__pyx_v_itervalues);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_2close[] = "DB.close(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_3close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_2close(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":240
 *         self.iterators = weakref.WeakValueDictionary()
 * 
 *     cpdef close(self):             # <<<<<<<<<<<<<<
 *         # If the constructor raised an exception (and hence never
 *         # completed), self.iterators can be None. In that case no
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_2close(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6plyvel_7_plyvel_2DB_close(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.DB.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_6closed_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_6closed_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_6closed___get__(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":277
 * 
 *     property closed:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._db is NULL
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_6closed___get__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plyvel/_plyvel.pyx":278
 *     property closed:
 *         def __get__(self):
 *             return self._db is NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->_db == NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.DB.closed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_6plyvel_7_plyvel_2DB_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_6plyvel_7_plyvel_2DB_5__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_6plyvel_7_plyvel_2DB_4__dealloc__(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "plyvel/_plyvel.pyx":280
 *             return self._db is NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

static void __pyx_pf_6plyvel_7_plyvel_2DB_4__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "plyvel/_plyvel.pyx":281
 * 
 *     def __dealloc__(self):
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 */
  __pyx_t_1 = __pyx_f_6plyvel_7_plyvel_2DB_close(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.DB.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_7get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_6get[] = "DB.get(self, bytes key, *, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_7get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[3] = {0,0,0};

    /* "plyvel/_plyvel.pyx":283
 *         self.close()
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 1; index < 3 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_verify_checksums = values[1];
    __pyx_v_fill_cache = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_6get(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_key, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_6get(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  leveldb::ReadOptions __pyx_v_read_options;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  bool __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);

  /* "plyvel/_plyvel.pyx":284
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":285
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef ReadOptions read_options
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":289
 *         cdef ReadOptions read_options
 * 
 *         if verify_checksums is not None:             # <<<<<<<<<<<<<<
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 */
  __pyx_t_1 = (__pyx_v_verify_checksums != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":290
 * 
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums             # <<<<<<<<<<<<<<
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_verify_checksums); if (unlikely((__pyx_t_3 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_read_options.verify_checksums = __pyx_t_3;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":291
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:             # <<<<<<<<<<<<<<
 *             read_options.fill_cache = fill_cache
 * 
 */
  __pyx_t_1 = (__pyx_v_fill_cache != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":292
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache             # <<<<<<<<<<<<<<
 * 
 *         return db_get(self, key, read_options)
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_fill_cache); if (unlikely((__pyx_t_3 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_read_options.fill_cache = __pyx_t_3;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":294
 *             read_options.fill_cache = fill_cache
 * 
 *         return db_get(self, key, read_options)             # <<<<<<<<<<<<<<
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_db_get(__pyx_v_self, __pyx_v_key, __pyx_v_read_options); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.DB.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_9put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_8put[] = "DB.put(self, bytes key, bytes value, *, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_9put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("put (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,&__pyx_n_s__sync,0};
    PyObject* values[3] = {0,0,0};

    /* "plyvel/_plyvel.pyx":296
 *         return db_get(self, key, read_options)
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 2;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_value = ((PyObject*)values[1]);
    __pyx_v_sync = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_8put(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_key, __pyx_v_value, __pyx_v_sync);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_8put(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_sync) {
  leveldb::WriteOptions __pyx_v_write_options;
  leveldb::Slice __pyx_v_key_slice;
  leveldb::Slice __pyx_v_value_slice;
  leveldb::Status __pyx_v_st;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  bool __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("put", 0);

  /* "plyvel/_plyvel.pyx":297
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":298
 *     def put(self, bytes key, bytes value, *, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef WriteOptions write_options = WriteOptions()
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":300
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         cdef WriteOptions write_options = WriteOptions()             # <<<<<<<<<<<<<<
 *         cdef Slice key_slice = Slice(key, len(key))
 *         cdef Slice value_slice = Slice(value, len(value))
 */
  __pyx_v_write_options = leveldb::WriteOptions();

  /* "plyvel/_plyvel.pyx":301
 * 
 *         cdef WriteOptions write_options = WriteOptions()
 *         cdef Slice key_slice = Slice(key, len(key))             # <<<<<<<<<<<<<<
 *         cdef Slice value_slice = Slice(value, len(value))
 *         cdef Status st
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":302
 *         cdef WriteOptions write_options = WriteOptions()
 *         cdef Slice key_slice = Slice(key, len(key))
 *         cdef Slice value_slice = Slice(value, len(value))             # <<<<<<<<<<<<<<
 *         cdef Status st
 * 
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_value)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_value) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_value)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_value_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":305
 *         cdef Status st
 * 
 *         if sync is not None:             # <<<<<<<<<<<<<<
 *             write_options.sync = sync
 * 
 */
  __pyx_t_1 = (__pyx_v_sync != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":306
 * 
 *         if sync is not None:
 *             write_options.sync = sync             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_sync); if (unlikely((__pyx_t_5 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_write_options.sync = __pyx_t_5;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":308
 *             write_options.sync = sync
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self._db.Put(write_options, key_slice, value_slice)
 *         raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":309
 * 
 *         with nogil:
 *             st = self._db.Put(write_options, key_slice, value_slice)             # <<<<<<<<<<<<<<
 *         raise_for_status(st)
 * 
 */
        __pyx_v_st = __pyx_v_self->_db->Put(__pyx_v_write_options, __pyx_v_key_slice, __pyx_v_value_slice);
      }

      /* "plyvel/_plyvel.pyx":308
 *             write_options.sync = sync
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self._db.Put(write_options, key_slice, value_slice)
 *         raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":310
 *         with nogil:
 *             st = self._db.Put(write_options, key_slice, value_slice)
 *         raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 *     def delete(self, bytes key, *, sync=None):
 */
  __pyx_t_6 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.DB.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_11delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_10delete[] = "DB.delete(self, bytes key, *, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_11delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__sync,0};
    PyObject* values[2] = {0,0};

    /* "plyvel/_plyvel.pyx":312
 *         raise_for_status(st)
 * 
 *     def delete(self, bytes key, *, sync=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 1;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "delete") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_sync = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("delete", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_10delete(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_key, __pyx_v_sync);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_10delete(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_sync) {
  leveldb::Status __pyx_v_st;
  leveldb::WriteOptions __pyx_v_write_options;
  leveldb::Slice __pyx_v_key_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  bool __pyx_t_3;
  const char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("delete", 0);

  /* "plyvel/_plyvel.pyx":313
 * 
 *     def delete(self, bytes key, *, sync=None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":314
 *     def delete(self, bytes key, *, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Status st
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":317
 * 
 *         cdef Status st
 *         cdef WriteOptions write_options = WriteOptions()             # <<<<<<<<<<<<<<
 * 
 *         if sync is not None:
 */
  __pyx_v_write_options = leveldb::WriteOptions();

  /* "plyvel/_plyvel.pyx":319
 *         cdef WriteOptions write_options = WriteOptions()
 * 
 *         if sync is not None:             # <<<<<<<<<<<<<<
 *             write_options.sync = sync
 * 
 */
  __pyx_t_1 = (__pyx_v_sync != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":320
 * 
 *         if sync is not None:
 *             write_options.sync = sync             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_sync); if (unlikely((__pyx_t_3 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_write_options.sync = __pyx_t_3;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":322
 *             write_options.sync = sync
 * 
 *         cdef Slice key_slice = Slice(key, len(key))             # <<<<<<<<<<<<<<
 *         with nogil:
 *             st = self._db.Delete(write_options, key_slice)
 */
  __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key_slice = leveldb::Slice(__pyx_t_4, __pyx_t_5);

  /* "plyvel/_plyvel.pyx":323
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self._db.Delete(write_options, key_slice)
 *         raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":324
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:
 *             st = self._db.Delete(write_options, key_slice)             # <<<<<<<<<<<<<<
 *         raise_for_status(st)
 * 
 */
        __pyx_v_st = __pyx_v_self->_db->Delete(__pyx_v_write_options, __pyx_v_key_slice);
      }

      /* "plyvel/_plyvel.pyx":323
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self._db.Delete(write_options, key_slice)
 *         raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":325
 *         with nogil:
 *             st = self._db.Delete(write_options, key_slice)
 *         raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 *     def write_batch(self, *, transaction=False, sync=None):
 */
  __pyx_t_6 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.DB.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_13write_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_12write_batch[] = "DB.write_batch(self, *, transaction=False, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_13write_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_transaction = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_batch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__transaction,&__pyx_n_s__sync,0};
    PyObject* values[2] = {0,0};
    values[0] = __pyx_k_21;

    /* "plyvel/_plyvel.pyx":327
 *         raise_for_status(st)
 * 
 *     def write_batch(self, *, transaction=False, sync=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 0; index < 2 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "write_batch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_transaction = values[0];
    __pyx_v_sync = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_batch", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.write_batch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_12write_batch(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_transaction, __pyx_v_sync);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_12write_batch(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_transaction, PyObject *__pyx_v_sync) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_batch", 0);

  /* "plyvel/_plyvel.pyx":328
 * 
 *     def write_batch(self, *, transaction=False, sync=None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":329
 *     def write_batch(self, *, transaction=False, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return WriteBatch(db=self, transaction=transaction, sync=sync)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":331
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         return WriteBatch(db=self, transaction=transaction, sync=sync)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__transaction), __pyx_v_transaction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sync), __pyx_v_sync) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_WriteBatch)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __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_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plyvel._plyvel.DB.write_batch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_15__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_15__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_14__iter__(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":333
 *         return WriteBatch(db=self, transaction=transaction, sync=sync)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_14__iter__(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "plyvel/_plyvel.pyx":334
 * 
 *     def __iter__(self):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":335
 *     def __iter__(self):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.iterator()
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":337
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         return self.iterator()             # <<<<<<<<<<<<<<
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__iterator); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plyvel._plyvel.DB.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_17iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_16iterator[] = "DB.iterator(self, *, reverse=False, start=None, stop=None, include_start=True, include_stop=False, prefix=None, include_key=True, include_value=True, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_17iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_include_start = 0;
  PyObject *__pyx_v_include_stop = 0;
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_include_key = 0;
  PyObject *__pyx_v_include_value = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reverse,&__pyx_n_s__start,&__pyx_n_s__stop,&__pyx_n_s__include_start,&__pyx_n_s__include_stop,&__pyx_n_s__prefix,&__pyx_n_s__include_key,&__pyx_n_s__include_value,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    values[0] = __pyx_k_24;

    /* "plyvel/_plyvel.pyx":339
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_25;
    values[4] = __pyx_k_26;

    /* "plyvel/_plyvel.pyx":340
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
    values[5] = ((PyObject *)Py_None);
    values[6] = __pyx_k_27;
    values[7] = __pyx_k_28;

    /* "plyvel/_plyvel.pyx":341
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
    values[8] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":342
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):             # <<<<<<<<<<<<<<
 *         return Iterator(
 *             db=self, key_prefix=None, reverse=reverse, start=start, stop=stop,
 */
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 10)) {
        Py_ssize_t index;
        for (index = 0; index < 10 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "iterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_reverse = values[0];
    __pyx_v_start = values[1];
    __pyx_v_stop = values[2];
    __pyx_v_include_start = values[3];
    __pyx_v_include_stop = values[4];
    __pyx_v_prefix = values[5];
    __pyx_v_include_key = values[6];
    __pyx_v_include_value = values[7];
    __pyx_v_verify_checksums = values[8];
    __pyx_v_fill_cache = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterator", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_16iterator(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_reverse, __pyx_v_start, __pyx_v_stop, __pyx_v_include_start, __pyx_v_include_stop, __pyx_v_prefix, __pyx_v_include_key, __pyx_v_include_value, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":339
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_16iterator(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iterator", 0);

  /* "plyvel/_plyvel.pyx":343
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 *         return Iterator(             # <<<<<<<<<<<<<<
 *             db=self, key_prefix=None, reverse=reverse, start=start, stop=stop,
 *             include_start=include_start, include_stop=include_stop,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "plyvel/_plyvel.pyx":344
 *                  fill_cache=None):
 *         return Iterator(
 *             db=self, key_prefix=None, reverse=reverse, start=start, stop=stop,             # <<<<<<<<<<<<<<
 *             include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__key_prefix), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__reverse), __pyx_v_reverse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__start), __pyx_v_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__stop), __pyx_v_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":345
 *         return Iterator(
 *             db=self, key_prefix=None, reverse=reverse, start=start, stop=stop,
 *             include_start=include_start, include_stop=include_stop,             # <<<<<<<<<<<<<<
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_start), __pyx_v_include_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_stop), __pyx_v_include_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":346
 *             db=self, key_prefix=None, reverse=reverse, start=start, stop=stop,
 *             include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,             # <<<<<<<<<<<<<<
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=None)
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), __pyx_v_prefix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_key), __pyx_v_include_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":347
 *             include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,             # <<<<<<<<<<<<<<
 *             fill_cache=fill_cache, snapshot=None)
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_value), __pyx_v_include_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__verify_checksums), __pyx_v_verify_checksums) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":348
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=None)             # <<<<<<<<<<<<<<
 * 
 *     cdef _register_iterator(self, Iterator iterator):
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__fill_cache), __pyx_v_fill_cache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__snapshot), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_Iterator)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.DB.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":350
 *             fill_cache=fill_cache, snapshot=None)
 * 
 *     cdef _register_iterator(self, Iterator iterator):             # <<<<<<<<<<<<<<
 *         # Store a weak reference to an iterator (needed when closing DB)
 *         self.iterators[id(iterator)] = iterator
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_2DB__register_iterator(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_iterator) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_register_iterator", 0);

  /* "plyvel/_plyvel.pyx":352
 *     cdef _register_iterator(self, Iterator iterator):
 *         # Store a weak reference to an iterator (needed when closing DB)
 *         self.iterators[id(iterator)] = iterator             # <<<<<<<<<<<<<<
 * 
 *     def snapshot(self):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_iterator));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_iterator));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyObject_SetItem(__pyx_v_self->iterators, __pyx_t_2, ((PyObject *)__pyx_v_iterator)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __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_AddTraceback("plyvel._plyvel.DB._register_iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_19snapshot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_18snapshot[] = "DB.snapshot(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_19snapshot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("snapshot (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_18snapshot(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":354
 *         self.iterators[id(iterator)] = iterator
 * 
 *     def snapshot(self):             # <<<<<<<<<<<<<<
 *         return Snapshot(db=self)
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_18snapshot(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("snapshot", 0);

  /* "plyvel/_plyvel.pyx":355
 * 
 *     def snapshot(self):
 *         return Snapshot(db=self)             # <<<<<<<<<<<<<<
 * 
 *     def get_property(self, bytes name not None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_Snapshot)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.DB.snapshot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_21get_property(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_20get_property[] = "DB.get_property(self, bytes name)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_21get_property(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_property (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyBytes_Type), 0, "name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_20get_property(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), ((PyObject*)__pyx_v_name));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":357
 *         return Snapshot(db=self)
 * 
 *     def get_property(self, bytes name not None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_20get_property(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_name) {
  leveldb::Slice __pyx_v_sl;
  std::string __pyx_v_value;
  bool __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_property", 0);

  /* "plyvel/_plyvel.pyx":358
 * 
 *     def get_property(self, bytes name not None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":359
 *     def get_property(self, bytes name not None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice sl = Slice(name, len(name))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":361
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         cdef Slice sl = Slice(name, len(name))             # <<<<<<<<<<<<<<
 *         cdef string value
 *         cdef bool result
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_name)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_name)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_sl = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":365
 *         cdef bool result
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = self._db.GetProperty(sl, &value)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":366
 * 
 *         with nogil:
 *             result = self._db.GetProperty(sl, &value)             # <<<<<<<<<<<<<<
 * 
 *         return value if result else None
 */
        __pyx_v_result = __pyx_v_self->_db->GetProperty(__pyx_v_sl, (&__pyx_v_value));
      }

      /* "plyvel/_plyvel.pyx":365
 *         cdef bool result
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = self._db.GetProperty(sl, &value)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":368
 *             result = self._db.GetProperty(sl, &value)
 * 
 *         return value if result else None             # <<<<<<<<<<<<<<
 * 
 *     def compact_range(self, *, bytes start=None, bytes stop=None):
 */
  __Pyx_XDECREF(__pyx_r);
  if (__pyx_v_result) {
    __pyx_t_5 = __pyx_convert_string_to_py_(__pyx_v_value); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __pyx_t_2 = ((PyObject *)__pyx_t_5);
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_2 = Py_None;
  }
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plyvel._plyvel.DB.get_property", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_23compact_range(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_22compact_range[] = "DB.compact_range(self, *, bytes start=None, bytes stop=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_23compact_range(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compact_range (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__stop,0};
    PyObject* values[2] = {0,0};

    /* "plyvel/_plyvel.pyx":370
 *         return value if result else None
 * 
 *     def compact_range(self, *, bytes start=None, bytes stop=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[0] = ((PyObject*)Py_None);
    values[1] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 0; index < 2 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "compact_range") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_start = ((PyObject*)values[0]);
    __pyx_v_stop = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("compact_range", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.compact_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start), (&PyBytes_Type), 1, "start", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stop), (&PyBytes_Type), 1, "stop", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_22compact_range(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_start, __pyx_v_stop);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_22compact_range(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_stop) {
  leveldb::Slice __pyx_v_start_slice;
  leveldb::Slice __pyx_v_stop_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("compact_range", 0);

  /* "plyvel/_plyvel.pyx":371
 * 
 *     def compact_range(self, *, bytes start=None, bytes stop=None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":372
 *     def compact_range(self, *, bytes start=None, bytes stop=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice start_slice
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":377
 *         cdef Slice stop_slice
 * 
 *         if start is not None:             # <<<<<<<<<<<<<<
 *             start_slice = Slice(start, len(start))
 * 
 */
  __pyx_t_1 = (__pyx_v_start != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":378
 * 
 *         if start is not None:
 *             start_slice = Slice(start, len(start))             # <<<<<<<<<<<<<<
 * 
 *         if stop is not None:
 */
    __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_start)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_start) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_start)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_start_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":380
 *             start_slice = Slice(start, len(start))
 * 
 *         if stop is not None:             # <<<<<<<<<<<<<<
 *             stop_slice = Slice(stop, len(stop))
 * 
 */
  __pyx_t_1 = (__pyx_v_stop != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":381
 * 
 *         if stop is not None:
 *             stop_slice = Slice(stop, len(stop))             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_stop)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_stop) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_stop)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_stop_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":383
 *             stop_slice = Slice(stop, len(stop))
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._db.CompactRange(&start_slice, &stop_slice)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":384
 * 
 *         with nogil:
 *             self._db.CompactRange(&start_slice, &stop_slice)             # <<<<<<<<<<<<<<
 * 
 *     def approximate_size(self, bytes start not None, bytes stop not None):
 */
        __pyx_v_self->_db->CompactRange((&__pyx_v_start_slice), (&__pyx_v_stop_slice));
      }

      /* "plyvel/_plyvel.pyx":383
 *             stop_slice = Slice(stop, len(stop))
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._db.CompactRange(&start_slice, &stop_slice)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.DB.compact_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_25approximate_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_24approximate_size[] = "DB.approximate_size(self, bytes start, bytes stop)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_25approximate_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("approximate_size (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__stop,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stop)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("approximate_size", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "approximate_size") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_start = ((PyObject*)values[0]);
    __pyx_v_stop = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("approximate_size", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.DB.approximate_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start), (&PyBytes_Type), 0, "start", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stop), (&PyBytes_Type), 0, "stop", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_24approximate_size(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_start, __pyx_v_stop);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":386
 *             self._db.CompactRange(&start_slice, &stop_slice)
 * 
 *     def approximate_size(self, bytes start not None, bytes stop not None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_24approximate_size(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_stop) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("approximate_size", 0);

  /* "plyvel/_plyvel.pyx":387
 * 
 *     def approximate_size(self, bytes start not None, bytes stop not None):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":388
 *     def approximate_size(self, bytes start not None, bytes stop not None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.approximate_sizes((start, stop))[0]
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":390
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         return self.approximate_sizes((start, stop))[0]             # <<<<<<<<<<<<<<
 * 
 *     def approximate_sizes(self, *ranges):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__approximate_sizes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_start));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_start));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_start));
  __Pyx_INCREF(((PyObject *)__pyx_v_stop));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_stop));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_stop));
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plyvel._plyvel.DB.approximate_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_27approximate_sizes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_26approximate_sizes[] = "DB.approximate_sizes(self, *ranges)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_27approximate_sizes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ranges = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("approximate_sizes (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "approximate_sizes", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_ranges = __pyx_args;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_26approximate_sizes(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), __pyx_v_ranges);
  __Pyx_XDECREF(__pyx_v_ranges);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":392
 *         return self.approximate_sizes((start, stop))[0]
 * 
 *     def approximate_sizes(self, *ranges):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_26approximate_sizes(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_ranges) {
  int __pyx_v_n_ranges;
  leveldb::Range *__pyx_v_c_ranges;
  uint64_t *__pyx_v_sizes;
  int __pyx_v_i;
  PyObject *__pyx_v_start = NULL;
  PyObject *__pyx_v_stop = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_t_11;
  const char *__pyx_t_12;
  const char *__pyx_t_13;
  Py_ssize_t __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("approximate_sizes", 0);

  /* "plyvel/_plyvel.pyx":393
 * 
 *     def approximate_sizes(self, *ranges):
 *         if self._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":394
 *     def approximate_sizes(self, *ranges):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef int n_ranges = len(ranges)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":396
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         cdef int n_ranges = len(ranges)             # <<<<<<<<<<<<<<
 *         cdef Range *c_ranges = <Range *>malloc(n_ranges * sizeof(Range))
 *         cdef uint64_t *sizes = <uint64_t *>malloc(n_ranges * sizeof(uint64_t))
 */
  __pyx_t_3 = PyTuple_GET_SIZE(((PyObject *)__pyx_v_ranges)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n_ranges = __pyx_t_3;

  /* "plyvel/_plyvel.pyx":397
 * 
 *         cdef int n_ranges = len(ranges)
 *         cdef Range *c_ranges = <Range *>malloc(n_ranges * sizeof(Range))             # <<<<<<<<<<<<<<
 *         cdef uint64_t *sizes = <uint64_t *>malloc(n_ranges * sizeof(uint64_t))
 *         try:
 */
  __pyx_v_c_ranges = ((leveldb::Range *)malloc((__pyx_v_n_ranges * (sizeof(leveldb::Range)))));

  /* "plyvel/_plyvel.pyx":398
 *         cdef int n_ranges = len(ranges)
 *         cdef Range *c_ranges = <Range *>malloc(n_ranges * sizeof(Range))
 *         cdef uint64_t *sizes = <uint64_t *>malloc(n_ranges * sizeof(uint64_t))             # <<<<<<<<<<<<<<
 *         try:
 *             for i in xrange(n_ranges):
 */
  __pyx_v_sizes = ((uint64_t *)malloc((__pyx_v_n_ranges * (sizeof(uint64_t)))));

  /* "plyvel/_plyvel.pyx":399
 *         cdef Range *c_ranges = <Range *>malloc(n_ranges * sizeof(Range))
 *         cdef uint64_t *sizes = <uint64_t *>malloc(n_ranges * sizeof(uint64_t))
 *         try:             # <<<<<<<<<<<<<<
 *             for i in xrange(n_ranges):
 *                 start, stop = ranges[i]
 */
  /*try:*/ {

    /* "plyvel/_plyvel.pyx":400
 *         cdef uint64_t *sizes = <uint64_t *>malloc(n_ranges * sizeof(uint64_t))
 *         try:
 *             for i in xrange(n_ranges):             # <<<<<<<<<<<<<<
 *                 start, stop = ranges[i]
 *                 if not isinstance(start, bytes) or not isinstance(stop, bytes):
 */
    __pyx_t_4 = __pyx_v_n_ranges;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "plyvel/_plyvel.pyx":401
 *         try:
 *             for i in xrange(n_ranges):
 *                 start, stop = ranges[i]             # <<<<<<<<<<<<<<
 *                 if not isinstance(start, bytes) or not isinstance(stop, bytes):
 *                     raise TypeError(
 */
      __pyx_t_2 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_ranges), __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L5;}
        __pyx_L10_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_start);
      __pyx_v_start = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_stop);
      __pyx_v_stop = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "plyvel/_plyvel.pyx":402
 *             for i in xrange(n_ranges):
 *                 start, stop = ranges[i]
 *                 if not isinstance(start, bytes) or not isinstance(stop, bytes):             # <<<<<<<<<<<<<<
 *                     raise TypeError(
 *                         "Start and stop of range must be byte strings")
 */
      __pyx_t_2 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_start, __pyx_t_2); 
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = (!__pyx_t_1);
      if (!__pyx_t_10) {
        __pyx_t_2 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_stop, __pyx_t_2); 
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_11 = (!__pyx_t_1);
        __pyx_t_1 = __pyx_t_11;
      } else {
        __pyx_t_1 = __pyx_t_10;
      }
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":403
 *                 start, stop = ranges[i]
 *                 if not isinstance(start, bytes) or not isinstance(stop, bytes):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         "Start and stop of range must be byte strings")
 *                 c_ranges[i] = Range(
 */
        __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L5;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L5;}
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "plyvel/_plyvel.pyx":406
 *                         "Start and stop of range must be byte strings")
 *                 c_ranges[i] = Range(
 *                     Slice(start, len(start)),             # <<<<<<<<<<<<<<
 *                     Slice(stop, len(stop)))
 * 
 */
      __pyx_t_12 = PyBytes_AsString(__pyx_v_start); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __pyx_t_3 = PyObject_Length(__pyx_v_start); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L5;}

      /* "plyvel/_plyvel.pyx":407
 *                 c_ranges[i] = Range(
 *                     Slice(start, len(start)),
 *                     Slice(stop, len(stop)))             # <<<<<<<<<<<<<<
 * 
 *             with nogil:
 */
      __pyx_t_13 = PyBytes_AsString(__pyx_v_stop); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __pyx_t_14 = PyObject_Length(__pyx_v_stop); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L5;}

      /* "plyvel/_plyvel.pyx":405
 *                     raise TypeError(
 *                         "Start and stop of range must be byte strings")
 *                 c_ranges[i] = Range(             # <<<<<<<<<<<<<<
 *                     Slice(start, len(start)),
 *                     Slice(stop, len(stop)))
 */
      (__pyx_v_c_ranges[__pyx_v_i]) = leveldb::Range(leveldb::Slice(__pyx_t_12, __pyx_t_3), leveldb::Slice(__pyx_t_13, __pyx_t_14));
    }

    /* "plyvel/_plyvel.pyx":409
 *                     Slice(stop, len(stop)))
 * 
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._db.GetApproximateSizes(c_ranges, n_ranges, sizes)
 * 
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "plyvel/_plyvel.pyx":410
 * 
 *             with nogil:
 *                 self._db.GetApproximateSizes(c_ranges, n_ranges, sizes)             # <<<<<<<<<<<<<<
 * 
 *             return [sizes[i] for i in xrange(n_ranges)]
 */
          __pyx_v_self->_db->GetApproximateSizes(__pyx_v_c_ranges, __pyx_v_n_ranges, __pyx_v_sizes);
        }

        /* "plyvel/_plyvel.pyx":409
 *                     Slice(stop, len(stop)))
 * 
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._db.GetApproximateSizes(c_ranges, n_ranges, sizes)
 * 
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "plyvel/_plyvel.pyx":412
 *                 self._db.GetApproximateSizes(c_ranges, n_ranges, sizes)
 * 
 *             return [sizes[i] for i in xrange(n_ranges)]             # <<<<<<<<<<<<<<
 *         finally:
 *             free(c_ranges)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L5;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_v_n_ranges;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;
      __pyx_t_7 = __Pyx_PyInt_to_py_uint64_t((__pyx_v_sizes[__pyx_v_i])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L5;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_INCREF(((PyObject *)__pyx_t_2));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":414
 *             return [sizes[i] for i in xrange(n_ranges)]
 *         finally:
 *             free(c_ranges)             # <<<<<<<<<<<<<<
 *             free(sizes)
 * 
 */
  /*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_L6;
    __pyx_L4: __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
    __pyx_why = 3; goto __pyx_L6;
    __pyx_L5: {
      __pyx_why = 4;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
      __pyx_exc_lineno = __pyx_lineno;
      goto __pyx_L6;
    }
    __pyx_L6:;
    free(__pyx_v_c_ranges);

    /* "plyvel/_plyvel.pyx":415
 *         finally:
 *             free(c_ranges)
 *             free(sizes)             # <<<<<<<<<<<<<<
 * 
 *     def prefixed_db(self, bytes prefix not None):
 */
    free(__pyx_v_sizes);
    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;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plyvel._plyvel.DB.approximate_sizes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_stop);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_29prefixed_db(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2DB_28prefixed_db[] = "DB.prefixed_db(self, bytes prefix)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_2DB_29prefixed_db(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prefixed_db (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyBytes_Type), 0, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2DB_28prefixed_db(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_self), ((PyObject*)__pyx_v_prefix));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":417
 *             free(sizes)
 * 
 *     def prefixed_db(self, bytes prefix not None):             # <<<<<<<<<<<<<<
 *         return PrefixedDB(db=self, prefix=prefix)
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2DB_28prefixed_db(struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_self, PyObject *__pyx_v_prefix) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prefixed_db", 0);

  /* "plyvel/_plyvel.pyx":418
 * 
 *     def prefixed_db(self, bytes prefix not None):
 *         return PrefixedDB(db=self, prefix=prefix)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), ((PyObject *)__pyx_v_prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_PrefixedDB)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.DB.prefixed_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_db = 0;
  PyObject *__pyx_v_prefix = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__db,&__pyx_n_s__prefix,0};
    PyObject* values[2] = {0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__db)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__prefix); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_db = values[0];
    __pyx_v_prefix = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB___init__(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_db, __pyx_v_prefix);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":425
 *     cdef readonly bytes prefix
 * 
 *     def __init__(self, *, db, prefix):             # <<<<<<<<<<<<<<
 *         self.db = db
 *         self.prefix = prefix
 */

static int __pyx_pf_6plyvel_7_plyvel_10PrefixedDB___init__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_db, PyObject *__pyx_v_prefix) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "plyvel/_plyvel.pyx":426
 * 
 *     def __init__(self, *, db, prefix):
 *         self.db = db             # <<<<<<<<<<<<<<
 *         self.prefix = prefix
 * 
 */
  if (!(likely(((__pyx_v_db) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_db, __pyx_ptype_6plyvel_7_plyvel_DB))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_db);
  __Pyx_GIVEREF(__pyx_v_db);
  __Pyx_GOTREF(__pyx_v_self->db);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->db));
  __pyx_v_self->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_v_db);

  /* "plyvel/_plyvel.pyx":427
 *     def __init__(self, *, db, prefix):
 *         self.db = db
 *         self.prefix = prefix             # <<<<<<<<<<<<<<
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_prefix))||((__pyx_v_prefix) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_prefix)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_prefix);
  __Pyx_GIVEREF(__pyx_v_prefix);
  __Pyx_GOTREF(__pyx_v_self->prefix);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->prefix));
  __pyx_v_self->prefix = ((PyObject*)__pyx_v_prefix);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_3get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_2get[] = "PrefixedDB.get(self, bytes key, *, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_3get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[3] = {0,0,0};

    /* "plyvel/_plyvel.pyx":429
 *         self.prefix = prefix
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):             # <<<<<<<<<<<<<<
 *         return self.db.get(
 *             self.prefix + key,
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 1; index < 3 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_verify_checksums = values[1];
    __pyx_v_fill_cache = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2get(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_key, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2get(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);

  /* "plyvel/_plyvel.pyx":430
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         return self.db.get(             # <<<<<<<<<<<<<<
 *             self.prefix + key,
 *             verify_checksums=verify_checksums,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->db), __pyx_n_s__get); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plyvel/_plyvel.pyx":431
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         return self.db.get(
 *             self.prefix + key,             # <<<<<<<<<<<<<<
 *             verify_checksums=verify_checksums,
 *             fill_cache=fill_cache)
 */
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":430
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         return self.db.get(             # <<<<<<<<<<<<<<
 *             self.prefix + key,
 *             verify_checksums=verify_checksums,
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "plyvel/_plyvel.pyx":432
 *         return self.db.get(
 *             self.prefix + key,
 *             verify_checksums=verify_checksums,             # <<<<<<<<<<<<<<
 *             fill_cache=fill_cache)
 * 
 */
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__verify_checksums), __pyx_v_verify_checksums) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":433
 *             self.prefix + key,
 *             verify_checksums=verify_checksums,
 *             fill_cache=fill_cache)             # <<<<<<<<<<<<<<
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):
 */
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__fill_cache), __pyx_v_fill_cache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_5put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_4put[] = "PrefixedDB.put(self, bytes key, bytes value, *, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_5put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("put (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,&__pyx_n_s__sync,0};
    PyObject* values[3] = {0,0,0};

    /* "plyvel/_plyvel.pyx":435
 *             fill_cache=fill_cache)
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):             # <<<<<<<<<<<<<<
 *         return self.db.put(self.prefix + key, value, sync=sync)
 * 
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 2;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_value = ((PyObject*)values[1]);
    __pyx_v_sync = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_4put(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_key, __pyx_v_value, __pyx_v_sync);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_4put(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value, PyObject *__pyx_v_sync) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("put", 0);

  /* "plyvel/_plyvel.pyx":436
 * 
 *     def put(self, bytes key, bytes value, *, sync=None):
 *         return self.db.put(self.prefix + key, value, sync=sync)             # <<<<<<<<<<<<<<
 * 
 *     def delete(self, bytes key, *, sync=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->db), __pyx_n_s__put); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_v_value));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_value));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_value));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sync), __pyx_v_sync) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_7delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_6delete[] = "PrefixedDB.delete(self, bytes key, *, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_7delete(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__sync,0};
    PyObject* values[2] = {0,0};

    /* "plyvel/_plyvel.pyx":438
 *         return self.db.put(self.prefix + key, value, sync=sync)
 * 
 *     def delete(self, bytes key, *, sync=None):             # <<<<<<<<<<<<<<
 *         return self.db.delete(self.prefix + key, sync=sync)
 * 
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 1;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "delete") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_sync = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("delete", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6delete(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_key, __pyx_v_sync);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6delete(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_sync) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("delete", 0);

  /* "plyvel/_plyvel.pyx":439
 * 
 *     def delete(self, bytes key, *, sync=None):
 *         return self.db.delete(self.prefix + key, sync=sync)             # <<<<<<<<<<<<<<
 * 
 *     def write_batch(self, *, transaction=False, sync=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->db), __pyx_n_s__delete); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sync), __pyx_v_sync) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_9write_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_8write_batch[] = "PrefixedDB.write_batch(self, *, transaction=False, sync=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_9write_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_transaction = 0;
  PyObject *__pyx_v_sync = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_batch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__transaction,&__pyx_n_s__sync,0};
    PyObject* values[2] = {0,0};
    values[0] = __pyx_k_35;

    /* "plyvel/_plyvel.pyx":441
 *         return self.db.delete(self.prefix + key, sync=sync)
 * 
 *     def write_batch(self, *, transaction=False, sync=None):             # <<<<<<<<<<<<<<
 *         return WriteBatch(
 *             db=self.db, prefix=self.prefix, transaction=transaction, sync=sync)
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 0; index < 2 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "write_batch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_transaction = values[0];
    __pyx_v_sync = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_batch", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.write_batch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_8write_batch(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_transaction, __pyx_v_sync);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_8write_batch(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_transaction, PyObject *__pyx_v_sync) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write_batch", 0);

  /* "plyvel/_plyvel.pyx":442
 * 
 *     def write_batch(self, *, transaction=False, sync=None):
 *         return WriteBatch(             # <<<<<<<<<<<<<<
 *             db=self.db, prefix=self.prefix, transaction=transaction, sync=sync)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "plyvel/_plyvel.pyx":443
 *     def write_batch(self, *, transaction=False, sync=None):
 *         return WriteBatch(
 *             db=self.db, prefix=self.prefix, transaction=transaction, sync=sync)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self->db)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), ((PyObject *)__pyx_v_self->prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__transaction), __pyx_v_transaction) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__sync), __pyx_v_sync) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_WriteBatch)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.write_batch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_11__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_11__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_10__iter__(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":445
 *             db=self.db, prefix=self.prefix, transaction=transaction, sync=sync)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self.iterator()
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_10__iter__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "plyvel/_plyvel.pyx":446
 * 
 *     def __iter__(self):
 *         return self.iterator()             # <<<<<<<<<<<<<<
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__iterator); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __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 = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_13iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_12iterator[] = "PrefixedDB.iterator(self, *, reverse=False, start=None, stop=None, include_start=True, include_stop=False, prefix=None, include_key=True, include_value=True, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_13iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_include_start = 0;
  PyObject *__pyx_v_include_stop = 0;
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_include_key = 0;
  PyObject *__pyx_v_include_value = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reverse,&__pyx_n_s__start,&__pyx_n_s__stop,&__pyx_n_s__include_start,&__pyx_n_s__include_stop,&__pyx_n_s__prefix,&__pyx_n_s__include_key,&__pyx_n_s__include_value,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    values[0] = __pyx_k_36;

    /* "plyvel/_plyvel.pyx":448
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_37;
    values[4] = __pyx_k_38;

    /* "plyvel/_plyvel.pyx":449
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
    values[5] = ((PyObject *)Py_None);
    values[6] = __pyx_k_39;
    values[7] = __pyx_k_40;

    /* "plyvel/_plyvel.pyx":450
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
    values[8] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":451
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):             # <<<<<<<<<<<<<<
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 */
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 10)) {
        Py_ssize_t index;
        for (index = 0; index < 10 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "iterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_reverse = values[0];
    __pyx_v_start = values[1];
    __pyx_v_stop = values[2];
    __pyx_v_include_start = values[3];
    __pyx_v_include_stop = values[4];
    __pyx_v_prefix = values[5];
    __pyx_v_include_key = values[6];
    __pyx_v_include_value = values[7];
    __pyx_v_verify_checksums = values[8];
    __pyx_v_fill_cache = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterator", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.PrefixedDB.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_12iterator(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), __pyx_v_reverse, __pyx_v_start, __pyx_v_stop, __pyx_v_include_start, __pyx_v_include_stop, __pyx_v_prefix, __pyx_v_include_key, __pyx_v_include_value, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":448
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_12iterator(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iterator", 0);

  /* "plyvel/_plyvel.pyx":452
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 *         return Iterator(             # <<<<<<<<<<<<<<
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "plyvel/_plyvel.pyx":453
 *                  fill_cache=None):
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,             # <<<<<<<<<<<<<<
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self->db)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__key_prefix), ((PyObject *)__pyx_v_self->prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__reverse), __pyx_v_reverse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__start), __pyx_v_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":454
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,             # <<<<<<<<<<<<<<
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__stop), __pyx_v_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_start), __pyx_v_include_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_stop), __pyx_v_include_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":455
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,             # <<<<<<<<<<<<<<
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=None)
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), __pyx_v_prefix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_key), __pyx_v_include_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":456
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,             # <<<<<<<<<<<<<<
 *             fill_cache=fill_cache, snapshot=None)
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_value), __pyx_v_include_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__verify_checksums), __pyx_v_verify_checksums) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":457
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=None)             # <<<<<<<<<<<<<<
 * 
 *     def snapshot(self):
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__fill_cache), __pyx_v_fill_cache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__snapshot), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_Iterator)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_15snapshot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_14snapshot[] = "PrefixedDB.snapshot(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_15snapshot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("snapshot (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_14snapshot(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":459
 *             fill_cache=fill_cache, snapshot=None)
 * 
 *     def snapshot(self):             # <<<<<<<<<<<<<<
 *         return Snapshot(db=self.db, prefix=self.prefix)
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_14snapshot(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("snapshot", 0);

  /* "plyvel/_plyvel.pyx":460
 * 
 *     def snapshot(self):
 *         return Snapshot(db=self.db, prefix=self.prefix)             # <<<<<<<<<<<<<<
 * 
 *     def prefixed_db(self, bytes prefix not None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self->db)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), ((PyObject *)__pyx_v_self->prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_Snapshot)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.snapshot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_17prefixed_db(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10PrefixedDB_16prefixed_db[] = "PrefixedDB.prefixed_db(self, bytes prefix)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_17prefixed_db(PyObject *__pyx_v_self, PyObject *__pyx_v_prefix) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prefixed_db (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyBytes_Type), 0, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_16prefixed_db(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self), ((PyObject*)__pyx_v_prefix));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":462
 *         return Snapshot(db=self.db, prefix=self.prefix)
 * 
 *     def prefixed_db(self, bytes prefix not None):             # <<<<<<<<<<<<<<
 *         return PrefixedDB(db=self.db, prefix=self.prefix + prefix)
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_16prefixed_db(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self, PyObject *__pyx_v_prefix) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prefixed_db", 0);

  /* "plyvel/_plyvel.pyx":463
 * 
 *     def prefixed_db(self, bytes prefix not None):
 *         return PrefixedDB(db=self.db, prefix=self.prefix + prefix)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self->db)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_prefix)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_PrefixedDB)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.PrefixedDB.prefixed_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_2db_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_2db_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2db___get__(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":422
 * 
 * cdef class PrefixedDB:
 *     cdef readonly DB db             # <<<<<<<<<<<<<<
 *     cdef readonly bytes prefix
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_2db___get__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->db));
  __pyx_r = ((PyObject *)__pyx_v_self->db);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_6prefix_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_6prefix_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6prefix___get__(((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":423
 * cdef class PrefixedDB:
 *     cdef readonly DB db
 *     cdef readonly bytes prefix             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *, db, prefix):
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10PrefixedDB_6prefix___get__(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->prefix));
  __pyx_r = ((PyObject *)__pyx_v_self->prefix);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_1repair_db(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_repair_db[] = "repair_db(name, *, paranoid_checks=None, write_buffer_size=None, max_open_files=None, lru_cache_size=None, block_size=None, block_restart_interval=None, compression='snappy', int bloom_filter_bits=0, comparator=None, bytes comparator_name=None)";
static PyMethodDef __pyx_mdef_6plyvel_7_plyvel_1repair_db = {__Pyx_NAMESTR("repair_db"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_1repair_db, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_repair_db)};
static PyObject *__pyx_pw_6plyvel_7_plyvel_1repair_db(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  PyObject *__pyx_v_paranoid_checks = 0;
  PyObject *__pyx_v_write_buffer_size = 0;
  PyObject *__pyx_v_max_open_files = 0;
  PyObject *__pyx_v_lru_cache_size = 0;
  PyObject *__pyx_v_block_size = 0;
  PyObject *__pyx_v_block_restart_interval = 0;
  PyObject *__pyx_v_compression = 0;
  int __pyx_v_bloom_filter_bits;
  PyObject *__pyx_v_comparator = 0;
  PyObject *__pyx_v_comparator_name = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("repair_db (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__paranoid_checks,&__pyx_n_s__write_buffer_size,&__pyx_n_s__max_open_files,&__pyx_n_s__lru_cache_size,&__pyx_n_s__block_size,&__pyx_n_s_15,&__pyx_n_s__compression,&__pyx_n_s__bloom_filter_bits,&__pyx_n_s__comparator,&__pyx_n_s__comparator_name,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};

    /* "plyvel/_plyvel.pyx":466
 * 
 * 
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,             # <<<<<<<<<<<<<<
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":467
 * 
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,
 *               max_open_files=None, lru_cache_size=None, block_size=None,             # <<<<<<<<<<<<<<
 *               block_restart_interval=None, compression='snappy',
 *               int bloom_filter_bits=0, comparator=None,
 */
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":468
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',             # <<<<<<<<<<<<<<
 *               int bloom_filter_bits=0, comparator=None,
 *               bytes comparator_name=None):
 */
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)__pyx_n_s__snappy);

    /* "plyvel/_plyvel.pyx":469
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',
 *               int bloom_filter_bits=0, comparator=None,             # <<<<<<<<<<<<<<
 *               bytes comparator_name=None):
 *     cdef Options options = Options()
 */
    values[9] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":470
 *               block_restart_interval=None, compression='snappy',
 *               int bloom_filter_bits=0, comparator=None,
 *               bytes comparator_name=None):             # <<<<<<<<<<<<<<
 *     cdef Options options = Options()
 *     cdef Status st
 */
    values[10] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args > 0 && likely(kw_args <= 10)) {
        Py_ssize_t index;
        for (index = 1; index < 11 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "repair_db") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_name = values[0];
    __pyx_v_paranoid_checks = values[1];
    __pyx_v_write_buffer_size = values[2];
    __pyx_v_max_open_files = values[3];
    __pyx_v_lru_cache_size = values[4];
    __pyx_v_block_size = values[5];
    __pyx_v_block_restart_interval = values[6];
    __pyx_v_compression = values[7];
    if (values[8]) {
      __pyx_v_bloom_filter_bits = __Pyx_PyInt_AsInt(values[8]); if (unlikely((__pyx_v_bloom_filter_bits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_bloom_filter_bits = ((int)0);
    }
    __pyx_v_comparator = values[9];
    __pyx_v_comparator_name = ((PyObject*)values[10]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("repair_db", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.repair_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comparator_name), (&PyBytes_Type), 1, "comparator_name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_repair_db(__pyx_self, __pyx_v_name, __pyx_v_paranoid_checks, __pyx_v_write_buffer_size, __pyx_v_max_open_files, __pyx_v_lru_cache_size, __pyx_v_block_size, __pyx_v_block_restart_interval, __pyx_v_compression, __pyx_v_bloom_filter_bits, __pyx_v_comparator, __pyx_v_comparator_name);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":466
 * 
 * 
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,             # <<<<<<<<<<<<<<
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_repair_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_paranoid_checks, PyObject *__pyx_v_write_buffer_size, PyObject *__pyx_v_max_open_files, PyObject *__pyx_v_lru_cache_size, PyObject *__pyx_v_block_size, PyObject *__pyx_v_block_restart_interval, PyObject *__pyx_v_compression, int __pyx_v_bloom_filter_bits, PyObject *__pyx_v_comparator, PyObject *__pyx_v_comparator_name) {
  leveldb::Options __pyx_v_options;
  leveldb::Status __pyx_v_st;
  std::string __pyx_v_fsname;
  int __pyx_v_create_if_missing;
  int __pyx_v_error_if_exists;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  std::string __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("repair_db", 0);

  /* "plyvel/_plyvel.pyx":471
 *               int bloom_filter_bits=0, comparator=None,
 *               bytes comparator_name=None):
 *     cdef Options options = Options()             # <<<<<<<<<<<<<<
 *     cdef Status st
 *     cdef string fsname
 */
  __pyx_v_options = leveldb::Options();

  /* "plyvel/_plyvel.pyx":475
 *     cdef string fsname
 * 
 *     fsname = to_file_system_name(name)             # <<<<<<<<<<<<<<
 *     create_if_missing = False
 *     error_if_exists = True
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_6plyvel_7_plyvel_to_file_system_name(__pyx_v_name)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fsname = __pyx_t_2;

  /* "plyvel/_plyvel.pyx":476
 * 
 *     fsname = to_file_system_name(name)
 *     create_if_missing = False             # <<<<<<<<<<<<<<
 *     error_if_exists = True
 *     parse_options(
 */
  __pyx_v_create_if_missing = 0;

  /* "plyvel/_plyvel.pyx":477
 *     fsname = to_file_system_name(name)
 *     create_if_missing = False
 *     error_if_exists = True             # <<<<<<<<<<<<<<
 *     parse_options(
 *         &options, create_if_missing, error_if_exists, paranoid_checks,
 */
  __pyx_v_error_if_exists = 1;

  /* "plyvel/_plyvel.pyx":482
 *         write_buffer_size, max_open_files, lru_cache_size, block_size,
 *         block_restart_interval, compression, bloom_filter_bits, comparator,
 *         comparator_name)             # <<<<<<<<<<<<<<
 *     with nogil:
 *         st = RepairDB(fsname, options)
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_parse_options((&__pyx_v_options), __pyx_v_create_if_missing, __pyx_v_error_if_exists, __pyx_v_paranoid_checks, __pyx_v_write_buffer_size, __pyx_v_max_open_files, __pyx_v_lru_cache_size, __pyx_v_block_size, __pyx_v_block_restart_interval, __pyx_v_compression, __pyx_v_bloom_filter_bits, __pyx_v_comparator, __pyx_v_comparator_name); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":483
 *         block_restart_interval, compression, bloom_filter_bits, comparator,
 *         comparator_name)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = RepairDB(fsname, options)
 *     raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":484
 *         comparator_name)
 *     with nogil:
 *         st = RepairDB(fsname, options)             # <<<<<<<<<<<<<<
 *     raise_for_status(st)
 * 
 */
        __pyx_v_st = leveldb::RepairDB(__pyx_v_fsname, __pyx_v_options);
      }

      /* "plyvel/_plyvel.pyx":483
 *         block_restart_interval, compression, bloom_filter_bits, comparator,
 *         comparator_name)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = RepairDB(fsname, options)
 *     raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":485
 *     with nogil:
 *         st = RepairDB(fsname, options)
 *     raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.repair_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_3destroy_db(PyObject *__pyx_self, PyObject *__pyx_v_name); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_2destroy_db[] = "destroy_db(name)";
static PyMethodDef __pyx_mdef_6plyvel_7_plyvel_3destroy_db = {__Pyx_NAMESTR("destroy_db"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_3destroy_db, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2destroy_db)};
static PyObject *__pyx_pw_6plyvel_7_plyvel_3destroy_db(PyObject *__pyx_self, PyObject *__pyx_v_name) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_db (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_2destroy_db(__pyx_self, ((PyObject *)__pyx_v_name));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":488
 * 
 * 
 * def destroy_db(name):             # <<<<<<<<<<<<<<
 *     cdef Options options = Options()
 *     cdef Status st
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_2destroy_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) {
  leveldb::Options __pyx_v_options;
  leveldb::Status __pyx_v_st;
  std::string __pyx_v_fsname;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  std::string __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("destroy_db", 0);

  /* "plyvel/_plyvel.pyx":489
 * 
 * def destroy_db(name):
 *     cdef Options options = Options()             # <<<<<<<<<<<<<<
 *     cdef Status st
 *     cdef string fsname
 */
  __pyx_v_options = leveldb::Options();

  /* "plyvel/_plyvel.pyx":493
 *     cdef string fsname
 * 
 *     fsname = to_file_system_name(name)             # <<<<<<<<<<<<<<
 *     with nogil:
 *         st = DestroyDB(fsname, options)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_6plyvel_7_plyvel_to_file_system_name(__pyx_v_name)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fsname = __pyx_t_2;

  /* "plyvel/_plyvel.pyx":494
 * 
 *     fsname = to_file_system_name(name)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = DestroyDB(fsname, options)
 *     raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":495
 *     fsname = to_file_system_name(name)
 *     with nogil:
 *         st = DestroyDB(fsname, options)             # <<<<<<<<<<<<<<
 *     raise_for_status(st)
 * 
 */
        __pyx_v_st = leveldb::DestroyDB(__pyx_v_fsname, __pyx_v_options);
      }

      /* "plyvel/_plyvel.pyx":494
 * 
 *     fsname = to_file_system_name(name)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         st = DestroyDB(fsname, options)
 *     raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":496
 *     with nogil:
 *         st = DestroyDB(fsname, options)
 *     raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.destroy_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6plyvel_7_plyvel_10WriteBatch_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6plyvel_7_plyvel_10WriteBatch_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db = 0;
  PyObject *__pyx_v_prefix = 0;
  bool __pyx_v_transaction;
  PyObject *__pyx_v_sync = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__db,&__pyx_n_s__prefix,&__pyx_n_s__transaction,&__pyx_n_s__sync,0};
    PyObject* values[4] = {0,0,0,0};

    /* "plyvel/_plyvel.pyx":511
 *     cdef bool transaction
 * 
 *     def __init__(self, *, DB db not None, bytes prefix=None,             # <<<<<<<<<<<<<<
 *                  bool transaction=False, sync=None):
 *         self.db = db
 */
    values[1] = ((PyObject*)Py_None);

    /* "plyvel/_plyvel.pyx":512
 * 
 *     def __init__(self, *, DB db not None, bytes prefix=None,
 *                  bool transaction=False, sync=None):             # <<<<<<<<<<<<<<
 *         self.db = db
 *         self.prefix = prefix
 */
    values[3] = ((PyObject *)Py_None);
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__db)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (kw_args > 0 && likely(kw_args <= 3)) {
        Py_ssize_t index;
        for (index = 1; index < 4 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)values[0]);
    __pyx_v_prefix = ((PyObject*)values[1]);
    if (values[2]) {
      __pyx_v_transaction = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_transaction == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_transaction = ((bool)0);
    }
    __pyx_v_sync = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_db), __pyx_ptype_6plyvel_7_plyvel_DB, 0, "db", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyBytes_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch___init__(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self), __pyx_v_db, __pyx_v_prefix, __pyx_v_transaction, __pyx_v_sync);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":511
 *     cdef bool transaction
 * 
 *     def __init__(self, *, DB db not None, bytes prefix=None,             # <<<<<<<<<<<<<<
 *                  bool transaction=False, sync=None):
 *         self.db = db
 */

static int __pyx_pf_6plyvel_7_plyvel_10WriteBatch___init__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_prefix, bool __pyx_v_transaction, PyObject *__pyx_v_sync) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  bool __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "plyvel/_plyvel.pyx":513
 *     def __init__(self, *, DB db not None, bytes prefix=None,
 *                  bool transaction=False, sync=None):
 *         self.db = db             # <<<<<<<<<<<<<<
 *         self.prefix = prefix
 *         self.transaction = transaction
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_db));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_db));
  __Pyx_GOTREF(__pyx_v_self->db);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->db));
  __pyx_v_self->db = __pyx_v_db;

  /* "plyvel/_plyvel.pyx":514
 *                  bool transaction=False, sync=None):
 *         self.db = db
 *         self.prefix = prefix             # <<<<<<<<<<<<<<
 *         self.transaction = transaction
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix));
  __Pyx_GOTREF(__pyx_v_self->prefix);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->prefix));
  __pyx_v_self->prefix = __pyx_v_prefix;

  /* "plyvel/_plyvel.pyx":515
 *         self.db = db
 *         self.prefix = prefix
 *         self.transaction = transaction             # <<<<<<<<<<<<<<
 * 
 *         self.write_options = WriteOptions()
 */
  __pyx_v_self->transaction = __pyx_v_transaction;

  /* "plyvel/_plyvel.pyx":517
 *         self.transaction = transaction
 * 
 *         self.write_options = WriteOptions()             # <<<<<<<<<<<<<<
 *         if sync is not None:
 *             self.write_options.sync = sync
 */
  __pyx_v_self->write_options = leveldb::WriteOptions();

  /* "plyvel/_plyvel.pyx":518
 * 
 *         self.write_options = WriteOptions()
 *         if sync is not None:             # <<<<<<<<<<<<<<
 *             self.write_options.sync = sync
 * 
 */
  __pyx_t_1 = (__pyx_v_sync != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":519
 *         self.write_options = WriteOptions()
 *         if sync is not None:
 *             self.write_options.sync = sync             # <<<<<<<<<<<<<<
 * 
 *         self._write_batch = new leveldb.WriteBatch()
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_sync); if (unlikely((__pyx_t_2 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->write_options.sync = __pyx_t_2;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":521
 *             self.write_options.sync = sync
 * 
 *         self._write_batch = new leveldb.WriteBatch()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->_write_batch = new leveldb::WriteBatch();

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_6plyvel_7_plyvel_10WriteBatch_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_6plyvel_7_plyvel_10WriteBatch_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_6plyvel_7_plyvel_10WriteBatch_2__dealloc__(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "plyvel/_plyvel.pyx":523
 *         self._write_batch = new leveldb.WriteBatch()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         del self._write_batch
 * 
 */

static void __pyx_pf_6plyvel_7_plyvel_10WriteBatch_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "plyvel/_plyvel.pyx":524
 * 
 *     def __dealloc__(self):
 *         del self._write_batch             # <<<<<<<<<<<<<<
 * 
 *     def put(self, bytes key, bytes value):
 */
  delete __pyx_v_self->_write_batch;

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_5put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_4put[] = "WriteBatch.put(self, bytes key, bytes value)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_5put(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("put (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__value,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "put") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_value = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("put", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_4put(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self), __pyx_v_key, __pyx_v_value);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":526
 *         del self._write_batch
 * 
 *     def put(self, bytes key, bytes value):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_4put(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  leveldb::Slice __pyx_v_key_slice;
  leveldb::Slice __pyx_v_value_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("put", 0);
  __Pyx_INCREF(__pyx_v_key);

  /* "plyvel/_plyvel.pyx":527
 * 
 *     def put(self, bytes key, bytes value):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":528
 *     def put(self, bytes key, bytes value):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.prefix is not None:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":530
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         if self.prefix is not None:             # <<<<<<<<<<<<<<
 *             key = self.prefix + key
 * 
 */
  __pyx_t_1 = (__pyx_v_self->prefix != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":531
 * 
 *         if self.prefix is not None:
 *             key = self.prefix + key             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 */
    __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_v_key));
    __pyx_v_key = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":533
 *             key = self.prefix + key
 * 
 *         cdef Slice key_slice = Slice(key, len(key))             # <<<<<<<<<<<<<<
 *         cdef Slice value_slice = Slice(value, len(value))
 *         with nogil:
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":534
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 *         cdef Slice value_slice = Slice(value, len(value))             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self._write_batch.Put(key_slice, value_slice)
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_value)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_value) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_value)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_value_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":535
 *         cdef Slice key_slice = Slice(key, len(key))
 *         cdef Slice value_slice = Slice(value, len(value))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Put(key_slice, value_slice)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":536
 *         cdef Slice value_slice = Slice(value, len(value))
 *         with nogil:
 *             self._write_batch.Put(key_slice, value_slice)             # <<<<<<<<<<<<<<
 * 
 *     def delete(self, bytes key):
 */
        __pyx_v_self->_write_batch->Put(__pyx_v_key_slice, __pyx_v_value_slice);
      }

      /* "plyvel/_plyvel.pyx":535
 *         cdef Slice key_slice = Slice(key, len(key))
 *         cdef Slice value_slice = Slice(value, len(value))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Put(key_slice, value_slice)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.put", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_7delete(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_6delete[] = "WriteBatch.delete(self, bytes key)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_7delete(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_6delete(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self), ((PyObject*)__pyx_v_key));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":538
 *             self._write_batch.Put(key_slice, value_slice)
 * 
 *     def delete(self, bytes key):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_6delete(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_key) {
  leveldb::Slice __pyx_v_key_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("delete", 0);
  __Pyx_INCREF(__pyx_v_key);

  /* "plyvel/_plyvel.pyx":539
 * 
 *     def delete(self, bytes key):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":540
 *     def delete(self, bytes key):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.prefix is not None:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":542
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         if self.prefix is not None:             # <<<<<<<<<<<<<<
 *             key = self.prefix + key
 * 
 */
  __pyx_t_1 = (__pyx_v_self->prefix != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":543
 * 
 *         if self.prefix is not None:
 *             key = self.prefix + key             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 */
    __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_v_key));
    __pyx_v_key = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":545
 *             key = self.prefix + key
 * 
 *         cdef Slice key_slice = Slice(key, len(key))             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self._write_batch.Delete(key_slice)
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_key)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_key) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_key)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_key_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":546
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Delete(key_slice)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":547
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:
 *             self._write_batch.Delete(key_slice)             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
        __pyx_v_self->_write_batch->Delete(__pyx_v_key_slice);
      }

      /* "plyvel/_plyvel.pyx":546
 * 
 *         cdef Slice key_slice = Slice(key, len(key))
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Delete(key_slice)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.delete", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_8clear[] = "WriteBatch.clear(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_9clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_8clear(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":549
 *             self._write_batch.Delete(key_slice)
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_8clear(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clear", 0);

  /* "plyvel/_plyvel.pyx":550
 * 
 *     def clear(self):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":551
 *     def clear(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":553
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Clear()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":554
 * 
 *         with nogil:
 *             self._write_batch.Clear()             # <<<<<<<<<<<<<<
 * 
 *     def write(self):
 */
        __pyx_v_self->_write_batch->Clear();
      }

      /* "plyvel/_plyvel.pyx":553
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._write_batch.Clear()
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.clear", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_11write(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_10write[] = "WriteBatch.write(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_11write(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_10write(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":556
 *             self._write_batch.Clear()
 * 
 *     def write(self):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_10write(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self) {
  leveldb::Status __pyx_v_st;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("write", 0);

  /* "plyvel/_plyvel.pyx":557
 * 
 *     def write(self):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":558
 *     def write(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Status st
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":561
 * 
 *         cdef Status st
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self.db._db.Write(self.write_options, self._write_batch)
 *         raise_for_status(st)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":562
 *         cdef Status st
 *         with nogil:
 *             st = self.db._db.Write(self.write_options, self._write_batch)             # <<<<<<<<<<<<<<
 *         raise_for_status(st)
 * 
 */
        __pyx_v_st = __pyx_v_self->db->_db->Write(__pyx_v_self->write_options, __pyx_v_self->_write_batch);
      }

      /* "plyvel/_plyvel.pyx":561
 * 
 *         cdef Status st
 *         with nogil:             # <<<<<<<<<<<<<<
 *             st = self.db._db.Write(self.write_options, self._write_batch)
 *         raise_for_status(st)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":563
 *         with nogil:
 *             st = self.db._db.Write(self.write_options, self._write_batch)
 *         raise_for_status(st)             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_st); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_13__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_12__enter__[] = "WriteBatch.__enter__(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_13__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_12__enter__(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":565
 *         raise_for_status(st)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_12__enter__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "plyvel/_plyvel.pyx":566
 * 
 *     def __enter__(self):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":567
 *     def __enter__(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":569
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, exc_type, exc_val, exc_tb):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_15__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_10WriteBatch_14__exit__[] = "WriteBatch.__exit__(self, exc_type, exc_val, exc_tb)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_10WriteBatch_15__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_exc_type = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_val = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_tb = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__exc_type,&__pyx_n_s__exc_val,&__pyx_n_s__exc_tb,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_val)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_tb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_exc_type = values[0];
    __pyx_v_exc_val = values[1];
    __pyx_v_exc_tb = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_10WriteBatch_14__exit__(((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)__pyx_v_self), __pyx_v_exc_type, __pyx_v_exc_val, __pyx_v_exc_tb);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":571
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_val, exc_tb):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_10WriteBatch_14__exit__(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *__pyx_v_self, PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_val, CYTHON_UNUSED PyObject *__pyx_v_exc_tb) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "plyvel/_plyvel.pyx":572
 * 
 *     def __exit__(self, exc_type, exc_val, exc_tb):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":573
 *     def __exit__(self, exc_type, exc_val, exc_tb):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.transaction and exc_type is not None:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":575
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         if self.transaction and exc_type is not None:             # <<<<<<<<<<<<<<
 *             # Exception occurred in transaction; do not write the batch
 *             self.clear()
 */
  if (__pyx_v_self->transaction) {
    __pyx_t_1 = (__pyx_v_exc_type != Py_None);
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_v_self->transaction;
  }
  if (__pyx_t_3) {

    /* "plyvel/_plyvel.pyx":577
 *         if self.transaction and exc_type is not None:
 *             # Exception occurred in transaction; do not write the batch
 *             self.clear()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clear); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "plyvel/_plyvel.pyx":578
 *             # Exception occurred in transaction; do not write the batch
 *             self.clear()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.write()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":580
 *             return
 * 
 *         self.write()             # <<<<<<<<<<<<<<
 *         self.clear()
 * 
 */
  __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 = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":581
 * 
 *         self.write()
 *         self.clear()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__clear); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plyvel._plyvel.WriteBatch.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6plyvel_7_plyvel_8Iterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6plyvel_7_plyvel_8Iterator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db = 0;
  PyObject *__pyx_v_key_prefix = 0;
  bool __pyx_v_reverse;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  bool __pyx_v_include_start;
  bool __pyx_v_include_stop;
  PyObject *__pyx_v_prefix = 0;
  bool __pyx_v_include_key;
  bool __pyx_v_include_value;
  bool __pyx_v_verify_checksums;
  bool __pyx_v_fill_cache;
  struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_snapshot = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__db,&__pyx_n_s__key_prefix,&__pyx_n_s__reverse,&__pyx_n_s__start,&__pyx_n_s__stop,&__pyx_n_s__include_start,&__pyx_n_s__include_stop,&__pyx_n_s__prefix,&__pyx_n_s__include_key,&__pyx_n_s__include_value,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,&__pyx_n_s__snapshot,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__db)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key_prefix)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__key_prefix); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reverse)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__reverse); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__start); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stop)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__stop); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__include_start)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__include_start); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__include_stop)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__include_stop); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__prefix); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__include_key)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__include_key); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__include_value)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__include_value); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__verify_checksums)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__verify_checksums); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fill_cache)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__fill_cache); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__snapshot)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__snapshot); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)values[0]);
    __pyx_v_key_prefix = values[1];
    __pyx_v_reverse = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_reverse == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_start = ((PyObject*)values[3]);
    __pyx_v_stop = ((PyObject*)values[4]);
    __pyx_v_include_start = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_include_start == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_include_stop = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_include_stop == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_prefix = ((PyObject*)values[7]);
    __pyx_v_include_key = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_include_key == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_include_value = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_include_value == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_verify_checksums = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_verify_checksums == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_fill_cache = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_fill_cache == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_snapshot = ((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)values[12]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_db), __pyx_ptype_6plyvel_7_plyvel_DB, 0, "db", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start), (&PyBytes_Type), 1, "start", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stop), (&PyBytes_Type), 1, "stop", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyBytes_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_snapshot), __pyx_ptype_6plyvel_7_plyvel_Snapshot, 1, "snapshot", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator___init__(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self), __pyx_v_db, __pyx_v_key_prefix, __pyx_v_reverse, __pyx_v_start, __pyx_v_stop, __pyx_v_include_start, __pyx_v_include_stop, __pyx_v_prefix, __pyx_v_include_key, __pyx_v_include_value, __pyx_v_verify_checksums, __pyx_v_fill_cache, __pyx_v_snapshot);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":625
 *     cdef object __weakref__
 * 
 *     def __init__(self, *, DB db not None, key_prefix, bool reverse,             # <<<<<<<<<<<<<<
 *                  bytes start, bytes stop, bool include_start,
 *                  bool include_stop, bytes prefix, bool include_key,
 */

static int __pyx_pf_6plyvel_7_plyvel_8Iterator___init__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_key_prefix, bool __pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, bool __pyx_v_include_start, bool __pyx_v_include_stop, PyObject *__pyx_v_prefix, bool __pyx_v_include_key, bool __pyx_v_include_value, bool __pyx_v_verify_checksums, bool __pyx_v_fill_cache, struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_snapshot) {
  leveldb::ReadOptions __pyx_v_read_options;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  enum __pyx_t_6plyvel_7_plyvel_IteratorDirection __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  const char *__pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_INCREF(__pyx_v_stop);
  __Pyx_INCREF(__pyx_v_prefix);

  /* "plyvel/_plyvel.pyx":630
 *                  bool include_value, bool verify_checksums, bool fill_cache,
 *                  Snapshot snapshot):
 *         if db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":631
 *                  Snapshot snapshot):
 *         if db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.db = db
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":633
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         self.db = db             # <<<<<<<<<<<<<<
 *         self.comparator = <leveldb.Comparator*>db.options.comparator
 *         self.direction = FORWARD if not reverse else REVERSE
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_db));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_db));
  __Pyx_GOTREF(__pyx_v_self->db);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->db));
  __pyx_v_self->db = __pyx_v_db;

  /* "plyvel/_plyvel.pyx":634
 * 
 *         self.db = db
 *         self.comparator = <leveldb.Comparator*>db.options.comparator             # <<<<<<<<<<<<<<
 *         self.direction = FORWARD if not reverse else REVERSE
 * 
 */
  __pyx_v_self->comparator = ((leveldb::Comparator *)__pyx_v_db->options.comparator);

  /* "plyvel/_plyvel.pyx":635
 *         self.db = db
 *         self.comparator = <leveldb.Comparator*>db.options.comparator
 *         self.direction = FORWARD if not reverse else REVERSE             # <<<<<<<<<<<<<<
 * 
 *         if key_prefix is None:
 */
  if ((!__pyx_v_reverse)) {
    __pyx_t_3 = __pyx_e_6plyvel_7_plyvel_FORWARD;
  } else {
    __pyx_t_3 = __pyx_e_6plyvel_7_plyvel_REVERSE;
  }
  __pyx_v_self->direction = __pyx_t_3;

  /* "plyvel/_plyvel.pyx":637
 *         self.direction = FORWARD if not reverse else REVERSE
 * 
 *         if key_prefix is None:             # <<<<<<<<<<<<<<
 *             self.skip_key_bytes = 0
 *         else:
 */
  __pyx_t_1 = (__pyx_v_key_prefix == Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":638
 * 
 *         if key_prefix is None:
 *             self.skip_key_bytes = 0             # <<<<<<<<<<<<<<
 *         else:
 *             # This is an iterator on a PrefixedDB. Transform args so
 */
    __pyx_v_self->skip_key_bytes = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":642
 *             # This is an iterator on a PrefixedDB. Transform args so
 *             # that the database key prefix is taken into account.
 *             self.skip_key_bytes = len(key_prefix)             # <<<<<<<<<<<<<<
 *             if prefix is not None:
 *                 # Both database key prefix and prefix on the iterator
 */
    __pyx_t_4 = PyObject_Length(__pyx_v_key_prefix); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->skip_key_bytes = __pyx_t_4;

    /* "plyvel/_plyvel.pyx":643
 *             # that the database key prefix is taken into account.
 *             self.skip_key_bytes = len(key_prefix)
 *             if prefix is not None:             # <<<<<<<<<<<<<<
 *                 # Both database key prefix and prefix on the iterator
 *                 prefix = key_prefix + prefix
 */
    __pyx_t_1 = (__pyx_v_prefix != ((PyObject*)Py_None));
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":645
 *             if prefix is not None:
 *                 # Both database key prefix and prefix on the iterator
 *                 prefix = key_prefix + prefix             # <<<<<<<<<<<<<<
 *             else:
 *                 # Adapt start and stop keys to use the database key
 */
      __pyx_t_2 = PyNumber_Add(__pyx_v_key_prefix, ((PyObject *)__pyx_v_prefix)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __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 = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_prefix));
      __pyx_v_prefix = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "plyvel/_plyvel.pyx":649
 *                 # Adapt start and stop keys to use the database key
 *                 # prefix.
 *                 if start is None:             # <<<<<<<<<<<<<<
 *                     start = key_prefix
 *                     include_start = True
 */
      __pyx_t_1 = (__pyx_v_start == ((PyObject*)Py_None));
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":650
 *                 # prefix.
 *                 if start is None:
 *                     start = key_prefix             # <<<<<<<<<<<<<<
 *                     include_start = True
 *                 else:
 */
        if (!(likely(PyBytes_CheckExact(__pyx_v_key_prefix))||((__pyx_v_key_prefix) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key_prefix)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_INCREF(__pyx_v_key_prefix);
        __Pyx_DECREF(((PyObject *)__pyx_v_start));
        __pyx_v_start = ((PyObject*)__pyx_v_key_prefix);

        /* "plyvel/_plyvel.pyx":651
 *                 if start is None:
 *                     start = key_prefix
 *                     include_start = True             # <<<<<<<<<<<<<<
 *                 else:
 *                     start = key_prefix + start
 */
        __pyx_v_include_start = 1;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "plyvel/_plyvel.pyx":653
 *                     include_start = True
 *                 else:
 *                     start = key_prefix + start             # <<<<<<<<<<<<<<
 * 
 *                 if stop is None:
 */
        __pyx_t_2 = PyNumber_Add(__pyx_v_key_prefix, ((PyObject *)__pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __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 = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_start));
        __pyx_v_start = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L6:;

      /* "plyvel/_plyvel.pyx":655
 *                     start = key_prefix + start
 * 
 *                 if stop is None:             # <<<<<<<<<<<<<<
 *                     stop = bytes_increment(key_prefix)
 *                     include_stop = False
 */
      __pyx_t_1 = (__pyx_v_stop == ((PyObject*)Py_None));
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":656
 * 
 *                 if stop is None:
 *                     stop = bytes_increment(key_prefix)             # <<<<<<<<<<<<<<
 *                     include_stop = False
 *                 else:
 */
        if (!(likely(PyBytes_CheckExact(__pyx_v_key_prefix))||((__pyx_v_key_prefix) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_key_prefix)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = __pyx_v_key_prefix;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_5 = ((PyObject *)__pyx_f_6plyvel_7_plyvel_bytes_increment(((PyObject*)__pyx_t_2))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_stop));
        __pyx_v_stop = ((PyObject*)__pyx_t_5);
        __pyx_t_5 = 0;

        /* "plyvel/_plyvel.pyx":657
 *                 if stop is None:
 *                     stop = bytes_increment(key_prefix)
 *                     include_stop = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     stop = key_prefix + stop
 */
        __pyx_v_include_stop = 0;
        goto __pyx_L7;
      }
      /*else*/ {

        /* "plyvel/_plyvel.pyx":659
 *                     include_stop = False
 *                 else:
 *                     stop = key_prefix + stop             # <<<<<<<<<<<<<<
 * 
 *         if prefix is not None:
 */
        __pyx_t_5 = PyNumber_Add(__pyx_v_key_prefix, ((PyObject *)__pyx_v_stop)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_stop));
        __pyx_v_stop = ((PyObject*)__pyx_t_5);
        __pyx_t_5 = 0;
      }
      __pyx_L7:;
    }
    __pyx_L5:;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":661
 *                     stop = key_prefix + stop
 * 
 *         if prefix is not None:             # <<<<<<<<<<<<<<
 *             if start is not None or stop is not None:
 *                 raise TypeError(
 */
  __pyx_t_1 = (__pyx_v_prefix != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":662
 * 
 *         if prefix is not None:
 *             if start is not None or stop is not None:             # <<<<<<<<<<<<<<
 *                 raise TypeError(
 *                     "'prefix' cannot be used together with 'start' or 'stop'")
 */
    __pyx_t_1 = (__pyx_v_start != ((PyObject*)Py_None));
    if (!__pyx_t_1) {
      __pyx_t_6 = (__pyx_v_stop != ((PyObject*)Py_None));
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_1;
    }
    if (__pyx_t_7) {

      /* "plyvel/_plyvel.pyx":663
 *         if prefix is not None:
 *             if start is not None or stop is not None:
 *                 raise TypeError(             # <<<<<<<<<<<<<<
 *                     "'prefix' cannot be used together with 'start' or 'stop'")
 *             # Use prefix to construct start and stop keys, and ignore
 */
      __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "plyvel/_plyvel.pyx":667
 *             # Use prefix to construct start and stop keys, and ignore
 *             # include_start and include_stop args
 *             start = prefix             # <<<<<<<<<<<<<<
 *             stop = bytes_increment(prefix)
 *             include_start = True
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_prefix));
    __Pyx_DECREF(((PyObject *)__pyx_v_start));
    __pyx_v_start = __pyx_v_prefix;

    /* "plyvel/_plyvel.pyx":668
 *             # include_start and include_stop args
 *             start = prefix
 *             stop = bytes_increment(prefix)             # <<<<<<<<<<<<<<
 *             include_start = True
 *             include_stop = False
 */
    __pyx_t_5 = ((PyObject *)__pyx_f_6plyvel_7_plyvel_bytes_increment(__pyx_v_prefix)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_v_stop));
    __pyx_v_stop = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plyvel/_plyvel.pyx":669
 *             start = prefix
 *             stop = bytes_increment(prefix)
 *             include_start = True             # <<<<<<<<<<<<<<
 *             include_stop = False
 * 
 */
    __pyx_v_include_start = 1;

    /* "plyvel/_plyvel.pyx":670
 *             stop = bytes_increment(prefix)
 *             include_start = True
 *             include_stop = False             # <<<<<<<<<<<<<<
 * 
 *         if start is not None:
 */
    __pyx_v_include_stop = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "plyvel/_plyvel.pyx":672
 *             include_stop = False
 * 
 *         if start is not None:             # <<<<<<<<<<<<<<
 *             self.start = start
 *             self.start_slice = Slice(start, len(start))
 */
  __pyx_t_7 = (__pyx_v_start != ((PyObject*)Py_None));
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":673
 * 
 *         if start is not None:
 *             self.start = start             # <<<<<<<<<<<<<<
 *             self.start_slice = Slice(start, len(start))
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_start));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_start));
    __Pyx_GOTREF(__pyx_v_self->start);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->start));
    __pyx_v_self->start = __pyx_v_start;

    /* "plyvel/_plyvel.pyx":674
 *         if start is not None:
 *             self.start = start
 *             self.start_slice = Slice(start, len(start))             # <<<<<<<<<<<<<<
 * 
 *         if stop is not None:
 */
    __pyx_t_8 = PyBytes_AsString(((PyObject *)__pyx_v_start)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_start) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_start)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->start_slice = leveldb::Slice(__pyx_t_8, __pyx_t_4);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "plyvel/_plyvel.pyx":676
 *             self.start_slice = Slice(start, len(start))
 * 
 *         if stop is not None:             # <<<<<<<<<<<<<<
 *             self.stop = stop
 *             self.stop_slice = Slice(stop, len(stop))
 */
  __pyx_t_7 = (__pyx_v_stop != ((PyObject*)Py_None));
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":677
 * 
 *         if stop is not None:
 *             self.stop = stop             # <<<<<<<<<<<<<<
 *             self.stop_slice = Slice(stop, len(stop))
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_stop));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_stop));
    __Pyx_GOTREF(__pyx_v_self->stop);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->stop));
    __pyx_v_self->stop = __pyx_v_stop;

    /* "plyvel/_plyvel.pyx":678
 *         if stop is not None:
 *             self.stop = stop
 *             self.stop_slice = Slice(stop, len(stop))             # <<<<<<<<<<<<<<
 * 
 *         self.include_start = include_start
 */
    __pyx_t_8 = PyBytes_AsString(((PyObject *)__pyx_v_stop)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(((PyObject *)__pyx_v_stop) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_stop)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_self->stop_slice = leveldb::Slice(__pyx_t_8, __pyx_t_4);
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "plyvel/_plyvel.pyx":680
 *             self.stop_slice = Slice(stop, len(stop))
 * 
 *         self.include_start = include_start             # <<<<<<<<<<<<<<
 *         self.include_stop = include_stop
 *         self.include_key = include_key
 */
  __pyx_v_self->include_start = __pyx_v_include_start;

  /* "plyvel/_plyvel.pyx":681
 * 
 *         self.include_start = include_start
 *         self.include_stop = include_stop             # <<<<<<<<<<<<<<
 *         self.include_key = include_key
 *         self.include_value = include_value
 */
  __pyx_v_self->include_stop = __pyx_v_include_stop;

  /* "plyvel/_plyvel.pyx":682
 *         self.include_start = include_start
 *         self.include_stop = include_stop
 *         self.include_key = include_key             # <<<<<<<<<<<<<<
 *         self.include_value = include_value
 * 
 */
  __pyx_v_self->include_key = __pyx_v_include_key;

  /* "plyvel/_plyvel.pyx":683
 *         self.include_stop = include_stop
 *         self.include_key = include_key
 *         self.include_value = include_value             # <<<<<<<<<<<<<<
 * 
 *         cdef ReadOptions read_options
 */
  __pyx_v_self->include_value = __pyx_v_include_value;

  /* "plyvel/_plyvel.pyx":686
 * 
 *         cdef ReadOptions read_options
 *         if verify_checksums is not None:             # <<<<<<<<<<<<<<
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_verify_checksums); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = (__pyx_t_5 != Py_None);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":687
 *         cdef ReadOptions read_options
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums             # <<<<<<<<<<<<<<
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache
 */
    __pyx_v_read_options.verify_checksums = __pyx_v_verify_checksums;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "plyvel/_plyvel.pyx":688
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:             # <<<<<<<<<<<<<<
 *             read_options.fill_cache = fill_cache
 *         if snapshot is not None:
 */
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_fill_cache); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = (__pyx_t_5 != Py_None);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":689
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache             # <<<<<<<<<<<<<<
 *         if snapshot is not None:
 *             read_options.snapshot = snapshot._snapshot
 */
    __pyx_v_read_options.fill_cache = __pyx_v_fill_cache;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "plyvel/_plyvel.pyx":690
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache
 *         if snapshot is not None:             # <<<<<<<<<<<<<<
 *             read_options.snapshot = snapshot._snapshot
 * 
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_snapshot) != Py_None);
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":691
 *             read_options.fill_cache = fill_cache
 *         if snapshot is not None:
 *             read_options.snapshot = snapshot._snapshot             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_read_options.snapshot = __pyx_v_snapshot->_snapshot;
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "plyvel/_plyvel.pyx":693
 *             read_options.snapshot = snapshot._snapshot
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter = db._db.NewIterator(read_options)
 *         if self.direction == FORWARD:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":694
 * 
 *         with nogil:
 *             self._iter = db._db.NewIterator(read_options)             # <<<<<<<<<<<<<<
 *         if self.direction == FORWARD:
 *             self.seek_to_start()
 */
        __pyx_v_self->_iter = __pyx_v_db->_db->NewIterator(__pyx_v_read_options);
      }

      /* "plyvel/_plyvel.pyx":693
 *             read_options.snapshot = snapshot._snapshot
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter = db._db.NewIterator(read_options)
 *         if self.direction == FORWARD:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":695
 *         with nogil:
 *             self._iter = db._db.NewIterator(read_options)
 *         if self.direction == FORWARD:             # <<<<<<<<<<<<<<
 *             self.seek_to_start()
 *         else:
 */
  __pyx_t_7 = (__pyx_v_self->direction == __pyx_e_6plyvel_7_plyvel_FORWARD);
  if (__pyx_t_7) {

    /* "plyvel/_plyvel.pyx":696
 *             self._iter = db._db.NewIterator(read_options)
 *         if self.direction == FORWARD:
 *             self.seek_to_start()             # <<<<<<<<<<<<<<
 *         else:
 *             self.seek_to_stop()
 */
    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seek_to_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L18;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":698
 *             self.seek_to_start()
 *         else:
 *             self.seek_to_stop()             # <<<<<<<<<<<<<<
 * 
 *         db._register_iterator(self)
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seek_to_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L18:;

  /* "plyvel/_plyvel.pyx":700
 *             self.seek_to_stop()
 * 
 *         db._register_iterator(self)             # <<<<<<<<<<<<<<
 *         raise_for_status(self._iter.status())
 * 
 */
  __pyx_t_5 = __pyx_f_6plyvel_7_plyvel_2DB__register_iterator(__pyx_v_db, __pyx_v_self); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "plyvel/_plyvel.pyx":701
 * 
 *         db._register_iterator(self)
 *         raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 * 
 *     cdef close(self):
 */
  __pyx_t_9 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_stop);
  __Pyx_XDECREF(__pyx_v_prefix);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":703
 *         raise_for_status(self._iter.status())
 * 
 *     cdef close(self):             # <<<<<<<<<<<<<<
 *         # Note: this method is only for internal cleanups and hence not
 *         # accessible from Python.
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_close(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("close", 0);

  /* "plyvel/_plyvel.pyx":706
 *         # Note: this method is only for internal cleanups and hence not
 *         # accessible from Python.
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             # Already closed
 *             return
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":708
 *         if self._iter is NULL:
 *             # Already closed
 *             return             # <<<<<<<<<<<<<<
 * 
 *         del self._iter
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":710
 *             return
 * 
 *         del self._iter             # <<<<<<<<<<<<<<
 *         self._iter = NULL
 * 
 */
  delete __pyx_v_self->_iter;

  /* "plyvel/_plyvel.pyx":711
 * 
 *         del self._iter
 *         self._iter = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->_iter = NULL;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_6plyvel_7_plyvel_8Iterator_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_6plyvel_7_plyvel_8Iterator_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_6plyvel_7_plyvel_8Iterator_2__dealloc__(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "plyvel/_plyvel.pyx":713
 *         self._iter = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

static void __pyx_pf_6plyvel_7_plyvel_8Iterator_2__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "plyvel/_plyvel.pyx":714
 * 
 *     def __dealloc__(self):
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_t_1 = __pyx_f_6plyvel_7_plyvel_8Iterator_close(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_5__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_5__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_4__iter__(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":716
 *         self.close()
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_4__iter__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "plyvel/_plyvel.pyx":717
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     cdef object current(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":719
 *         return self
 * 
 *     cdef object current(self):             # <<<<<<<<<<<<<<
 *         """Return the current iterator key/value.
 * 
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_current(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  leveldb::Slice __pyx_v_key_slice;
  PyObject *__pyx_v_key = 0;
  leveldb::Slice __pyx_v_value_slice;
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("current", 0);

  /* "plyvel/_plyvel.pyx":732
 * 
 *         # Only build Python strings that will be returned
 *         if self.include_key:             # <<<<<<<<<<<<<<
 *             key_slice = self._iter.key()
 *             key = key_slice.data()[self.skip_key_bytes:key_slice.size()]
 */
  if (__pyx_v_self->include_key) {

    /* "plyvel/_plyvel.pyx":733
 *         # Only build Python strings that will be returned
 *         if self.include_key:
 *             key_slice = self._iter.key()             # <<<<<<<<<<<<<<
 *             key = key_slice.data()[self.skip_key_bytes:key_slice.size()]
 * 
 */
    __pyx_v_key_slice = __pyx_v_self->_iter->key();

    /* "plyvel/_plyvel.pyx":734
 *         if self.include_key:
 *             key_slice = self._iter.key()
 *             key = key_slice.data()[self.skip_key_bytes:key_slice.size()]             # <<<<<<<<<<<<<<
 * 
 *         if self.include_value:
 */
    __pyx_t_1 = PyBytes_FromStringAndSize(((const char*)__pyx_v_key_slice.data()) + __pyx_v_self->skip_key_bytes, __pyx_v_key_slice.size() - __pyx_v_self->skip_key_bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_v_key = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":736
 *             key = key_slice.data()[self.skip_key_bytes:key_slice.size()]
 * 
 *         if self.include_value:             # <<<<<<<<<<<<<<
 *             value_slice = self._iter.value()
 *             value = value_slice.data()[:value_slice.size()]
 */
  if (__pyx_v_self->include_value) {

    /* "plyvel/_plyvel.pyx":737
 * 
 *         if self.include_value:
 *             value_slice = self._iter.value()             # <<<<<<<<<<<<<<
 *             value = value_slice.data()[:value_slice.size()]
 * 
 */
    __pyx_v_value_slice = __pyx_v_self->_iter->value();

    /* "plyvel/_plyvel.pyx":738
 *         if self.include_value:
 *             value_slice = self._iter.value()
 *             value = value_slice.data()[:value_slice.size()]             # <<<<<<<<<<<<<<
 * 
 *         if self.include_key and self.include_value:
 */
    __pyx_t_1 = PyBytes_FromStringAndSize(((const char*)__pyx_v_value_slice.data()) + 0, __pyx_v_value_slice.size() - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_v_value = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":740
 *             value = value_slice.data()[:value_slice.size()]
 * 
 *         if self.include_key and self.include_value:             # <<<<<<<<<<<<<<
 *             return (key, value)
 *         if self.include_key:
 */
  if (__pyx_v_self->include_key) {
    __pyx_t_2 = __pyx_v_self->include_value;
  } else {
    __pyx_t_2 = __pyx_v_self->include_key;
  }
  if (__pyx_t_2) {

    /* "plyvel/_plyvel.pyx":741
 * 
 *         if self.include_key and self.include_value:
 *             return (key, value)             # <<<<<<<<<<<<<<
 *         if self.include_key:
 *             return key
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(!__pyx_v_key)) { __Pyx_RaiseUnboundLocalError("key"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_v_value)) { __Pyx_RaiseUnboundLocalError("value"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __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 = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_key));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_key));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_key));
    __Pyx_INCREF(((PyObject *)__pyx_v_value));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_value));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_value));
    __pyx_r = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":742
 *         if self.include_key and self.include_value:
 *             return (key, value)
 *         if self.include_key:             # <<<<<<<<<<<<<<
 *             return key
 *         if self.include_value:
 */
  if (__pyx_v_self->include_key) {

    /* "plyvel/_plyvel.pyx":743
 *             return (key, value)
 *         if self.include_key:
 *             return key             # <<<<<<<<<<<<<<
 *         if self.include_value:
 *             return value
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(!__pyx_v_key)) { __Pyx_RaiseUnboundLocalError("key"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __Pyx_INCREF(((PyObject *)__pyx_v_key));
    __pyx_r = ((PyObject *)__pyx_v_key);
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "plyvel/_plyvel.pyx":744
 *         if self.include_key:
 *             return key
 *         if self.include_value:             # <<<<<<<<<<<<<<
 *             return value
 *         return None
 */
  if (__pyx_v_self->include_value) {

    /* "plyvel/_plyvel.pyx":745
 *             return key
 *         if self.include_value:
 *             return value             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(!__pyx_v_value)) { __Pyx_RaiseUnboundLocalError("value"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __Pyx_INCREF(((PyObject *)__pyx_v_value));
    __pyx_r = ((PyObject *)__pyx_v_value);
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "plyvel/_plyvel.pyx":746
 *         if self.include_value:
 *             return value
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.current", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_7__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Iterator_6__next__[] = "Return the next iterator entry.\n\n        Note: Cython will also create a .next() method that does the\n        same as this method.\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_6plyvel_7_plyvel_8Iterator_6__next__;
#endif
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_7__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_6__next__(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":748
 *         return None
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """Return the next iterator entry.
 * 
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_6__next__(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "plyvel/_plyvel.pyx":754
 *         same as this method.
 *         """
 *         if self.direction == FORWARD:             # <<<<<<<<<<<<<<
 *             return self.real_next()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->direction == __pyx_e_6plyvel_7_plyvel_FORWARD);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":755
 *         """
 *         if self.direction == FORWARD:
 *             return self.real_next()             # <<<<<<<<<<<<<<
 *         else:
 *             return self.real_prev()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_real_next(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":757
 *             return self.real_next()
 *         else:
 *             return self.real_prev()             # <<<<<<<<<<<<<<
 * 
 *     def prev(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_real_prev(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_9prev(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Iterator_8prev[] = "Iterator.prev(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_9prev(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prev (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_8prev(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":759
 *             return self.real_prev()
 * 
 *     def prev(self):             # <<<<<<<<<<<<<<
 *         if self.direction == FORWARD:
 *             return self.real_prev()
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_8prev(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("prev", 0);

  /* "plyvel/_plyvel.pyx":760
 * 
 *     def prev(self):
 *         if self.direction == FORWARD:             # <<<<<<<<<<<<<<
 *             return self.real_prev()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->direction == __pyx_e_6plyvel_7_plyvel_FORWARD);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":761
 *     def prev(self):
 *         if self.direction == FORWARD:
 *             return self.real_prev()             # <<<<<<<<<<<<<<
 *         else:
 *             return self.real_next()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_real_prev(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":763
 *             return self.real_prev()
 *         else:
 *             return self.real_next()             # <<<<<<<<<<<<<<
 * 
 *     cdef real_next(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_real_next(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.prev", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":765
 *             return self.real_next()
 * 
 *     cdef real_next(self):             # <<<<<<<<<<<<<<
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_real_next(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  long __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  long __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("real_next", 0);

  /* "plyvel/_plyvel.pyx":766
 * 
 *     cdef real_next(self):
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":767
 *     cdef real_next(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.state == IN_BETWEEN:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":769
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         if self.state == IN_BETWEEN:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self._iter.Next()
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_IN_BETWEEN);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":770
 * 
 *         if self.state == IN_BETWEEN:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._iter.Next()
 *             if not self._iter.Valid():
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "plyvel/_plyvel.pyx":771
 *         if self.state == IN_BETWEEN:
 *             with nogil:
 *                 self._iter.Next()             # <<<<<<<<<<<<<<
 *             if not self._iter.Valid():
 *                 self.state = AFTER_STOP
 */
          __pyx_v_self->_iter->Next();
        }

        /* "plyvel/_plyvel.pyx":770
 * 
 *         if self.state == IN_BETWEEN:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._iter.Next()
 *             if not self._iter.Valid():
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "plyvel/_plyvel.pyx":772
 *             with nogil:
 *                 self._iter.Next()
 *             if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                 self.state = AFTER_STOP
 *                 raise StopIteration
 */
    __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":773
 *                 self._iter.Next()
 *             if not self._iter.Valid():
 *                 self.state = AFTER_STOP             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 */
      __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_AFTER_STOP;

      /* "plyvel/_plyvel.pyx":774
 *             if not self._iter.Valid():
 *                 self.state = AFTER_STOP
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             self.state = IN_BETWEEN
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":775
 *                 self.state = AFTER_STOP
 *                 raise StopIteration
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:             # <<<<<<<<<<<<<<
 *             self.state = IN_BETWEEN
 *         elif self.state == BEFORE_START:
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_IN_BETWEEN_ALREADY_POSITIONED);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":776
 *                 raise StopIteration
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             self.state = IN_BETWEEN             # <<<<<<<<<<<<<<
 *         elif self.state == BEFORE_START:
 *             if self.start is None:
 */
    __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_IN_BETWEEN;
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":777
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             self.state = IN_BETWEEN
 *         elif self.state == BEFORE_START:             # <<<<<<<<<<<<<<
 *             if self.start is None:
 *                 with nogil:
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_BEFORE_START);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":778
 *             self.state = IN_BETWEEN
 *         elif self.state == BEFORE_START:
 *             if self.start is None:             # <<<<<<<<<<<<<<
 *                 with nogil:
 *                     self._iter.SeekToFirst()
 */
    __pyx_t_1 = (__pyx_v_self->start == ((PyObject*)Py_None));
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":779
 *         elif self.state == BEFORE_START:
 *             if self.start is None:
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.SeekToFirst()
 *             else:
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save = NULL;
          #endif
          Py_UNBLOCK_THREADS
          /*try:*/ {

            /* "plyvel/_plyvel.pyx":780
 *             if self.start is None:
 *                 with nogil:
 *                     self._iter.SeekToFirst()             # <<<<<<<<<<<<<<
 *             else:
 *                 with nogil:
 */
            __pyx_v_self->_iter->SeekToFirst();
          }

          /* "plyvel/_plyvel.pyx":779
 *         elif self.state == BEFORE_START:
 *             if self.start is None:
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.SeekToFirst()
 *             else:
 */
          /*finally:*/ {
            Py_BLOCK_THREADS
          }
      }
      goto __pyx_L9;
    }
    /*else*/ {

      /* "plyvel/_plyvel.pyx":782
 *                     self._iter.SeekToFirst()
 *             else:
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Seek(self.start_slice)
 *             if not self._iter.Valid():
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save = NULL;
          #endif
          Py_UNBLOCK_THREADS
          /*try:*/ {

            /* "plyvel/_plyvel.pyx":783
 *             else:
 *                 with nogil:
 *                     self._iter.Seek(self.start_slice)             # <<<<<<<<<<<<<<
 *             if not self._iter.Valid():
 *                 # Iterator is empty
 */
            __pyx_v_self->_iter->Seek(__pyx_v_self->start_slice);
          }

          /* "plyvel/_plyvel.pyx":782
 *                     self._iter.SeekToFirst()
 *             else:
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Seek(self.start_slice)
 *             if not self._iter.Valid():
 */
          /*finally:*/ {
            Py_BLOCK_THREADS
          }
      }
    }
    __pyx_L9:;

    /* "plyvel/_plyvel.pyx":784
 *                 with nogil:
 *                     self._iter.Seek(self.start_slice)
 *             if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                 # Iterator is empty
 *                 raise StopIteration
 */
    __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":786
 *             if not self._iter.Valid():
 *                 # Iterator is empty
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             if self.start is not None and not self.include_start:
 *                 # Start key is excluded, so skip past it
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "plyvel/_plyvel.pyx":787
 *                 # Iterator is empty
 *                 raise StopIteration
 *             if self.start is not None and not self.include_start:             # <<<<<<<<<<<<<<
 *                 # Start key is excluded, so skip past it
 *                 with nogil:
 */
    __pyx_t_1 = (__pyx_v_self->start != ((PyObject*)Py_None));
    if (__pyx_t_1) {
      __pyx_t_3 = (!__pyx_v_self->include_start);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_1;
    }
    if (__pyx_t_4) {

      /* "plyvel/_plyvel.pyx":789
 *             if self.start is not None and not self.include_start:
 *                 # Start key is excluded, so skip past it
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Next()
 *                 if not self._iter.Valid():
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save = NULL;
          #endif
          Py_UNBLOCK_THREADS
          /*try:*/ {

            /* "plyvel/_plyvel.pyx":790
 *                 # Start key is excluded, so skip past it
 *                 with nogil:
 *                     self._iter.Next()             # <<<<<<<<<<<<<<
 *                 if not self._iter.Valid():
 *                     raise StopIteration
 */
            __pyx_v_self->_iter->Next();
          }

          /* "plyvel/_plyvel.pyx":789
 *             if self.start is not None and not self.include_start:
 *                 # Start key is excluded, so skip past it
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Next()
 *                 if not self._iter.Valid():
 */
          /*finally:*/ {
            Py_BLOCK_THREADS
          }
      }

      /* "plyvel/_plyvel.pyx":791
 *                 with nogil:
 *                     self._iter.Next()
 *                 if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                     raise StopIteration
 *             self.state = IN_BETWEEN
 */
      __pyx_t_4 = (!__pyx_v_self->_iter->Valid());
      if (__pyx_t_4) {

        /* "plyvel/_plyvel.pyx":792
 *                     self._iter.Next()
 *                 if not self._iter.Valid():
 *                     raise StopIteration             # <<<<<<<<<<<<<<
 *             self.state = IN_BETWEEN
 *         elif self.state == AFTER_STOP:
 */
        __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L21;
      }
      __pyx_L21:;
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "plyvel/_plyvel.pyx":793
 *                 if not self._iter.Valid():
 *                     raise StopIteration
 *             self.state = IN_BETWEEN             # <<<<<<<<<<<<<<
 *         elif self.state == AFTER_STOP:
 *             raise StopIteration
 */
    __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_IN_BETWEEN;
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":794
 *                     raise StopIteration
 *             self.state = IN_BETWEEN
 *         elif self.state == AFTER_STOP:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 * 
 */
  __pyx_t_4 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_AFTER_STOP);
  if (__pyx_t_4) {

    /* "plyvel/_plyvel.pyx":795
 *             self.state = IN_BETWEEN
 *         elif self.state == AFTER_STOP:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         raise_for_status(self._iter.status())
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":797
 *             raise StopIteration
 * 
 *         raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 * 
 *         # Check range boundaries
 */
  __pyx_t_5 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":800
 * 
 *         # Check range boundaries
 *         if self.stop is not None:             # <<<<<<<<<<<<<<
 *             n = 1 if self.include_stop else 0
 *             if self.comparator.Compare(self._iter.key(), self.stop_slice) >= n:
 */
  __pyx_t_4 = (__pyx_v_self->stop != ((PyObject*)Py_None));
  if (__pyx_t_4) {

    /* "plyvel/_plyvel.pyx":801
 *         # Check range boundaries
 *         if self.stop is not None:
 *             n = 1 if self.include_stop else 0             # <<<<<<<<<<<<<<
 *             if self.comparator.Compare(self._iter.key(), self.stop_slice) >= n:
 *                 self.state = AFTER_STOP
 */
    if (__pyx_v_self->include_stop) {
      __pyx_t_6 = 1;
    } else {
      __pyx_t_6 = 0;
    }
    __pyx_v_n = __pyx_t_6;

    /* "plyvel/_plyvel.pyx":802
 *         if self.stop is not None:
 *             n = 1 if self.include_stop else 0
 *             if self.comparator.Compare(self._iter.key(), self.stop_slice) >= n:             # <<<<<<<<<<<<<<
 *                 self.state = AFTER_STOP
 *                 raise StopIteration
 */
    __pyx_t_4 = (__pyx_v_self->comparator->Compare(__pyx_v_self->_iter->key(), __pyx_v_self->stop_slice) >= __pyx_v_n);
    if (__pyx_t_4) {

      /* "plyvel/_plyvel.pyx":803
 *             n = 1 if self.include_stop else 0
 *             if self.comparator.Compare(self._iter.key(), self.stop_slice) >= n:
 *                 self.state = AFTER_STOP             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 * 
 */
      __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_AFTER_STOP;

      /* "plyvel/_plyvel.pyx":804
 *             if self.comparator.Compare(self._iter.key(), self.stop_slice) >= n:
 *                 self.state = AFTER_STOP
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 * 
 *         return self.current()
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L23;
    }
    __pyx_L23:;
    goto __pyx_L22;
  }
  __pyx_L22:;

  /* "plyvel/_plyvel.pyx":806
 *                 raise StopIteration
 * 
 *         return self.current()             # <<<<<<<<<<<<<<
 * 
 *     cdef real_prev(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_current(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.real_next", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":808
 *         return self.current()
 * 
 *     cdef real_prev(self):             # <<<<<<<<<<<<<<
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_f_6plyvel_7_plyvel_8Iterator_real_prev(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_v_out = NULL;
  long __pyx_v_n;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  long __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("real_prev", 0);

  /* "plyvel/_plyvel.pyx":809
 * 
 *     cdef real_prev(self):
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":810
 *     cdef real_prev(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.state == IN_BETWEEN:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":812
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         if self.state == IN_BETWEEN:             # <<<<<<<<<<<<<<
 *             pass
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_IN_BETWEEN);
  if (__pyx_t_1) {
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":814
 *         if self.state == IN_BETWEEN:
 *             pass
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:             # <<<<<<<<<<<<<<
 *             assert self._iter.Valid()
 *             with nogil:
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_IN_BETWEEN_ALREADY_POSITIONED);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":815
 *             pass
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             assert self._iter.Valid()             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 self._iter.Prev()
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!__pyx_v_self->_iter->Valid())) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "plyvel/_plyvel.pyx":816
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             assert self._iter.Valid()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._iter.Prev()
 *             if not self._iter.Valid():
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "plyvel/_plyvel.pyx":817
 *             assert self._iter.Valid()
 *             with nogil:
 *                 self._iter.Prev()             # <<<<<<<<<<<<<<
 *             if not self._iter.Valid():
 *                 # The .seek() resulted in the first key in the database
 */
          __pyx_v_self->_iter->Prev();
        }

        /* "plyvel/_plyvel.pyx":816
 *         elif self.state == IN_BETWEEN_ALREADY_POSITIONED:
 *             assert self._iter.Valid()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 self._iter.Prev()
 *             if not self._iter.Valid():
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "plyvel/_plyvel.pyx":818
 *             with nogil:
 *                 self._iter.Prev()
 *             if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                 # The .seek() resulted in the first key in the database
 *                 self.state = BEFORE_START
 */
    __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":820
 *             if not self._iter.Valid():
 *                 # The .seek() resulted in the first key in the database
 *                 self.state = BEFORE_START             # <<<<<<<<<<<<<<
 *                 raise StopIteration
 *             raise_for_status(self._iter.status())
 */
      __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_BEFORE_START;

      /* "plyvel/_plyvel.pyx":821
 *                 # The .seek() resulted in the first key in the database
 *                 self.state = BEFORE_START
 *                 raise StopIteration             # <<<<<<<<<<<<<<
 *             raise_for_status(self._iter.status())
 *         elif self.state == BEFORE_START:
 */
      __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "plyvel/_plyvel.pyx":822
 *                 self.state = BEFORE_START
 *                 raise StopIteration
 *             raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 *         elif self.state == BEFORE_START:
 *             raise StopIteration
 */
    __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":823
 *                 raise StopIteration
 *             raise_for_status(self._iter.status())
 *         elif self.state == BEFORE_START:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         elif self.state == AFTER_STOP:
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_BEFORE_START);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":824
 *             raise_for_status(self._iter.status())
 *         elif self.state == BEFORE_START:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         elif self.state == AFTER_STOP:
 *             if self.stop is None:
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }

  /* "plyvel/_plyvel.pyx":825
 *         elif self.state == BEFORE_START:
 *             raise StopIteration
 *         elif self.state == AFTER_STOP:             # <<<<<<<<<<<<<<
 *             if self.stop is None:
 *                 # No stop key, seek to last entry
 */
  __pyx_t_1 = (__pyx_v_self->state == __pyx_e_6plyvel_7_plyvel_AFTER_STOP);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":826
 *             raise StopIteration
 *         elif self.state == AFTER_STOP:
 *             if self.stop is None:             # <<<<<<<<<<<<<<
 *                 # No stop key, seek to last entry
 *                 with nogil:
 */
    __pyx_t_1 = (__pyx_v_self->stop == ((PyObject*)Py_None));
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":828
 *             if self.stop is None:
 *                 # No stop key, seek to last entry
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.SeekToLast()
 *                 if not self._iter.Valid():
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save = NULL;
          #endif
          Py_UNBLOCK_THREADS
          /*try:*/ {

            /* "plyvel/_plyvel.pyx":829
 *                 # No stop key, seek to last entry
 *                 with nogil:
 *                     self._iter.SeekToLast()             # <<<<<<<<<<<<<<
 *                 if not self._iter.Valid():
 *                     # Iterator is empty
 */
            __pyx_v_self->_iter->SeekToLast();
          }

          /* "plyvel/_plyvel.pyx":828
 *             if self.stop is None:
 *                 # No stop key, seek to last entry
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.SeekToLast()
 *                 if not self._iter.Valid():
 */
          /*finally:*/ {
            Py_BLOCK_THREADS
          }
      }

      /* "plyvel/_plyvel.pyx":830
 *                 with nogil:
 *                     self._iter.SeekToLast()
 *                 if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                     # Iterator is empty
 *                     raise StopIteration
 */
      __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":832
 *                 if not self._iter.Valid():
 *                     # Iterator is empty
 *                     raise StopIteration             # <<<<<<<<<<<<<<
 *                 raise_for_status(self._iter.status())
 *             else:
 */
        __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "plyvel/_plyvel.pyx":833
 *                     # Iterator is empty
 *                     raise StopIteration
 *                 raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 *             else:
 *                 # Seek to stop key
 */
      __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    /*else*/ {

      /* "plyvel/_plyvel.pyx":836
 *             else:
 *                 # Seek to stop key
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Seek(self.stop_slice)
 *                 if not self._iter.Valid():
 */
      {
          #ifdef WITH_THREAD
          PyThreadState *_save = NULL;
          #endif
          Py_UNBLOCK_THREADS
          /*try:*/ {

            /* "plyvel/_plyvel.pyx":837
 *                 # Seek to stop key
 *                 with nogil:
 *                     self._iter.Seek(self.stop_slice)             # <<<<<<<<<<<<<<
 *                 if not self._iter.Valid():
 *                     # Iterator is empty
 */
            __pyx_v_self->_iter->Seek(__pyx_v_self->stop_slice);
          }

          /* "plyvel/_plyvel.pyx":836
 *             else:
 *                 # Seek to stop key
 *                 with nogil:             # <<<<<<<<<<<<<<
 *                     self._iter.Seek(self.stop_slice)
 *                 if not self._iter.Valid():
 */
          /*finally:*/ {
            Py_BLOCK_THREADS
          }
      }

      /* "plyvel/_plyvel.pyx":838
 *                 with nogil:
 *                     self._iter.Seek(self.stop_slice)
 *                 if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                     # Iterator is empty
 *                     raise StopIteration
 */
      __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":840
 *                 if not self._iter.Valid():
 *                     # Iterator is empty
 *                     raise StopIteration             # <<<<<<<<<<<<<<
 *                 # Move one step back if stop is exclusive
 *                 if not self.include_stop:
 */
        __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "plyvel/_plyvel.pyx":842
 *                     raise StopIteration
 *                 # Move one step back if stop is exclusive
 *                 if not self.include_stop:             # <<<<<<<<<<<<<<
 *                     with nogil:
 *                         self._iter.Prev()
 */
      __pyx_t_1 = (!__pyx_v_self->include_stop);
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":843
 *                 # Move one step back if stop is exclusive
 *                 if not self.include_stop:
 *                     with nogil:             # <<<<<<<<<<<<<<
 *                         self._iter.Prev()
 *                     if not self._iter.Valid():
 */
        {
            #ifdef WITH_THREAD
            PyThreadState *_save = NULL;
            #endif
            Py_UNBLOCK_THREADS
            /*try:*/ {

              /* "plyvel/_plyvel.pyx":844
 *                 if not self.include_stop:
 *                     with nogil:
 *                         self._iter.Prev()             # <<<<<<<<<<<<<<
 *                     if not self._iter.Valid():
 *                         raise StopIteration
 */
              __pyx_v_self->_iter->Prev();
            }

            /* "plyvel/_plyvel.pyx":843
 *                 # Move one step back if stop is exclusive
 *                 if not self.include_stop:
 *                     with nogil:             # <<<<<<<<<<<<<<
 *                         self._iter.Prev()
 *                     if not self._iter.Valid():
 */
            /*finally:*/ {
              Py_BLOCK_THREADS
            }
        }

        /* "plyvel/_plyvel.pyx":845
 *                     with nogil:
 *                         self._iter.Prev()
 *                     if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *                         raise StopIteration
 *                 raise_for_status(self._iter.status())
 */
        __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
        if (__pyx_t_1) {

          /* "plyvel/_plyvel.pyx":846
 *                         self._iter.Prev()
 *                     if not self._iter.Valid():
 *                         raise StopIteration             # <<<<<<<<<<<<<<
 *                 raise_for_status(self._iter.status())
 * 
 */
          __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L22;
        }
        __pyx_L22:;
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "plyvel/_plyvel.pyx":847
 *                     if not self._iter.Valid():
 *                         raise StopIteration
 *                 raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 * 
 *         # Unlike .next(), first obtain the value, then move the iterator
 */
      __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L9:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":852
 *         # pointer (not the other way around), so that repeatedly calling
 *         # .prev() and .next() will work as designed.
 *         out = self.current()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self._iter.Prev()
 */
  __pyx_t_2 = __pyx_f_6plyvel_7_plyvel_8Iterator_current(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_out = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":853
 *         # .prev() and .next() will work as designed.
 *         out = self.current()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter.Prev()
 *         if not self._iter.Valid():
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":854
 *         out = self.current()
 *         with nogil:
 *             self._iter.Prev()             # <<<<<<<<<<<<<<
 *         if not self._iter.Valid():
 *             # Moved before the first key in the database
 */
        __pyx_v_self->_iter->Prev();
      }

      /* "plyvel/_plyvel.pyx":853
 *         # .prev() and .next() will work as designed.
 *         out = self.current()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter.Prev()
 *         if not self._iter.Valid():
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":855
 *         with nogil:
 *             self._iter.Prev()
 *         if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *             # Moved before the first key in the database
 *             self.state = BEFORE_START
 */
  __pyx_t_1 = (!__pyx_v_self->_iter->Valid());
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":857
 *         if not self._iter.Valid():
 *             # Moved before the first key in the database
 *             self.state = BEFORE_START             # <<<<<<<<<<<<<<
 *         else:
 *             if self.start is None:
 */
    __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_BEFORE_START;
    goto __pyx_L26;
  }
  /*else*/ {

    /* "plyvel/_plyvel.pyx":859
 *             self.state = BEFORE_START
 *         else:
 *             if self.start is None:             # <<<<<<<<<<<<<<
 *                 # Iterator is valid
 *                 self.state = IN_BETWEEN
 */
    __pyx_t_1 = (__pyx_v_self->start == ((PyObject*)Py_None));
    if (__pyx_t_1) {

      /* "plyvel/_plyvel.pyx":861
 *             if self.start is None:
 *                 # Iterator is valid
 *                 self.state = IN_BETWEEN             # <<<<<<<<<<<<<<
 *             else:
 *                 # Check range boundaries
 */
      __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_IN_BETWEEN;
      goto __pyx_L27;
    }
    /*else*/ {

      /* "plyvel/_plyvel.pyx":864
 *             else:
 *                 # Check range boundaries
 *                 n = 0 if self.include_start else 1             # <<<<<<<<<<<<<<
 *                 if self.comparator.Compare(
 *                         self._iter.key(), self.start_slice) >= n:
 */
      if (__pyx_v_self->include_start) {
        __pyx_t_4 = 0;
      } else {
        __pyx_t_4 = 1;
      }
      __pyx_v_n = __pyx_t_4;

      /* "plyvel/_plyvel.pyx":866
 *                 n = 0 if self.include_start else 1
 *                 if self.comparator.Compare(
 *                         self._iter.key(), self.start_slice) >= n:             # <<<<<<<<<<<<<<
 *                     # Iterator is valid and within range boundaries
 *                     self.state = IN_BETWEEN
 */
      __pyx_t_1 = (__pyx_v_self->comparator->Compare(__pyx_v_self->_iter->key(), __pyx_v_self->start_slice) >= __pyx_v_n);
      if (__pyx_t_1) {

        /* "plyvel/_plyvel.pyx":868
 *                         self._iter.key(), self.start_slice) >= n:
 *                     # Iterator is valid and within range boundaries
 *                     self.state = IN_BETWEEN             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Iterator is valid, but has moved before the
 */
        __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_IN_BETWEEN;
        goto __pyx_L28;
      }
      /*else*/ {

        /* "plyvel/_plyvel.pyx":872
 *                     # Iterator is valid, but has moved before the
 *                     # 'start' key
 *                     self.state = BEFORE_START             # <<<<<<<<<<<<<<
 * 
 *         raise_for_status(self._iter.status())
 */
        __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_BEFORE_START;
      }
      __pyx_L28:;
    }
    __pyx_L27:;
  }
  __pyx_L26:;

  /* "plyvel/_plyvel.pyx":874
 *                     self.state = BEFORE_START
 * 
 *         raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
  __pyx_t_3 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":875
 * 
 *         raise_for_status(self._iter.status())
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     def seek_to_start(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.real_prev", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_11seek_to_start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Iterator_10seek_to_start[] = "Iterator.seek_to_start(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_11seek_to_start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("seek_to_start (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_10seek_to_start(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":877
 *         return out
 * 
 *     def seek_to_start(self):             # <<<<<<<<<<<<<<
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_10seek_to_start(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("seek_to_start", 0);

  /* "plyvel/_plyvel.pyx":878
 * 
 *     def seek_to_start(self):
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":879
 *     def seek_to_start(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.state = BEFORE_START
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":881
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         self.state = BEFORE_START             # <<<<<<<<<<<<<<
 * 
 *     def seek_to_stop(self):
 */
  __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_BEFORE_START;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.seek_to_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_13seek_to_stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Iterator_12seek_to_stop[] = "Iterator.seek_to_stop(self)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_13seek_to_stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("seek_to_stop (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_12seek_to_stop(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":883
 *         self.state = BEFORE_START
 * 
 *     def seek_to_stop(self):             # <<<<<<<<<<<<<<
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_12seek_to_stop(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("seek_to_stop", 0);

  /* "plyvel/_plyvel.pyx":884
 * 
 *     def seek_to_stop(self):
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":885
 *     def seek_to_stop(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.state = AFTER_STOP
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_53), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":887
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         self.state = AFTER_STOP             # <<<<<<<<<<<<<<
 * 
 *     def seek(self, bytes target):
 */
  __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_AFTER_STOP;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.seek_to_stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_15seek(PyObject *__pyx_v_self, PyObject *__pyx_v_target); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Iterator_14seek[] = "Iterator.seek(self, bytes target)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Iterator_15seek(PyObject *__pyx_v_self, PyObject *__pyx_v_target) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("seek (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), (&PyBytes_Type), 1, "target", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Iterator_14seek(((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)__pyx_v_self), ((PyObject*)__pyx_v_target));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":889
 *         self.state = AFTER_STOP
 * 
 *     def seek(self, bytes target):             # <<<<<<<<<<<<<<
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Iterator_14seek(struct __pyx_obj_6plyvel_7_plyvel_Iterator *__pyx_v_self, PyObject *__pyx_v_target) {
  leveldb::Slice __pyx_v_target_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  const char *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("seek", 0);

  /* "plyvel/_plyvel.pyx":890
 * 
 *     def seek(self, bytes target):
 *         if self._iter is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_iter == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":891
 *     def seek(self, bytes target):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice target_slice = Slice(target, len(target))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_54), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":893
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         cdef Slice target_slice = Slice(target, len(target))             # <<<<<<<<<<<<<<
 * 
 *         # Seek only within the start/stop boundaries
 */
  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_target)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_target) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_target)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_target_slice = leveldb::Slice(__pyx_t_3, __pyx_t_4);

  /* "plyvel/_plyvel.pyx":896
 * 
 *         # Seek only within the start/stop boundaries
 *         if self.start is not None and self.comparator.Compare(             # <<<<<<<<<<<<<<
 *                 target_slice, self.start_slice) < 0:
 *             target_slice = self.start_slice
 */
  __pyx_t_1 = (__pyx_v_self->start != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":897
 *         # Seek only within the start/stop boundaries
 *         if self.start is not None and self.comparator.Compare(
 *                 target_slice, self.start_slice) < 0:             # <<<<<<<<<<<<<<
 *             target_slice = self.start_slice
 *         if self.stop is not None and self.comparator.Compare(
 */
    __pyx_t_5 = (__pyx_v_self->comparator->Compare(__pyx_v_target_slice, __pyx_v_self->start_slice) < 0);
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_1;
  }
  if (__pyx_t_6) {

    /* "plyvel/_plyvel.pyx":898
 *         if self.start is not None and self.comparator.Compare(
 *                 target_slice, self.start_slice) < 0:
 *             target_slice = self.start_slice             # <<<<<<<<<<<<<<
 *         if self.stop is not None and self.comparator.Compare(
 *                 target_slice, self.stop_slice) > 0:
 */
    __pyx_v_target_slice = __pyx_v_self->start_slice;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":899
 *                 target_slice, self.start_slice) < 0:
 *             target_slice = self.start_slice
 *         if self.stop is not None and self.comparator.Compare(             # <<<<<<<<<<<<<<
 *                 target_slice, self.stop_slice) > 0:
 *             target_slice = self.stop_slice
 */
  __pyx_t_6 = (__pyx_v_self->stop != ((PyObject*)Py_None));
  if (__pyx_t_6) {

    /* "plyvel/_plyvel.pyx":900
 *             target_slice = self.start_slice
 *         if self.stop is not None and self.comparator.Compare(
 *                 target_slice, self.stop_slice) > 0:             # <<<<<<<<<<<<<<
 *             target_slice = self.stop_slice
 * 
 */
    __pyx_t_1 = (__pyx_v_self->comparator->Compare(__pyx_v_target_slice, __pyx_v_self->stop_slice) > 0);
    __pyx_t_5 = __pyx_t_1;
  } else {
    __pyx_t_5 = __pyx_t_6;
  }
  if (__pyx_t_5) {

    /* "plyvel/_plyvel.pyx":901
 *         if self.stop is not None and self.comparator.Compare(
 *                 target_slice, self.stop_slice) > 0:
 *             target_slice = self.stop_slice             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_target_slice = __pyx_v_self->stop_slice;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":903
 *             target_slice = self.stop_slice
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter.Seek(target_slice)
 *         if not self._iter.Valid():
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":904
 * 
 *         with nogil:
 *             self._iter.Seek(target_slice)             # <<<<<<<<<<<<<<
 *         if not self._iter.Valid():
 *             # Moved past the end (or empty database)
 */
        __pyx_v_self->_iter->Seek(__pyx_v_target_slice);
      }

      /* "plyvel/_plyvel.pyx":903
 *             target_slice = self.stop_slice
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._iter.Seek(target_slice)
 *         if not self._iter.Valid():
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "plyvel/_plyvel.pyx":905
 *         with nogil:
 *             self._iter.Seek(target_slice)
 *         if not self._iter.Valid():             # <<<<<<<<<<<<<<
 *             # Moved past the end (or empty database)
 *             self.state = AFTER_STOP
 */
  __pyx_t_5 = (!__pyx_v_self->_iter->Valid());
  if (__pyx_t_5) {

    /* "plyvel/_plyvel.pyx":907
 *         if not self._iter.Valid():
 *             # Moved past the end (or empty database)
 *             self.state = AFTER_STOP             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_AFTER_STOP;

    /* "plyvel/_plyvel.pyx":908
 *             # Moved past the end (or empty database)
 *             self.state = AFTER_STOP
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.state = IN_BETWEEN_ALREADY_POSITIONED
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "plyvel/_plyvel.pyx":910
 *             return
 * 
 *         self.state = IN_BETWEEN_ALREADY_POSITIONED             # <<<<<<<<<<<<<<
 *         raise_for_status(self._iter.status())
 * 
 */
  __pyx_v_self->state = __pyx_e_6plyvel_7_plyvel_IN_BETWEEN_ALREADY_POSITIONED;

  /* "plyvel/_plyvel.pyx":911
 * 
 *         self.state = IN_BETWEEN_ALREADY_POSITIONED
 *         raise_for_status(self._iter.status())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __pyx_f_6plyvel_7_plyvel_raise_for_status(__pyx_v_self->_iter->status()); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Iterator.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_6plyvel_7_plyvel_8Snapshot_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_6plyvel_7_plyvel_8Snapshot_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db = 0;
  PyObject *__pyx_v_prefix = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__db,&__pyx_n_s__prefix,0};
    PyObject* values[2] = {0,0};

    /* "plyvel/_plyvel.pyx":924
 *     cdef bytes prefix
 * 
 *     def __init__(self, *, DB db not None, bytes prefix=None):             # <<<<<<<<<<<<<<
 *         if db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[1] = ((PyObject*)Py_None);
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__db)) != 0)) kw_args--;
      else {
        __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 1;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("__init__", __pyx_n_s__db); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)values[0]);
    __pyx_v_prefix = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_db), __pyx_ptype_6plyvel_7_plyvel_DB, 0, "db", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_prefix), (&PyBytes_Type), 1, "prefix", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Snapshot___init__(((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)__pyx_v_self), __pyx_v_db, __pyx_v_prefix);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_6plyvel_7_plyvel_8Snapshot___init__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, struct __pyx_obj_6plyvel_7_plyvel_DB *__pyx_v_db, PyObject *__pyx_v_prefix) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "plyvel/_plyvel.pyx":925
 * 
 *     def __init__(self, *, DB db not None, bytes prefix=None):
 *         if db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":926
 *     def __init__(self, *, DB db not None, bytes prefix=None):
 *         if db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.db = db
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_55), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":928
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         self.db = db             # <<<<<<<<<<<<<<
 *         self.prefix = prefix
 *         with nogil:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_db));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_db));
  __Pyx_GOTREF(__pyx_v_self->db);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->db));
  __pyx_v_self->db = __pyx_v_db;

  /* "plyvel/_plyvel.pyx":929
 * 
 *         self.db = db
 *         self.prefix = prefix             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self._snapshot = <leveldb.Snapshot*>db._db.GetSnapshot()
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_prefix));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_prefix));
  __Pyx_GOTREF(__pyx_v_self->prefix);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->prefix));
  __pyx_v_self->prefix = __pyx_v_prefix;

  /* "plyvel/_plyvel.pyx":930
 *         self.db = db
 *         self.prefix = prefix
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._snapshot = <leveldb.Snapshot*>db._db.GetSnapshot()
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":931
 *         self.prefix = prefix
 *         with nogil:
 *             self._snapshot = <leveldb.Snapshot*>db._db.GetSnapshot()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
        __pyx_v_self->_snapshot = ((leveldb::Snapshot *)__pyx_v_db->_db->GetSnapshot());
      }

      /* "plyvel/_plyvel.pyx":930
 *         self.db = db
 *         self.prefix = prefix
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self._snapshot = <leveldb.Snapshot*>db._db.GetSnapshot()
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_6plyvel_7_plyvel_8Snapshot_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_6plyvel_7_plyvel_8Snapshot_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_6plyvel_7_plyvel_8Snapshot_2__dealloc__(((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "plyvel/_plyvel.pyx":933
 *             self._snapshot = <leveldb.Snapshot*>db._db.GetSnapshot()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         with nogil:
 *             if self.db._db is not NULL and self._snapshot is not NULL:
 */

static void __pyx_pf_6plyvel_7_plyvel_8Snapshot_2__dealloc__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "plyvel/_plyvel.pyx":934
 * 
 *     def __dealloc__(self):
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.db._db is not NULL and self._snapshot is not NULL:
 *                 self.db._db.ReleaseSnapshot(self._snapshot)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "plyvel/_plyvel.pyx":935
 *     def __dealloc__(self):
 *         with nogil:
 *             if self.db._db is not NULL and self._snapshot is not NULL:             # <<<<<<<<<<<<<<
 *                 self.db._db.ReleaseSnapshot(self._snapshot)
 * 
 */
        __pyx_t_1 = (__pyx_v_self->db->_db != NULL);
        if (__pyx_t_1) {
          __pyx_t_2 = (__pyx_v_self->_snapshot != NULL);
          __pyx_t_3 = __pyx_t_2;
        } else {
          __pyx_t_3 = __pyx_t_1;
        }
        if (__pyx_t_3) {

          /* "plyvel/_plyvel.pyx":936
 *         with nogil:
 *             if self.db._db is not NULL and self._snapshot is not NULL:
 *                 self.db._db.ReleaseSnapshot(self._snapshot)             # <<<<<<<<<<<<<<
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 */
          __pyx_v_self->db->_db->ReleaseSnapshot(__pyx_v_self->_snapshot);
          goto __pyx_L6;
        }
        __pyx_L6:;
      }

      /* "plyvel/_plyvel.pyx":934
 * 
 *     def __dealloc__(self):
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if self.db._db is not NULL and self._snapshot is not NULL:
 *                 self.db._db.ReleaseSnapshot(self._snapshot)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_5get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Snapshot_4get[] = "Snapshot.get(self, bytes key, *, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_5get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__key,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[3] = {0,0,0};

    /* "plyvel/_plyvel.pyx":938
 *                 self.db._db.ReleaseSnapshot(self._snapshot)
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 1; index < 3 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_key = ((PyObject*)values[0]);
    __pyx_v_verify_checksums = values[1];
    __pyx_v_fill_cache = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyBytes_Type), 1, "key", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Snapshot_4get(((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)__pyx_v_self), __pyx_v_key, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_4get(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  leveldb::ReadOptions __pyx_v_read_options;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  bool __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get", 0);
  __Pyx_INCREF(__pyx_v_key);

  /* "plyvel/_plyvel.pyx":939
 * 
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":940
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef ReadOptions read_options
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_56), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":943
 * 
 *         cdef ReadOptions read_options
 *         read_options.snapshot = self._snapshot             # <<<<<<<<<<<<<<
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums
 */
  __pyx_v_read_options.snapshot = __pyx_v_self->_snapshot;

  /* "plyvel/_plyvel.pyx":944
 *         cdef ReadOptions read_options
 *         read_options.snapshot = self._snapshot
 *         if verify_checksums is not None:             # <<<<<<<<<<<<<<
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 */
  __pyx_t_1 = (__pyx_v_verify_checksums != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":945
 *         read_options.snapshot = self._snapshot
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums             # <<<<<<<<<<<<<<
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_verify_checksums); if (unlikely((__pyx_t_3 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_read_options.verify_checksums = __pyx_t_3;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "plyvel/_plyvel.pyx":946
 *         if verify_checksums is not None:
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:             # <<<<<<<<<<<<<<
 *             read_options.fill_cache = fill_cache
 * 
 */
  __pyx_t_1 = (__pyx_v_fill_cache != Py_None);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":947
 *             read_options.verify_checksums = verify_checksums
 *         if fill_cache is not None:
 *             read_options.fill_cache = fill_cache             # <<<<<<<<<<<<<<
 * 
 *         if self.prefix is not None:
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_fill_cache); if (unlikely((__pyx_t_3 == (bool)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_read_options.fill_cache = __pyx_t_3;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "plyvel/_plyvel.pyx":949
 *             read_options.fill_cache = fill_cache
 * 
 *         if self.prefix is not None:             # <<<<<<<<<<<<<<
 *             key = self.prefix + key
 * 
 */
  __pyx_t_1 = (__pyx_v_self->prefix != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":950
 * 
 *         if self.prefix is not None:
 *             key = self.prefix + key             # <<<<<<<<<<<<<<
 * 
 *         return db_get(self.db, key, read_options)
 */
    __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->prefix), ((PyObject *)__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__pyx_v_key));
    __pyx_v_key = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "plyvel/_plyvel.pyx":952
 *             key = self.prefix + key
 * 
 *         return db_get(self.db, key, read_options)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)__pyx_v_self->db);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = __pyx_f_6plyvel_7_plyvel_db_get(((struct __pyx_obj_6plyvel_7_plyvel_DB *)__pyx_t_2), __pyx_v_key, __pyx_v_read_options); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_7__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_7__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Snapshot_6__iter__(((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":954
 *         return db_get(self.db, key, read_options)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_6__iter__(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iter__", 0);

  /* "plyvel/_plyvel.pyx":955
 * 
 *     def __iter__(self):
 *         if self.db._db is NULL:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->db->_db == NULL);
  if (__pyx_t_1) {

    /* "plyvel/_plyvel.pyx":956
 *     def __iter__(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.iterator()
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "plyvel/_plyvel.pyx":958
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 * 
 *         return self.iterator()             # <<<<<<<<<<<<<<
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__iterator); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_9iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6plyvel_7_plyvel_8Snapshot_8iterator[] = "Snapshot.iterator(self, *, reverse=False, start=None, stop=None, include_start=True, include_stop=False, prefix=None, include_key=True, include_value=True, verify_checksums=None, fill_cache=None)";
static PyObject *__pyx_pw_6plyvel_7_plyvel_8Snapshot_9iterator(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reverse = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_stop = 0;
  PyObject *__pyx_v_include_start = 0;
  PyObject *__pyx_v_include_stop = 0;
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_include_key = 0;
  PyObject *__pyx_v_include_value = 0;
  PyObject *__pyx_v_verify_checksums = 0;
  PyObject *__pyx_v_fill_cache = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iterator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reverse,&__pyx_n_s__start,&__pyx_n_s__stop,&__pyx_n_s__include_start,&__pyx_n_s__include_stop,&__pyx_n_s__prefix,&__pyx_n_s__include_key,&__pyx_n_s__include_value,&__pyx_n_s__verify_checksums,&__pyx_n_s__fill_cache,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    values[0] = __pyx_k_58;

    /* "plyvel/_plyvel.pyx":960
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_59;
    values[4] = __pyx_k_60;

    /* "plyvel/_plyvel.pyx":961
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
    values[5] = ((PyObject *)Py_None);
    values[6] = __pyx_k_61;
    values[7] = __pyx_k_62;

    /* "plyvel/_plyvel.pyx":962
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
    values[8] = ((PyObject *)Py_None);

    /* "plyvel/_plyvel.pyx":963
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):             # <<<<<<<<<<<<<<
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 */
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args > 0 && likely(kw_args <= 10)) {
        Py_ssize_t index;
        for (index = 0; index < 10 && kw_args > 0; index++) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, 0, "iterator") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_reverse = values[0];
    __pyx_v_start = values[1];
    __pyx_v_stop = values[2];
    __pyx_v_include_start = values[3];
    __pyx_v_include_stop = values[4];
    __pyx_v_prefix = values[5];
    __pyx_v_include_key = values[6];
    __pyx_v_include_value = values[7];
    __pyx_v_verify_checksums = values[8];
    __pyx_v_fill_cache = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iterator", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plyvel._plyvel.Snapshot.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6plyvel_7_plyvel_8Snapshot_8iterator(((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)__pyx_v_self), __pyx_v_reverse, __pyx_v_start, __pyx_v_stop, __pyx_v_include_start, __pyx_v_include_stop, __pyx_v_prefix, __pyx_v_include_key, __pyx_v_include_value, __pyx_v_verify_checksums, __pyx_v_fill_cache);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plyvel/_plyvel.pyx":960
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */

static PyObject *__pyx_pf_6plyvel_7_plyvel_8Snapshot_8iterator(struct __pyx_obj_6plyvel_7_plyvel_Snapshot *__pyx_v_self, PyObject *__pyx_v_reverse, PyObject *__pyx_v_start, PyObject *__pyx_v_stop, PyObject *__pyx_v_include_start, PyObject *__pyx_v_include_stop, PyObject *__pyx_v_prefix, PyObject *__pyx_v_include_key, PyObject *__pyx_v_include_value, PyObject *__pyx_v_verify_checksums, PyObject *__pyx_v_fill_cache) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("iterator", 0);

  /* "plyvel/_plyvel.pyx":964
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 *         return Iterator(             # <<<<<<<<<<<<<<
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "plyvel/_plyvel.pyx":965
 *                  fill_cache=None):
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,             # <<<<<<<<<<<<<<
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__db), ((PyObject *)__pyx_v_self->db)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__key_prefix), ((PyObject *)__pyx_v_self->prefix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__reverse), __pyx_v_reverse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__start), __pyx_v_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":966
 *         return Iterator(
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,             # <<<<<<<<<<<<<<
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__stop), __pyx_v_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_start), __pyx_v_include_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_stop), __pyx_v_include_stop) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":967
 *             db=self.db, key_prefix=self.prefix, reverse=reverse, start=start,
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,             # <<<<<<<<<<<<<<
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=self)
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__prefix), __pyx_v_prefix) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_key), __pyx_v_include_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":968
 *             stop=stop, include_start=include_start, include_stop=include_stop,
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,             # <<<<<<<<<<<<<<
 *             fill_cache=fill_cache, snapshot=self)
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__include_value), __pyx_v_include_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__verify_checksums), __pyx_v_verify_checksums) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":969
 *             prefix=prefix, include_key=include_key,
 *             include_value=include_value, verify_checksums=verify_checksums,
 *             fill_cache=fill_cache, snapshot=self)             # <<<<<<<<<<<<<<
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__fill_cache), __pyx_v_fill_cache) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__snapshot), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6plyvel_7_plyvel_Iterator)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __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_AddTraceback("plyvel._plyvel.Snapshot.iterator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":25
 * 
 * @cname("__pyx_convert_string_to_py_")
 * cdef object __pyx_convert_string_to_py_(string& s):             # <<<<<<<<<<<<<<
 *     return s.data()[:s.size()]
 * 
 */

static PyObject *__pyx_convert_string_to_py_(const std::string &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_string_to_py_", 0);

  /* "string.to_py":26
 * @cname("__pyx_convert_string_to_py_")
 * cdef object __pyx_convert_string_to_py_(string& s):
 *     return s.data()[:s.size()]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyBytes_FromStringAndSize(((const char*)__pyx_v_s.data()) + 0, __pyx_v_s.size() - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_string_to_py_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.from_py":11
 * 
 * @cname("__pyx_convert_string_from_py_")
 * cdef string __pyx_convert_string_from_py_(object o) except *:             # <<<<<<<<<<<<<<
 *     return string(<char*>o, len(o))
 * 
 */

static std::string __pyx_convert_string_from_py_(PyObject *__pyx_v_o) {
  std::string __pyx_r;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_", 0);

  /* "string.from_py":12
 * @cname("__pyx_convert_string_from_py_")
 * cdef string __pyx_convert_string_from_py_(object o) except *:
 *     return string(<char*>o, len(o))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = std::string(((char *)__pyx_t_1), __pyx_t_2);
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_6plyvel_7_plyvel_DB __pyx_vtable_6plyvel_7_plyvel_DB;

static PyObject *__pyx_tp_new_6plyvel_7_plyvel_DB(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)o);
  p->__pyx_vtab = __pyx_vtabptr_6plyvel_7_plyvel_DB;
  new((void*)&(p->options)) leveldb::Options();
  p->lock = Py_None; Py_INCREF(Py_None);
  p->iterators = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6plyvel_7_plyvel_DB(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *p = (struct __pyx_obj_6plyvel_7_plyvel_DB *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_6plyvel_7_plyvel_2DB_5__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  p->options.leveldb::Options::~Options();
  Py_CLEAR(p->lock);
  Py_CLEAR(p->iterators);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6plyvel_7_plyvel_DB(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6plyvel_7_plyvel_DB *p = (struct __pyx_obj_6plyvel_7_plyvel_DB *)o;
  if (p->lock) {
    e = (*v)(p->lock, a); if (e) return e;
  }
  if (p->iterators) {
    e = (*v)(p->iterators, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6plyvel_7_plyvel_DB(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_DB *p = (struct __pyx_obj_6plyvel_7_plyvel_DB *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->lock);
  p->lock = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->iterators);
  p->iterators = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6plyvel_7_plyvel_2DB_closed(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6plyvel_7_plyvel_2DB_6closed_1__get__(o);
}

static PyMethodDef __pyx_methods_6plyvel_7_plyvel_DB[] = {
  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_3close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_2close)},
  {__Pyx_NAMESTR("get"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_7get, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_6get)},
  {__Pyx_NAMESTR("put"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_9put, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_8put)},
  {__Pyx_NAMESTR("delete"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_11delete, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_10delete)},
  {__Pyx_NAMESTR("write_batch"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_13write_batch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_12write_batch)},
  {__Pyx_NAMESTR("iterator"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_17iterator, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_16iterator)},
  {__Pyx_NAMESTR("snapshot"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_19snapshot, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_18snapshot)},
  {__Pyx_NAMESTR("get_property"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_21get_property, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_20get_property)},
  {__Pyx_NAMESTR("compact_range"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_23compact_range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_22compact_range)},
  {__Pyx_NAMESTR("approximate_size"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_25approximate_size, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_24approximate_size)},
  {__Pyx_NAMESTR("approximate_sizes"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_27approximate_sizes, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_26approximate_sizes)},
  {__Pyx_NAMESTR("prefixed_db"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_2DB_29prefixed_db, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_2DB_28prefixed_db)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6plyvel_7_plyvel_DB[] = {
  {(char *)"closed", __pyx_getprop_6plyvel_7_plyvel_2DB_closed, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_DB = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_DB = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_DB = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_DB = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6plyvel_7_plyvel_DB = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("plyvel._plyvel.DB"), /*tp_name*/
  sizeof(struct __pyx_obj_6plyvel_7_plyvel_DB), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6plyvel_7_plyvel_DB, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_DB, /*tp_as_number*/
  &__pyx_tp_as_sequence_DB, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_DB, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_DB, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("DB(name, bool create_if_missing=False, *, bool error_if_exists=False, paranoid_checks=None, write_buffer_size=None, max_open_files=None, lru_cache_size=None, block_size=None, block_restart_interval=None, compression='snappy', int bloom_filter_bits=0, comparator=None, bytes comparator_name=None)"), /*tp_doc*/
  __pyx_tp_traverse_6plyvel_7_plyvel_DB, /*tp_traverse*/
  __pyx_tp_clear_6plyvel_7_plyvel_DB, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_6plyvel_7_plyvel_2DB_15__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6plyvel_7_plyvel_DB, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6plyvel_7_plyvel_DB, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6plyvel_7_plyvel_2DB_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6plyvel_7_plyvel_DB, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_6plyvel_7_plyvel_PrefixedDB(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)o);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6plyvel_7_plyvel_PrefixedDB(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *p = (struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)o;
  Py_CLEAR(p->db);
  Py_CLEAR(p->prefix);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6plyvel_7_plyvel_PrefixedDB(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *p = (struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)o;
  if (p->db) {
    e = (*v)(((PyObject*)p->db), a); if (e) return e;
  }
  if (p->prefix) {
    e = (*v)(p->prefix, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6plyvel_7_plyvel_PrefixedDB(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *p = (struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->db);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->prefix);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_6plyvel_7_plyvel_10PrefixedDB_db(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_2db_1__get__(o);
}

static PyObject *__pyx_getprop_6plyvel_7_plyvel_10PrefixedDB_prefix(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_6prefix_1__get__(o);
}

static PyMethodDef __pyx_methods_6plyvel_7_plyvel_PrefixedDB[] = {
  {__Pyx_NAMESTR("get"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_3get, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_2get)},
  {__Pyx_NAMESTR("put"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_5put, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_4put)},
  {__Pyx_NAMESTR("delete"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_7delete, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_6delete)},
  {__Pyx_NAMESTR("write_batch"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_9write_batch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_8write_batch)},
  {__Pyx_NAMESTR("iterator"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_13iterator, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_12iterator)},
  {__Pyx_NAMESTR("snapshot"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_15snapshot, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_14snapshot)},
  {__Pyx_NAMESTR("prefixed_db"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10PrefixedDB_17prefixed_db, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10PrefixedDB_16prefixed_db)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_6plyvel_7_plyvel_PrefixedDB[] = {
  {(char *)"db", __pyx_getprop_6plyvel_7_plyvel_10PrefixedDB_db, 0, __Pyx_DOCSTR(__pyx_k_63), 0},
  {(char *)"prefix", __pyx_getprop_6plyvel_7_plyvel_10PrefixedDB_prefix, 0, __Pyx_DOCSTR(__pyx_k_64), 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PrefixedDB = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_PrefixedDB = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PrefixedDB = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PrefixedDB = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6plyvel_7_plyvel_PrefixedDB = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("plyvel._plyvel.PrefixedDB"), /*tp_name*/
  sizeof(struct __pyx_obj_6plyvel_7_plyvel_PrefixedDB), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6plyvel_7_plyvel_PrefixedDB, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_PrefixedDB, /*tp_as_number*/
  &__pyx_tp_as_sequence_PrefixedDB, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PrefixedDB, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PrefixedDB, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("PrefixedDB(db, *, prefix)"), /*tp_doc*/
  __pyx_tp_traverse_6plyvel_7_plyvel_PrefixedDB, /*tp_traverse*/
  __pyx_tp_clear_6plyvel_7_plyvel_PrefixedDB, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_11__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6plyvel_7_plyvel_PrefixedDB, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_6plyvel_7_plyvel_PrefixedDB, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6plyvel_7_plyvel_10PrefixedDB_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6plyvel_7_plyvel_PrefixedDB, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_6plyvel_7_plyvel_WriteBatch(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)o);
  new((void*)&(p->write_options)) leveldb::WriteOptions();
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6plyvel_7_plyvel_WriteBatch(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *p = (struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_6plyvel_7_plyvel_10WriteBatch_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  p->write_options.leveldb::WriteOptions::~WriteOptions();
  Py_CLEAR(p->db);
  Py_CLEAR(p->prefix);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6plyvel_7_plyvel_WriteBatch(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *p = (struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)o;
  if (p->db) {
    e = (*v)(((PyObject*)p->db), a); if (e) return e;
  }
  if (p->prefix) {
    e = (*v)(p->prefix, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6plyvel_7_plyvel_WriteBatch(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *p = (struct __pyx_obj_6plyvel_7_plyvel_WriteBatch *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->db);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->prefix);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6plyvel_7_plyvel_WriteBatch[] = {
  {__Pyx_NAMESTR("put"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_5put, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_4put)},
  {__Pyx_NAMESTR("delete"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_7delete, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_6delete)},
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_9clear, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_8clear)},
  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_11write, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_10write)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_13__enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_12__enter__)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_10WriteBatch_15__exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_10WriteBatch_14__exit__)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_WriteBatch = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_WriteBatch = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_WriteBatch = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_WriteBatch = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6plyvel_7_plyvel_WriteBatch = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("plyvel._plyvel.WriteBatch"), /*tp_name*/
  sizeof(struct __pyx_obj_6plyvel_7_plyvel_WriteBatch), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6plyvel_7_plyvel_WriteBatch, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_WriteBatch, /*tp_as_number*/
  &__pyx_tp_as_sequence_WriteBatch, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_WriteBatch, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_WriteBatch, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("WriteBatch(DB db, *, bytes prefix=None, bool transaction=False, sync=None)"), /*tp_doc*/
  __pyx_tp_traverse_6plyvel_7_plyvel_WriteBatch, /*tp_traverse*/
  __pyx_tp_clear_6plyvel_7_plyvel_WriteBatch, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6plyvel_7_plyvel_WriteBatch, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6plyvel_7_plyvel_10WriteBatch_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6plyvel_7_plyvel_WriteBatch, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_6plyvel_7_plyvel_Iterator __pyx_vtable_6plyvel_7_plyvel_Iterator;

static PyObject *__pyx_tp_new_6plyvel_7_plyvel_Iterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6plyvel_7_plyvel_Iterator *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6plyvel_7_plyvel_Iterator *)o);
  p->__pyx_vtab = __pyx_vtabptr_6plyvel_7_plyvel_Iterator;
  new((void*)&(p->start_slice)) leveldb::Slice();
  new((void*)&(p->stop_slice)) leveldb::Slice();
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  p->start = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->stop = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->__weakref__ = 0;
  return o;
}

static void __pyx_tp_dealloc_6plyvel_7_plyvel_Iterator(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_Iterator *p = (struct __pyx_obj_6plyvel_7_plyvel_Iterator *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_6plyvel_7_plyvel_8Iterator_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  p->start_slice.leveldb::Slice::~Slice();
  p->stop_slice.leveldb::Slice::~Slice();
  Py_CLEAR(p->db);
  Py_CLEAR(p->start);
  Py_CLEAR(p->stop);
  Py_CLEAR(p->__weakref__);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6plyvel_7_plyvel_Iterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6plyvel_7_plyvel_Iterator *p = (struct __pyx_obj_6plyvel_7_plyvel_Iterator *)o;
  if (p->db) {
    e = (*v)(((PyObject*)p->db), a); if (e) return e;
  }
  if (p->start) {
    e = (*v)(p->start, a); if (e) return e;
  }
  if (p->stop) {
    e = (*v)(p->stop, a); if (e) return e;
  }
  if (p->__weakref__) {
    e = (*v)(p->__weakref__, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6plyvel_7_plyvel_Iterator(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_Iterator *p = (struct __pyx_obj_6plyvel_7_plyvel_Iterator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->db);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->start);
  p->start = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->stop);
  p->stop = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6plyvel_7_plyvel_Iterator[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Iterator_7__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Iterator_6__next__)},
  {__Pyx_NAMESTR("prev"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Iterator_9prev, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Iterator_8prev)},
  {__Pyx_NAMESTR("seek_to_start"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Iterator_11seek_to_start, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Iterator_10seek_to_start)},
  {__Pyx_NAMESTR("seek_to_stop"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Iterator_13seek_to_stop, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Iterator_12seek_to_stop)},
  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Iterator_15seek, METH_O, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Iterator_14seek)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Iterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Iterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Iterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Iterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6plyvel_7_plyvel_Iterator = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("plyvel._plyvel.Iterator"), /*tp_name*/
  sizeof(struct __pyx_obj_6plyvel_7_plyvel_Iterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6plyvel_7_plyvel_Iterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Iterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_Iterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Iterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Iterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Iterator(DB db, *, key_prefix, bool reverse, bytes start, bytes stop, bool include_start, bool include_stop, bytes prefix, bool include_key, bool include_value, bool verify_checksums, bool fill_cache, Snapshot snapshot)"), /*tp_doc*/
  __pyx_tp_traverse_6plyvel_7_plyvel_Iterator, /*tp_traverse*/
  __pyx_tp_clear_6plyvel_7_plyvel_Iterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_6plyvel_7_plyvel_8Iterator_5__iter__, /*tp_iter*/
  __pyx_pw_6plyvel_7_plyvel_8Iterator_7__next__, /*tp_iternext*/
  __pyx_methods_6plyvel_7_plyvel_Iterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6plyvel_7_plyvel_8Iterator_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6plyvel_7_plyvel_Iterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_6plyvel_7_plyvel_Snapshot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_6plyvel_7_plyvel_Snapshot *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)o);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_6plyvel_7_plyvel_Snapshot(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_Snapshot *p = (struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_6plyvel_7_plyvel_8Snapshot_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->db);
  Py_CLEAR(p->prefix);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_6plyvel_7_plyvel_Snapshot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_6plyvel_7_plyvel_Snapshot *p = (struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)o;
  if (p->db) {
    e = (*v)(((PyObject*)p->db), a); if (e) return e;
  }
  if (p->prefix) {
    e = (*v)(p->prefix, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_6plyvel_7_plyvel_Snapshot(PyObject *o) {
  struct __pyx_obj_6plyvel_7_plyvel_Snapshot *p = (struct __pyx_obj_6plyvel_7_plyvel_Snapshot *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->db);
  p->db = ((struct __pyx_obj_6plyvel_7_plyvel_DB *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->prefix);
  p->prefix = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_6plyvel_7_plyvel_Snapshot[] = {
  {__Pyx_NAMESTR("get"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Snapshot_5get, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Snapshot_4get)},
  {__Pyx_NAMESTR("iterator"), (PyCFunction)__pyx_pw_6plyvel_7_plyvel_8Snapshot_9iterator, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6plyvel_7_plyvel_8Snapshot_8iterator)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Snapshot = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Snapshot = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Snapshot = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Snapshot = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_6plyvel_7_plyvel_Snapshot = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("plyvel._plyvel.Snapshot"), /*tp_name*/
  sizeof(struct __pyx_obj_6plyvel_7_plyvel_Snapshot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_6plyvel_7_plyvel_Snapshot, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Snapshot, /*tp_as_number*/
  &__pyx_tp_as_sequence_Snapshot, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Snapshot, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Snapshot, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Snapshot(DB db, *, bytes prefix=None)"), /*tp_doc*/
  __pyx_tp_traverse_6plyvel_7_plyvel_Snapshot, /*tp_traverse*/
  __pyx_tp_clear_6plyvel_7_plyvel_Snapshot, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_6plyvel_7_plyvel_8Snapshot_7__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_6plyvel_7_plyvel_Snapshot, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_6plyvel_7_plyvel_8Snapshot_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_6plyvel_7_plyvel_Snapshot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_plyvel"),
    __Pyx_DOCSTR(__pyx_k_65), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_n_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 1},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
  {&__pyx_n_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 1},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s__CorruptionError, __pyx_k__CorruptionError, sizeof(__pyx_k__CorruptionError), 0, 0, 1, 1},
  {&__pyx_n_s__Error, __pyx_k__Error, sizeof(__pyx_k__Error), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
  {&__pyx_n_s__Lock, __pyx_k__Lock, sizeof(__pyx_k__Lock), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__UnicodeEncodeError, __pyx_k__UnicodeEncodeError, sizeof(__pyx_k__UnicodeEncodeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s__WeakValueDictionary, __pyx_k__WeakValueDictionary, sizeof(__pyx_k__WeakValueDictionary), 0, 0, 1, 1},
  {&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1},
  {&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1},
  {&__pyx_n_s____leveldb_version__, __pyx_k____leveldb_version__, sizeof(__pyx_k____leveldb_version__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__approximate_sizes, __pyx_k__approximate_sizes, sizeof(__pyx_k__approximate_sizes), 0, 0, 1, 1},
  {&__pyx_n_s__ascii, __pyx_k__ascii, sizeof(__pyx_k__ascii), 0, 0, 1, 1},
  {&__pyx_n_s__block_size, __pyx_k__block_size, sizeof(__pyx_k__block_size), 0, 0, 1, 1},
  {&__pyx_n_s__bloom_filter_bits, __pyx_k__bloom_filter_bits, sizeof(__pyx_k__bloom_filter_bits), 0, 0, 1, 1},
  {&__pyx_n_s__bytearray, __pyx_k__bytearray, sizeof(__pyx_k__bytearray), 0, 0, 1, 1},
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
  {&__pyx_n_s__comparator, __pyx_k__comparator, sizeof(__pyx_k__comparator), 0, 0, 1, 1},
  {&__pyx_n_s__comparator_name, __pyx_k__comparator_name, sizeof(__pyx_k__comparator_name), 0, 0, 1, 1},
  {&__pyx_n_s__compression, __pyx_k__compression, sizeof(__pyx_k__compression), 0, 0, 1, 1},
  {&__pyx_n_s__create_if_missing, __pyx_k__create_if_missing, sizeof(__pyx_k__create_if_missing), 0, 0, 1, 1},
  {&__pyx_n_s__db, __pyx_k__db, sizeof(__pyx_k__db), 0, 0, 1, 1},
  {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__delete, __pyx_k__delete, sizeof(__pyx_k__delete), 0, 0, 1, 1},
  {&__pyx_n_s__destroy_db, __pyx_k__destroy_db, sizeof(__pyx_k__destroy_db), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__error_if_exists, __pyx_k__error_if_exists, sizeof(__pyx_k__error_if_exists), 0, 0, 1, 1},
  {&__pyx_n_s__exc_tb, __pyx_k__exc_tb, sizeof(__pyx_k__exc_tb), 0, 0, 1, 1},
  {&__pyx_n_s__exc_type, __pyx_k__exc_type, sizeof(__pyx_k__exc_type), 0, 0, 1, 1},
  {&__pyx_n_s__exc_val, __pyx_k__exc_val, sizeof(__pyx_k__exc_val), 0, 0, 1, 1},
  {&__pyx_n_s__fill_cache, __pyx_k__fill_cache, sizeof(__pyx_k__fill_cache), 0, 0, 1, 1},
  {&__pyx_n_s__fsname, __pyx_k__fsname, sizeof(__pyx_k__fsname), 0, 0, 1, 1},
  {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__include_key, __pyx_k__include_key, sizeof(__pyx_k__include_key), 0, 0, 1, 1},
  {&__pyx_n_s__include_start, __pyx_k__include_start, sizeof(__pyx_k__include_start), 0, 0, 1, 1},
  {&__pyx_n_s__include_stop, __pyx_k__include_stop, sizeof(__pyx_k__include_stop), 0, 0, 1, 1},
  {&__pyx_n_s__include_value, __pyx_k__include_value, sizeof(__pyx_k__include_value), 0, 0, 1, 1},
  {&__pyx_n_s__iterator, __pyx_k__iterator, sizeof(__pyx_k__iterator), 0, 0, 1, 1},
  {&__pyx_n_s__itervalues, __pyx_k__itervalues, sizeof(__pyx_k__itervalues), 0, 0, 1, 1},
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
  {&__pyx_n_s__key_prefix, __pyx_k__key_prefix, sizeof(__pyx_k__key_prefix), 0, 0, 1, 1},
  {&__pyx_n_s__lru_cache_size, __pyx_k__lru_cache_size, sizeof(__pyx_k__lru_cache_size), 0, 0, 1, 1},
  {&__pyx_n_s__max_open_files, __pyx_k__max_open_files, sizeof(__pyx_k__max_open_files), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__options, __pyx_k__options, sizeof(__pyx_k__options), 0, 0, 1, 1},
  {&__pyx_n_s__paranoid_checks, __pyx_k__paranoid_checks, sizeof(__pyx_k__paranoid_checks), 0, 0, 1, 1},
  {&__pyx_n_s__prefix, __pyx_k__prefix, sizeof(__pyx_k__prefix), 0, 0, 1, 1},
  {&__pyx_n_s__put, __pyx_k__put, sizeof(__pyx_k__put), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__repair_db, __pyx_k__repair_db, sizeof(__pyx_k__repair_db), 0, 0, 1, 1},
  {&__pyx_n_s__reverse, __pyx_k__reverse, sizeof(__pyx_k__reverse), 0, 0, 1, 1},
  {&__pyx_n_s__seek_to_start, __pyx_k__seek_to_start, sizeof(__pyx_k__seek_to_start), 0, 0, 1, 1},
  {&__pyx_n_s__seek_to_stop, __pyx_k__seek_to_stop, sizeof(__pyx_k__seek_to_stop), 0, 0, 1, 1},
  {&__pyx_n_s__snappy, __pyx_k__snappy, sizeof(__pyx_k__snappy), 0, 0, 1, 1},
  {&__pyx_n_u__snappy, __pyx_k__snappy, sizeof(__pyx_k__snappy), 0, 1, 0, 1},
  {&__pyx_n_s__snapshot, __pyx_k__snapshot, sizeof(__pyx_k__snapshot), 0, 0, 1, 1},
  {&__pyx_n_s__st, __pyx_k__st, sizeof(__pyx_k__st), 0, 0, 1, 1},
  {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
  {&__pyx_n_s__stop, __pyx_k__stop, sizeof(__pyx_k__stop), 0, 0, 1, 1},
  {&__pyx_n_s__sync, __pyx_k__sync, sizeof(__pyx_k__sync), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__threading, __pyx_k__threading, sizeof(__pyx_k__threading), 0, 0, 1, 1},
  {&__pyx_n_s__transaction, __pyx_k__transaction, sizeof(__pyx_k__transaction), 0, 0, 1, 1},
  {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
  {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1},
  {&__pyx_n_s__verify_checksums, __pyx_k__verify_checksums, sizeof(__pyx_k__verify_checksums), 0, 0, 1, 1},
  {&__pyx_n_s__weakref, __pyx_k__weakref, sizeof(__pyx_k__weakref), 0, 0, 1, 1},
  {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
  {&__pyx_n_s__write_buffer_size, __pyx_k__write_buffer_size, sizeof(__pyx_k__write_buffer_size), 0, 0, 1, 1},
  {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UnicodeEncodeError = __Pyx_GetName(__pyx_b, __pyx_n_s__UnicodeEncodeError); if (!__pyx_builtin_UnicodeEncodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_bytearray = __Pyx_GetName(__pyx_b, __pyx_n_s__bytearray); if (!__pyx_builtin_bytearray) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_n_s__id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "plyvel/_plyvel.pyx":108
 * 
 *     if not isinstance(name, unicode):
 *         raise TypeError(             # <<<<<<<<<<<<<<
 *             "'name' arg must be a byte string or a unicode string")
 * 
 */
  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_2);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

  /* "plyvel/_plyvel.pyx":176
 *     else:
 *         if isinstance(compression, bytes):
 *             compression = compression.decode('UTF-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(compression, unicode):
 *             raise TypeError("'compression' must be None or a string")
 */
  __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_6);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));

  /* "plyvel/_plyvel.pyx":178
 *             compression = compression.decode('UTF-8')
 *         if not isinstance(compression, unicode):
 *             raise TypeError("'compression' must be None or a string")             # <<<<<<<<<<<<<<
 *         if compression == u'snappy':
 *             options.compression = leveldb.kSnappyCompression
 */
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_8);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));

  /* "plyvel/_plyvel.pyx":182
 *             options.compression = leveldb.kSnappyCompression
 *         else:
 *             raise ValueError("'compression' must be None or 'snappy'")             # <<<<<<<<<<<<<<
 * 
 *     if bloom_filter_bits > 0:
 */
  __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_10);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
  PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));

  /* "plyvel/_plyvel.pyx":189
 * 
 *     if (comparator is None) != (comparator_name is None):
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'comparator' and 'comparator_name' must be specified together")
 * 
 */
  __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_12);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
  PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_s_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12));

  /* "plyvel/_plyvel.pyx":194
 *     if comparator is not None:
 *         if not callable(comparator):
 *             raise TypeError("custom comparator object must be callable")             # <<<<<<<<<<<<<<
 * 
 *         options.comparator = NewPlyvelCallbackComparator(
 */
  __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_14);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));

  /* "plyvel/_plyvel.pyx":247
 *         cdef Iterator iterator
 *         if self.iterators is not None:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 try:
 *                     itervalues = self.iterators.itervalues  # Python 2
 */
  __pyx_k_tuple_16 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_16);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 2, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16));

  /* "plyvel/_plyvel.pyx":285
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef ReadOptions read_options
 */
  __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_18);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));

  /* "plyvel/_plyvel.pyx":298
 *     def put(self, bytes key, bytes value, *, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef WriteOptions write_options = WriteOptions()
 */
  __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_19);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19));

  /* "plyvel/_plyvel.pyx":314
 *     def delete(self, bytes key, *, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Status st
 */
  __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_20);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));

  /* "plyvel/_plyvel.pyx":329
 *     def write_batch(self, *, transaction=False, sync=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return WriteBatch(db=self, transaction=transaction, sync=sync)
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_22);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));

  /* "plyvel/_plyvel.pyx":335
 *     def __iter__(self):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.iterator()
 */
  __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_23);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));

  /* "plyvel/_plyvel.pyx":359
 *     def get_property(self, bytes name not None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice sl = Slice(name, len(name))
 */
  __pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_29);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));

  /* "plyvel/_plyvel.pyx":372
 *     def compact_range(self, *, bytes start=None, bytes stop=None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice start_slice
 */
  __pyx_k_tuple_30 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_30);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_30, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30));

  /* "plyvel/_plyvel.pyx":388
 *     def approximate_size(self, bytes start not None, bytes stop not None):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.approximate_sizes((start, stop))[0]
 */
  __pyx_k_tuple_31 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_31);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_31, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31));

  /* "plyvel/_plyvel.pyx":394
 *     def approximate_sizes(self, *ranges):
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef int n_ranges = len(ranges)
 */
  __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_32);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));

  /* "plyvel/_plyvel.pyx":403
 *                 start, stop = ranges[i]
 *                 if not isinstance(start, bytes) or not isinstance(stop, bytes):
 *                     raise TypeError(             # <<<<<<<<<<<<<<
 *                         "Start and stop of range must be byte strings")
 *                 c_ranges[i] = Range(
 */
  __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_34);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
  PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));

  /* "plyvel/_plyvel.pyx":528
 *     def put(self, bytes key, bytes value):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.prefix is not None:
 */
  __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_41);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));

  /* "plyvel/_plyvel.pyx":540
 *     def delete(self, bytes key):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.prefix is not None:
 */
  __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_42);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));

  /* "plyvel/_plyvel.pyx":551
 *     def clear(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_43);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));

  /* "plyvel/_plyvel.pyx":558
 *     def write(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Status st
 */
  __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_44);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));

  /* "plyvel/_plyvel.pyx":567
 *     def __enter__(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self
 */
  __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_45);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));

  /* "plyvel/_plyvel.pyx":573
 *     def __exit__(self, exc_type, exc_val, exc_tb):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.transaction and exc_type is not None:
 */
  __pyx_k_tuple_46 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_46);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46));

  /* "plyvel/_plyvel.pyx":631
 *                  Snapshot snapshot):
 *         if db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.db = db
 */
  __pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_47);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));

  /* "plyvel/_plyvel.pyx":663
 *         if prefix is not None:
 *             if start is not None or stop is not None:
 *                 raise TypeError(             # <<<<<<<<<<<<<<
 *                     "'prefix' cannot be used together with 'start' or 'stop'")
 *             # Use prefix to construct start and stop keys, and ignore
 */
  __pyx_k_tuple_49 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_49);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_48));
  PyTuple_SET_ITEM(__pyx_k_tuple_49, 0, ((PyObject *)__pyx_kp_s_48));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_48));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49));

  /* "plyvel/_plyvel.pyx":767
 *     cdef real_next(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.state == IN_BETWEEN:
 */
  __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_50);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));

  /* "plyvel/_plyvel.pyx":810
 *     cdef real_prev(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         if self.state == IN_BETWEEN:
 */
  __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_51);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));

  /* "plyvel/_plyvel.pyx":879
 *     def seek_to_start(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.state = BEFORE_START
 */
  __pyx_k_tuple_52 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_52);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));

  /* "plyvel/_plyvel.pyx":885
 *     def seek_to_stop(self):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.state = AFTER_STOP
 */
  __pyx_k_tuple_53 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_53);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53));

  /* "plyvel/_plyvel.pyx":891
 *     def seek(self, bytes target):
 *         if self._iter is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef Slice target_slice = Slice(target, len(target))
 */
  __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_54);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));

  /* "plyvel/_plyvel.pyx":926
 *     def __init__(self, *, DB db not None, bytes prefix=None):
 *         if db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         self.db = db
 */
  __pyx_k_tuple_55 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_55);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_55, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55));

  /* "plyvel/_plyvel.pyx":940
 *     def get(self, bytes key, *, verify_checksums=None, fill_cache=None):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         cdef ReadOptions read_options
 */
  __pyx_k_tuple_56 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_56);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_56));

  /* "plyvel/_plyvel.pyx":956
 *     def __iter__(self):
 *         if self.db._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")             # <<<<<<<<<<<<<<
 * 
 *         return self.iterator()
 */
  __pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_57);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));

  /* "plyvel/_plyvel.pyx":466
 * 
 * 
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,             # <<<<<<<<<<<<<<
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',
 */
  __pyx_k_tuple_68 = PyTuple_New(16); if (unlikely(!__pyx_k_tuple_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_68);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 0, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__paranoid_checks));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 1, ((PyObject *)__pyx_n_s__paranoid_checks));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__paranoid_checks));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__write_buffer_size));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 2, ((PyObject *)__pyx_n_s__write_buffer_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__write_buffer_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__max_open_files));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 3, ((PyObject *)__pyx_n_s__max_open_files));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__max_open_files));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__lru_cache_size));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 4, ((PyObject *)__pyx_n_s__lru_cache_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__lru_cache_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__block_size));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 5, ((PyObject *)__pyx_n_s__block_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__block_size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_15));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 6, ((PyObject *)__pyx_n_s_15));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_15));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__compression));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 7, ((PyObject *)__pyx_n_s__compression));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__compression));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bloom_filter_bits));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 8, ((PyObject *)__pyx_n_s__bloom_filter_bits));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bloom_filter_bits));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__comparator));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 9, ((PyObject *)__pyx_n_s__comparator));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comparator));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__comparator_name));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 10, ((PyObject *)__pyx_n_s__comparator_name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__comparator_name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__options));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 11, ((PyObject *)__pyx_n_s__options));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__options));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__st));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 12, ((PyObject *)__pyx_n_s__st));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__st));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fsname));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 13, ((PyObject *)__pyx_n_s__fsname));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fsname));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__create_if_missing));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 14, ((PyObject *)__pyx_n_s__create_if_missing));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__create_if_missing));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__error_if_exists));
  PyTuple_SET_ITEM(__pyx_k_tuple_68, 15, ((PyObject *)__pyx_n_s__error_if_exists));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__error_if_exists));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_68));
  __pyx_k_codeobj_69 = (PyObject*)__Pyx_PyCode_New(11, 10, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_70, __pyx_n_s__repair_db, 466, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plyvel/_plyvel.pyx":488
 * 
 * 
 * def destroy_db(name):             # <<<<<<<<<<<<<<
 *     cdef Options options = Options()
 *     cdef Status st
 */
  __pyx_k_tuple_71 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_71);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 0, ((PyObject *)__pyx_n_s__name));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__options));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 1, ((PyObject *)__pyx_n_s__options));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__options));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__st));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 2, ((PyObject *)__pyx_n_s__st));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__st));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__fsname));
  PyTuple_SET_ITEM(__pyx_k_tuple_71, 3, ((PyObject *)__pyx_n_s__fsname));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__fsname));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71));
  __pyx_k_codeobj_72 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_70, __pyx_n_s__destroy_db, 488, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_plyvel(void); /*proto*/
PyMODINIT_FUNC init_plyvel(void)
#else
PyMODINIT_FUNC PyInit__plyvel(void); /*proto*/
PyMODINIT_FUNC PyInit__plyvel(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__plyvel(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_plyvel"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_65), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_plyvel___plyvel) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_6plyvel_7_plyvel_DB = &__pyx_vtable_6plyvel_7_plyvel_DB;
  __pyx_vtable_6plyvel_7_plyvel_DB.close = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_DB *, int __pyx_skip_dispatch))__pyx_f_6plyvel_7_plyvel_2DB_close;
  __pyx_vtable_6plyvel_7_plyvel_DB._register_iterator = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_DB *, struct __pyx_obj_6plyvel_7_plyvel_Iterator *))__pyx_f_6plyvel_7_plyvel_2DB__register_iterator;
  if (PyType_Ready(&__pyx_type_6plyvel_7_plyvel_DB) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_6plyvel_7_plyvel_DB.tp_dict, __pyx_vtabptr_6plyvel_7_plyvel_DB) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "DB", (PyObject *)&__pyx_type_6plyvel_7_plyvel_DB) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6plyvel_7_plyvel_DB = &__pyx_type_6plyvel_7_plyvel_DB;
  if (PyType_Ready(&__pyx_type_6plyvel_7_plyvel_PrefixedDB) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "PrefixedDB", (PyObject *)&__pyx_type_6plyvel_7_plyvel_PrefixedDB) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6plyvel_7_plyvel_PrefixedDB = &__pyx_type_6plyvel_7_plyvel_PrefixedDB;
  if (PyType_Ready(&__pyx_type_6plyvel_7_plyvel_WriteBatch) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "WriteBatch", (PyObject *)&__pyx_type_6plyvel_7_plyvel_WriteBatch) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6plyvel_7_plyvel_WriteBatch = &__pyx_type_6plyvel_7_plyvel_WriteBatch;
  __pyx_vtabptr_6plyvel_7_plyvel_Iterator = &__pyx_vtable_6plyvel_7_plyvel_Iterator;
  __pyx_vtable_6plyvel_7_plyvel_Iterator.close = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *))__pyx_f_6plyvel_7_plyvel_8Iterator_close;
  __pyx_vtable_6plyvel_7_plyvel_Iterator.current = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *))__pyx_f_6plyvel_7_plyvel_8Iterator_current;
  __pyx_vtable_6plyvel_7_plyvel_Iterator.real_next = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *))__pyx_f_6plyvel_7_plyvel_8Iterator_real_next;
  __pyx_vtable_6plyvel_7_plyvel_Iterator.real_prev = (PyObject *(*)(struct __pyx_obj_6plyvel_7_plyvel_Iterator *))__pyx_f_6plyvel_7_plyvel_8Iterator_real_prev;
  if (PyType_Ready(&__pyx_type_6plyvel_7_plyvel_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6plyvel_7_plyvel_Iterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_6plyvel_7_plyvel_8Iterator_6__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_6plyvel_7_plyvel_8Iterator_6__next__.doc = __pyx_doc_6plyvel_7_plyvel_8Iterator_6__next__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6plyvel_7_plyvel_8Iterator_6__next__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_6plyvel_7_plyvel_Iterator.tp_dict, __pyx_vtabptr_6plyvel_7_plyvel_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Iterator", (PyObject *)&__pyx_type_6plyvel_7_plyvel_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_6plyvel_7_plyvel_Iterator.tp_weaklistoffset == 0) __pyx_type_6plyvel_7_plyvel_Iterator.tp_weaklistoffset = offsetof(struct __pyx_obj_6plyvel_7_plyvel_Iterator, __weakref__);
  __pyx_ptype_6plyvel_7_plyvel_Iterator = &__pyx_type_6plyvel_7_plyvel_Iterator;
  if (PyType_Ready(&__pyx_type_6plyvel_7_plyvel_Snapshot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Snapshot", (PyObject *)&__pyx_type_6plyvel_7_plyvel_Snapshot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_6plyvel_7_plyvel_Snapshot = &__pyx_type_6plyvel_7_plyvel_Snapshot;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "plyvel/_plyvel.pyx":19
 * """
 * 
 * import sys             # <<<<<<<<<<<<<<
 * import threading
 * import weakref
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plyvel/_plyvel.pyx":20
 * 
 * import sys
 * import threading             # <<<<<<<<<<<<<<
 * import weakref
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__threading), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__threading, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plyvel/_plyvel.pyx":21
 * import sys
 * import threading
 * import weakref             # <<<<<<<<<<<<<<
 * 
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__weakref), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__weakref, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plyvel/_plyvel.pyx":50
 * 
 * 
 * __leveldb_version__ = '%d.%d' % (leveldb.kMajorVersion,             # <<<<<<<<<<<<<<
 *                                  leveldb.kMinorVersion)
 * 
 */
  __pyx_t_1 = PyInt_FromLong(leveldb::kMajorVersion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plyvel/_plyvel.pyx":51
 * 
 * __leveldb_version__ = '%d.%d' % (leveldb.kMajorVersion,
 *                                  leveldb.kMinorVersion)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyInt_FromLong(leveldb::kMinorVersion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____leveldb_version__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":58
 * #
 * 
 * class Error(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2), __pyx_n_s__Error, __pyx_n_s_67); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Error, __pyx_t_1) < 0) {__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_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":62
 * 
 * 
 * class IOError(Error, IOError):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__IOError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __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);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_2), __pyx_n_s__IOError, __pyx_n_s_67); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IOError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":66
 * 
 * 
 * class CorruptionError(Error):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__Error); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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 = __Pyx_CreateClass(((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_2), __pyx_n_s__CorruptionError, __pyx_n_s_67); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CorruptionError, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":327
 *         raise_for_status(st)
 * 
 *     def write_batch(self, *, transaction=False, sync=None):             # <<<<<<<<<<<<<<
 *         if self._db is NULL:
 *             raise RuntimeError("Cannot operate on closed LevelDB database")
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_21 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":339
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_24 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":340
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_25 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_26 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":341
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_27 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_28 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":441
 *         return self.db.delete(self.prefix + key, sync=sync)
 * 
 *     def write_batch(self, *, transaction=False, sync=None):             # <<<<<<<<<<<<<<
 *         return WriteBatch(
 *             db=self.db, prefix=self.prefix, transaction=transaction, sync=sync)
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_35 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":448
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_36 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":449
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_37 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_38 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":450
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_39 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_40 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":466
 * 
 * 
 * def repair_db(name, *, paranoid_checks=None, write_buffer_size=None,             # <<<<<<<<<<<<<<
 *               max_open_files=None, lru_cache_size=None, block_size=None,
 *               block_restart_interval=None, compression='snappy',
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6plyvel_7_plyvel_1repair_db, NULL, __pyx_n_s_67); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__repair_db, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":488
 * 
 * 
 * def destroy_db(name):             # <<<<<<<<<<<<<<
 *     cdef Options options = Options()
 *     cdef Status st
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6plyvel_7_plyvel_3destroy_db, NULL, __pyx_n_s_67); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__destroy_db, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":960
 *         return self.iterator()
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,             # <<<<<<<<<<<<<<
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_58 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":961
 * 
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,             # <<<<<<<<<<<<<<
 *                  include_key=True, include_value=True, verify_checksums=None,
 *                  fill_cache=None):
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_59 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_60 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":962
 *     def iterator(self, *, reverse=False, start=None, stop=None,
 *                  include_start=True, include_stop=False, prefix=None,
 *                  include_key=True, include_value=True, verify_checksums=None,             # <<<<<<<<<<<<<<
 *                  fill_cache=None):
 *         return Iterator(
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_61 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_62 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plyvel/_plyvel.pyx":1
 * # cython: embedsignature=True             # <<<<<<<<<<<<<<
 * 
 * #
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;

  /* "string.from_py":11
 * 
 * @cname("__pyx_convert_string_from_py_")
 * cdef string __pyx_convert_string_from_py_(object o) except *:             # <<<<<<<<<<<<<<
 *     return string(<char*>o, len(o))
 * 
 */
  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);
  if (__pyx_m) {
    __Pyx_AddTraceback("init plyvel._plyvel", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init plyvel._plyvel");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    #if PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *args;
        if (!value)
            args = PyTuple_New(0);
        else if (PyTuple_Check(value)) {
            Py_INCREF(value);
            args = value;
        }
        else
            args = PyTuple_Pack(1, value);
        if (!args)
            goto bad;
        owned_instance = PyEval_CallObject(type, args);
        Py_DECREF(args);
        if (!owned_instance)
            goto bad;
        value = owned_instance;
        if (!PyExceptionInstance_Check(value)) {
            PyErr_Format(PyExc_TypeError,
                         "calling %R should have returned an instance of "
                         "BaseException, not %R",
                         type, Py_TYPE(value));
            goto bad;
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause && cause != Py_None) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (DECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CPYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE void __Pyx_RaiseKeywordRequired(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() needs keyword-only argument %U", func_name, kw_name);
        #else
        "%s() needs keyword-only argument %s", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                /* try package relative import first */
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, (char *)"__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;
    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t val) {
    const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(uint64_t) == sizeof(char))  ||
        (sizeof(uint64_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(uint64_t) == sizeof(int)) ||
               (sizeof(uint64_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}


/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
