/* Generated by Cython 0.19 on Wed May  8 14:39:59 2013 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#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 __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #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"
  #define __Pyx_PyIndex_Check PyIndex_Check
#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 < 0x02060000
  #define Py_TPFLAGS_HAVE_VERSION_TAG 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_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
                                         PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type)
#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
#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
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#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__bitfield
#define __PYX_HAVE_API__bitfield
#include "string.h"
#include "unistd.h"
#include "stdlib.h"
#include "field.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#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 Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return u_end - u - 1;
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#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))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (ascii_chars_u == NULL) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
    }
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    default_encoding_c = PyBytes_AS_STRING(default_encoding);
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(sys);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


#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_d;
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[] = {
  "field.pyx",
};

/* "cimpl/field.pyx":11
 * from cython cimport view
 * 
 * ctypedef Py_ssize_t size_t             # <<<<<<<<<<<<<<
 * 
 * cdef extern:
 */
typedef Py_ssize_t __pyx_t_8bitfield_size_t;

/*--- Type declarations ---*/
struct __pyx_obj_8bitfield_PageIter;
struct __pyx_obj_8bitfield_IdsPage;
struct __pyx_obj_8bitfield_BitfieldIterator;
struct __pyx_obj_8bitfield_Bitfield;
struct __pyx_opt_args_8bitfield_7IdsPage__alloc;

/* "cimpl/field.pyx":184
 *         self._dealloc(PAGE_EMPTY)
 * 
 *     cdef void _alloc(self, int fill=0):             # <<<<<<<<<<<<<<
 *         assert(self.data == NULL)
 *         self.page_state = PAGE_PARTIAL
 */
struct __pyx_opt_args_8bitfield_7IdsPage__alloc {
  int __pyx_n;
  int fill;
};

/* "cimpl/field.pyx":70
 * 
 * 
 * cdef class PageIter:             # <<<<<<<<<<<<<<
 *     cdef usize_t chunk
 *     cdef usize_t bit_index
 */
struct __pyx_obj_8bitfield_PageIter {
  PyObject_HEAD
  struct __pyx_vtabstruct_8bitfield_PageIter *__pyx_vtab;
  usize_t chunk;
  usize_t bit_index;
  usize_t number;
  struct __pyx_obj_8bitfield_IdsPage *page;
};


/* "cimpl/field.pyx":160
 * 
 * 
 * cdef class IdsPage:             # <<<<<<<<<<<<<<
 *     cdef int page_state
 *     cdef usize_t _count
 */
struct __pyx_obj_8bitfield_IdsPage {
  PyObject_HEAD
  struct __pyx_vtabstruct_8bitfield_IdsPage *__pyx_vtab;
  int page_state;
  usize_t _count;
  CHUNK *data;
};


/* "cimpl/field.pyx":114
 * 
 * 
 * cdef class BitfieldIterator:             # <<<<<<<<<<<<<<
 *     """
 *     Performs correctly when bitfields are mutating during iteration.
 */
struct __pyx_obj_8bitfield_BitfieldIterator {
  PyObject_HEAD
  struct __pyx_vtabstruct_8bitfield_BitfieldIterator *__pyx_vtab;
  struct __pyx_obj_8bitfield_Bitfield *bitfield;
  struct __pyx_obj_8bitfield_PageIter *current_iter;
  usize_t current_page;
  usize_t offset;
};


/* "cimpl/field.pyx":419
 * 
 * 
 * cdef class Bitfield:             # <<<<<<<<<<<<<<
 *     """Efficient storage, and set-like operations on groups of positive integers
 *     Currently, all integers must be in the range 0 >= x >= bitfield.get_all_sizes()["BITFIELD_MAX"].
 */
struct __pyx_obj_8bitfield_Bitfield {
  PyObject_HEAD
  struct __pyx_vtabstruct_8bitfield_Bitfield *__pyx_vtab;
  PyObject *pages;
};



/* "cimpl/field.pyx":114
 * 
 * 
 * cdef class BitfieldIterator:             # <<<<<<<<<<<<<<
 *     """
 *     Performs correctly when bitfields are mutating during iteration.
 */

struct __pyx_vtabstruct_8bitfield_BitfieldIterator {
  PyObject *(*_next_iter)(struct __pyx_obj_8bitfield_BitfieldIterator *);
};
static struct __pyx_vtabstruct_8bitfield_BitfieldIterator *__pyx_vtabptr_8bitfield_BitfieldIterator;
static CYTHON_INLINE PyObject *__pyx_f_8bitfield_16BitfieldIterator__next_iter(struct __pyx_obj_8bitfield_BitfieldIterator *);


/* "cimpl/field.pyx":419
 * 
 * 
 * cdef class Bitfield:             # <<<<<<<<<<<<<<
 *     """Efficient storage, and set-like operations on groups of positive integers
 *     Currently, all integers must be in the range 0 >= x >= bitfield.get_all_sizes()["BITFIELD_MAX"].
 */

struct __pyx_vtabstruct_8bitfield_Bitfield {
  PyObject *(*_ensure_page_exists)(struct __pyx_obj_8bitfield_Bitfield *, usize_t);
  PyObject *(*_cleanup)(struct __pyx_obj_8bitfield_Bitfield *);
  PyObject *(*add)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch);
  PyObject *(*remove)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch);
  PyObject *(*discard)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch);
  PyObject *(*update)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*difference_update)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*symmetric_difference_update)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*symmetric_difference)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*intersection_update)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*intersection)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*isdisjoint)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*issubset)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*issuperset)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*copy)(struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*clone)(struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch);
  PyObject *(*load)(struct __pyx_obj_8bitfield_Bitfield *, PyObject *);
  PyObject *(*load_from_bytes)(struct __pyx_obj_8bitfield_Bitfield *, PyObject *);
  PyObject *(*fill_range)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, usize_t);
};
static struct __pyx_vtabstruct_8bitfield_Bitfield *__pyx_vtabptr_8bitfield_Bitfield;


/* "cimpl/field.pyx":70
 * 
 * 
 * cdef class PageIter:             # <<<<<<<<<<<<<<
 *     cdef usize_t chunk
 *     cdef usize_t bit_index
 */

struct __pyx_vtabstruct_8bitfield_PageIter {
  usize_t (*_advance)(struct __pyx_obj_8bitfield_PageIter *);
  PyObject *(*_next)(struct __pyx_obj_8bitfield_PageIter *);
};
static struct __pyx_vtabstruct_8bitfield_PageIter *__pyx_vtabptr_8bitfield_PageIter;




/* "cimpl/field.pyx":160
 * 
 * 
 * cdef class IdsPage:             # <<<<<<<<<<<<<<
 *     cdef int page_state
 *     cdef usize_t _count
 */

struct __pyx_vtabstruct_8bitfield_IdsPage {
  void (*_fill)(struct __pyx_obj_8bitfield_IdsPage *, CHUNK);
  void (*set_full)(struct __pyx_obj_8bitfield_IdsPage *);
  void (*set_empty)(struct __pyx_obj_8bitfield_IdsPage *);
  void (*_alloc)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_opt_args_8bitfield_7IdsPage__alloc *__pyx_optional_args);
  void (*_dealloc)(struct __pyx_obj_8bitfield_IdsPage *, int);
  PyObject *(*_iter)(struct __pyx_obj_8bitfield_IdsPage *);
  void (*calc_length)(struct __pyx_obj_8bitfield_IdsPage *);
  void (*add)(struct __pyx_obj_8bitfield_IdsPage *, usize_t);
  void (*remove)(struct __pyx_obj_8bitfield_IdsPage *, usize_t);
  void (*update)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *);
  void (*intersection_update)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *);
  void (*difference_update)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *);
  char const *(*_state)(struct __pyx_obj_8bitfield_IdsPage *);
  PyObject *(*symmetric_difference_update)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *);
  struct __pyx_obj_8bitfield_IdsPage *(*clone)(struct __pyx_obj_8bitfield_IdsPage *);
  char *(*set_bits)(struct __pyx_obj_8bitfield_IdsPage *, char *, char *);
};
static struct __pyx_vtabstruct_8bitfield_IdsPage *__pyx_vtabptr_8bitfield_IdsPage;
static CYTHON_INLINE char const *__pyx_f_8bitfield_7IdsPage__state(struct __pyx_obj_8bitfield_IdsPage *);

#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)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/

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 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*/

#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

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

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

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

#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact
#define PyAnySet_CheckExact(ob) \
    ((ob)->ob_type == &PySet_Type || \
     (ob)->ob_type == &PyFrozenSet_Type)
#define PySet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
#define Pyx_PyFrozenSet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
#define PySet_Size(anyset) \
    PyObject_Size((anyset))
#define PySet_Contains(anyset, key) \
    PySequence_Contains((anyset), (key))
#define PySet_Pop(set) \
    PyObject_CallMethod(set, (char *)"pop", NULL)
static CYTHON_INLINE int PySet_Clear(PyObject *set) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
#endif /* PyAnySet_CheckExact (<= Py2.4) */
#endif /* < Py2.5  */

#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) & likely(len > (L->allocated >> 1))) {
        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 PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) {
    PyObject *method, *result = NULL;
    if (unlikely(!args)) return NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
    result = PyObject_Call(method, args, NULL);
    Py_DECREF(method);
bad:
    Py_DECREF(args);
    return result;
}
#define __Pyx_PyObject_CallMethod3(obj, name, arg1, arg2, arg3) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(3, arg1, arg2, arg3))
#define __Pyx_PyObject_CallMethod2(obj, name, arg1, arg2) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(2, arg1, arg2))
#define __Pyx_PyObject_CallMethod1(obj, name, arg1) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1))
#define __Pyx_PyObject_CallMethod0(obj, name) \
    __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple))

static CYTHON_INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L); /*proto*/

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*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*/

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/

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, int level); /*proto*/

static CYTHON_INLINE usize_t __Pyx_PyInt_from_py_usize_t(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_usize_t(usize_t);

#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/

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 void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

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.view' */

/* Module declarations from 'cython' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'bitfield' */
static PyTypeObject *__pyx_ptype_8bitfield_PageIter = 0;
static PyTypeObject *__pyx_ptype_8bitfield_BitfieldIterator = 0;
static PyTypeObject *__pyx_ptype_8bitfield_IdsPage = 0;
static PyTypeObject *__pyx_ptype_8bitfield_Bitfield = 0;
static PyObject *__pyx_v_8bitfield_PICKLE_MARKER = 0;
static PyObject *__pyx_v_8bitfield_PICKLE_MARKER_zlib = 0;
__PYX_EXTERN_C DL_IMPORT(int) __builtin_popcountl(size_t); /*proto*/
static PyObject *__pyx_f_8bitfield_unpickle_bitfield(PyObject *, int __pyx_skip_dispatch); /*proto*/
#define __Pyx_MODULE_NAME "bitfield"
int __pyx_module_is_main_bitfield = 0;

/* Implementation of 'bitfield' */
static PyObject *__pyx_builtin_bin;
static PyObject *__pyx_builtin_StopIteration;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_AssertionError;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_memoryview;
static PyObject *__pyx_pf_8bitfield_get_all_sizes(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static int __pyx_pf_8bitfield_8PageIter___cinit__(struct __pyx_obj_8bitfield_PageIter *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page); /* proto */
static PyObject *__pyx_pf_8bitfield_8PageIter_2__next__(struct __pyx_obj_8bitfield_PageIter *__pyx_v_self); /* proto */
static int __pyx_pf_8bitfield_16BitfieldIterator___cinit__(struct __pyx_obj_8bitfield_BitfieldIterator *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_bitfield); /* proto */
static PyObject *__pyx_pf_8bitfield_16BitfieldIterator_2__next__(struct __pyx_obj_8bitfield_BitfieldIterator *__pyx_v_self); /* proto */
static int __pyx_pf_8bitfield_7IdsPage___cinit__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self); /* proto */
static void __pyx_pf_8bitfield_7IdsPage_2__dealloc__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_7IdsPage_4__iter__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_7IdsPage_5count___get__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self); /* proto */
static int __pyx_pf_8bitfield_7IdsPage_6__contains__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, usize_t __pyx_v_number); /* proto */
static PyObject *__pyx_pf_8bitfield_7IdsPage_8__richcmp__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_a, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_b, PyObject *__pyx_v_operator); /* proto */
static int __pyx_pf_8bitfield_8Bitfield___cinit__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v__data); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_2add(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_4remove(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_6discard(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_5count___get__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_8bitfield_8Bitfield_8__len__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static int __pyx_pf_8bitfield_8Bitfield_10__contains__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_number); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_12__iter__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_14__richcmp__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_a, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_b, PyObject *__pyx_v_operator); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_16__or__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_18__ior__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_20union(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_22__add__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, usize_t __pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_24__iadd__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, usize_t __pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_26__sub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_28__isub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_30__isub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_32__xor__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_34__ixor__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_36__and__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_38__iand__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_40update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_42difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_44symmetric_difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_46symmetric_difference(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_48intersection_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_50intersection(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_52isdisjoint(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_54issubset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_56issuperset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_58copy(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_60clone(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static int __pyx_pf_8bitfield_8Bitfield_62__getbuffer__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, Py_buffer *__pyx_v_view, int __pyx_v_flags); /* proto */
static void __pyx_pf_8bitfield_8Bitfield_64__releasebuffer__(CYTHON_UNUSED struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, Py_buffer *__pyx_v_view); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_66pickle(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_compress); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_68unpickle(CYTHON_UNUSED PyObject *__pyx_v_cls, PyObject *__pyx_v_data); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_70__reduce__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_72from_intervals(CYTHON_UNUSED PyObject *__pyx_v_cls, PyObject *__pyx_v_list); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_74__str__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_76__repr__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_8Bitfield_78clear(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8bitfield_2unpickle_bitfield(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data); /* proto */
static PyObject *__pyx_tp_new_8bitfield_PageIter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8bitfield_BitfieldIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8bitfield_IdsPage(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8bitfield_Bitfield(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_1[] = "Cannot test for %i in a page (overflow)";
static char __pyx_k_2[] = "Cannot add %i to a page (overflow)";
static char __pyx_k_3[] = "Cannot remove %i from a page (overflow)";
static char __pyx_k_4[] = "Invalid page state";
static char __pyx_k_7[] = "symmetric_difference_update";
static char __pyx_k_8[] = "symmetric_difference";
static char __pyx_k_9[] = "bitfields do not provide writable buffers";
static char __pyx_k_12[] = "Could not unpickle data";
static char __pyx_k_14[] = "Could not unpickle data. Invalid page state: %s";
static char __pyx_k_15[] = "Bitfield(len=%i, range=0 > ~%i)";
static char __pyx_k_16[] = "%s.%s(%r)";
static char __pyx_k_17[] = "The number of integers in the field";
static char __pyx_k_19[] = "/home/sstagg/src/bitfield/cimpl/field.pyx";
static char __pyx_k_20[] = "BF:";
static char __pyx_k_21[] = "BZ:";
static char __pyx_k__B[] = "B";
static char __pyx_k__add[] = "add";
static char __pyx_k__bin[] = "bin";
static char __pyx_k__pop[] = "pop";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__FULL[] = "FULL";
static char __pyx_k__copy[] = "copy";
static char __pyx_k__page[] = "page";
static char __pyx_k__zlib[] = "zlib";
static char __pyx_k__EMPTY[] = "EMPTY";
static char __pyx_k__ERROR[] = "ERROR";
static char __pyx_k___data[] = "_data";
static char __pyx_k__clone[] = "clone";
static char __pyx_k__count[] = "count";
static char __pyx_k__range[] = "range";
static char __pyx_k__pickle[] = "pickle";
static char __pyx_k__remove[] = "remove";
static char __pyx_k__update[] = "update";
static char __pyx_k__PARTIAL[] = "PARTIAL";
static char __pyx_k__discard[] = "discard";
static char __pyx_k__tobytes[] = "tobytes";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k__PAGE_MAX[] = "PAGE_MAX";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____name__[] = "__name__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__bitfield[] = "bitfield";
static char __pyx_k__compress[] = "compress";
static char __pyx_k__issubset[] = "issubset";
static char __pyx_k__unpickle[] = "unpickle";
static char __pyx_k____slots__[] = "__slots__";
static char __pyx_k__CHUNK_BITS[] = "CHUNK_BITS";
static char __pyx_k__CHUNK_MASK[] = "CHUNK_MASK";
static char __pyx_k__PAGE_BYTES[] = "PAGE_BYTES";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k____import__[] = "__import__";
static char __pyx_k____module__[] = "__module__";
static char __pyx_k__decompress[] = "decompress";
static char __pyx_k__isdisjoint[] = "isdisjoint";
static char __pyx_k__issuperset[] = "issuperset";
static char __pyx_k__memoryview[] = "memoryview";
static char __pyx_k__CHUNK_BYTES[] = "CHUNK_BYTES";
static char __pyx_k__CHUNK_SHIFT[] = "CHUNK_SHIFT";
static char __pyx_k__PAGE_CHUNKS[] = "PAGE_CHUNKS";
static char __pyx_k__BITFIELD_MAX[] = "BITFIELD_MAX";
static char __pyx_k__intersection[] = "intersection";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k__get_all_sizes[] = "get_all_sizes";
static char __pyx_k__AssertionError[] = "AssertionError";
static char __pyx_k__from_intervals[] = "from_intervals";
static char __pyx_k__PAGE_FULL_COUNT[] = "PAGE_FULL_COUNT";
static char __pyx_k__CHUNK_FULL_COUNT[] = "CHUNK_FULL_COUNT";
static char __pyx_k__difference_update[] = "difference_update";
static char __pyx_k__unpickle_bitfield[] = "unpickle_bitfield";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static char __pyx_k__intersection_update[] = "intersection_update";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_n_s_7;
static PyObject *__pyx_n_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__AssertionError;
static PyObject *__pyx_n_s__BITFIELD_MAX;
static PyObject *__pyx_n_s__CHUNK_BITS;
static PyObject *__pyx_n_s__CHUNK_BYTES;
static PyObject *__pyx_n_s__CHUNK_FULL_COUNT;
static PyObject *__pyx_n_s__CHUNK_MASK;
static PyObject *__pyx_n_s__CHUNK_SHIFT;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__PAGE_BYTES;
static PyObject *__pyx_n_s__PAGE_CHUNKS;
static PyObject *__pyx_n_s__PAGE_FULL_COUNT;
static PyObject *__pyx_n_s__PAGE_MAX;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____import__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____module__;
static PyObject *__pyx_n_s____name__;
static PyObject *__pyx_n_s____slots__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___data;
static PyObject *__pyx_n_s__add;
static PyObject *__pyx_n_s__bin;
static PyObject *__pyx_n_s__bitfield;
static PyObject *__pyx_n_s__clone;
static PyObject *__pyx_n_s__compress;
static PyObject *__pyx_n_s__copy;
static PyObject *__pyx_n_s__count;
static PyObject *__pyx_n_s__decompress;
static PyObject *__pyx_n_s__difference_update;
static PyObject *__pyx_n_s__discard;
static PyObject *__pyx_n_s__from_intervals;
static PyObject *__pyx_n_s__get_all_sizes;
static PyObject *__pyx_n_s__intersection;
static PyObject *__pyx_n_s__intersection_update;
static PyObject *__pyx_n_s__isdisjoint;
static PyObject *__pyx_n_s__issubset;
static PyObject *__pyx_n_s__issuperset;
static PyObject *__pyx_n_s__memoryview;
static PyObject *__pyx_n_s__page;
static PyObject *__pyx_n_s__pickle;
static PyObject *__pyx_n_s__pop;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__remove;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__tobytes;
static PyObject *__pyx_n_s__unpickle;
static PyObject *__pyx_n_s__unpickle_bitfield;
static PyObject *__pyx_n_s__update;
static PyObject *__pyx_n_s__zlib;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_k_11;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_codeobj_18;

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_1get_all_sizes(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_8bitfield_1get_all_sizes = {__Pyx_NAMESTR("get_all_sizes"), (PyCFunction)__pyx_pw_8bitfield_1get_all_sizes, METH_NOARGS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_8bitfield_1get_all_sizes(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_all_sizes (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_get_all_sizes(__pyx_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":55
 * 
 * 
 * def get_all_sizes():             # <<<<<<<<<<<<<<
 *     return dict(
 *         CHUNK_BYTES=CHUNK_BYTES,
 */

static PyObject *__pyx_pf_8bitfield_get_all_sizes(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("get_all_sizes", 0);

  /* "cimpl/field.pyx":56
 * 
 * def get_all_sizes():
 *     return dict(             # <<<<<<<<<<<<<<
 *         CHUNK_BYTES=CHUNK_BYTES,
 *         CHUNK_SHIFT=CHUNK_SHIFT,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "cimpl/field.pyx":57
 * def get_all_sizes():
 *     return dict(
 *         CHUNK_BYTES=CHUNK_BYTES,             # <<<<<<<<<<<<<<
 *         CHUNK_SHIFT=CHUNK_SHIFT,
 *         CHUNK_MASK=bin(CHUNK_MASK),
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(CHUNK_BYTES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CHUNK_BYTES), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":58
 *     return dict(
 *         CHUNK_BYTES=CHUNK_BYTES,
 *         CHUNK_SHIFT=CHUNK_SHIFT,             # <<<<<<<<<<<<<<
 *         CHUNK_MASK=bin(CHUNK_MASK),
 *         CHUNK_FULL_COUNT=CHUNK_FULL_COUNT,
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(CHUNK_SHIFT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CHUNK_SHIFT), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":59
 *         CHUNK_BYTES=CHUNK_BYTES,
 *         CHUNK_SHIFT=CHUNK_SHIFT,
 *         CHUNK_MASK=bin(CHUNK_MASK),             # <<<<<<<<<<<<<<
 *         CHUNK_FULL_COUNT=CHUNK_FULL_COUNT,
 *         CHUNK_BITS=bin(CHUNK_BITS),
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(CHUNK_MASK); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_bin, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CHUNK_MASK), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":60
 *         CHUNK_SHIFT=CHUNK_SHIFT,
 *         CHUNK_MASK=bin(CHUNK_MASK),
 *         CHUNK_FULL_COUNT=CHUNK_FULL_COUNT,             # <<<<<<<<<<<<<<
 *         CHUNK_BITS=bin(CHUNK_BITS),
 *         BITFIELD_MAX=USIZE_MAX,
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(CHUNK_FULL_COUNT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CHUNK_FULL_COUNT), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":61
 *         CHUNK_MASK=bin(CHUNK_MASK),
 *         CHUNK_FULL_COUNT=CHUNK_FULL_COUNT,
 *         CHUNK_BITS=bin(CHUNK_BITS),             # <<<<<<<<<<<<<<
 *         BITFIELD_MAX=USIZE_MAX,
 *         PAGE_CHUNKS=PAGE_CHUNKS,
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(CHUNK_BITS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_bin, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CHUNK_BITS), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":62
 *         CHUNK_FULL_COUNT=CHUNK_FULL_COUNT,
 *         CHUNK_BITS=bin(CHUNK_BITS),
 *         BITFIELD_MAX=USIZE_MAX,             # <<<<<<<<<<<<<<
 *         PAGE_CHUNKS=PAGE_CHUNKS,
 *         PAGE_FULL_COUNT=PAGE_FULL_COUNT,
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(USIZE_MAX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__BITFIELD_MAX), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":63
 *         CHUNK_BITS=bin(CHUNK_BITS),
 *         BITFIELD_MAX=USIZE_MAX,
 *         PAGE_CHUNKS=PAGE_CHUNKS,             # <<<<<<<<<<<<<<
 *         PAGE_FULL_COUNT=PAGE_FULL_COUNT,
 *         PAGE_BYTES=PAGE_BYTES,
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(PAGE_CHUNKS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PAGE_CHUNKS), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":64
 *         BITFIELD_MAX=USIZE_MAX,
 *         PAGE_CHUNKS=PAGE_CHUNKS,
 *         PAGE_FULL_COUNT=PAGE_FULL_COUNT,             # <<<<<<<<<<<<<<
 *         PAGE_BYTES=PAGE_BYTES,
 *         PAGE_MAX=PAGE_FULL_COUNT
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(PAGE_FULL_COUNT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PAGE_FULL_COUNT), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":65
 *         PAGE_CHUNKS=PAGE_CHUNKS,
 *         PAGE_FULL_COUNT=PAGE_FULL_COUNT,
 *         PAGE_BYTES=PAGE_BYTES,             # <<<<<<<<<<<<<<
 *         PAGE_MAX=PAGE_FULL_COUNT
 *     )
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(PAGE_BYTES); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PAGE_BYTES), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":67
 *         PAGE_BYTES=PAGE_BYTES,
 *         PAGE_MAX=PAGE_FULL_COUNT
 *     )             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(PAGE_FULL_COUNT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PAGE_MAX), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.get_all_sizes", __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_8bitfield_8PageIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8bitfield_8PageIter_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__page,0};
    PyObject* values[1] = {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  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__page)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __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_page = ((struct __pyx_obj_8bitfield_IdsPage *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.PageIter.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_page), __pyx_ptype_8bitfield_IdsPage, 1, "page", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8PageIter___cinit__(((struct __pyx_obj_8bitfield_PageIter *)__pyx_v_self), __pyx_v_page);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":76
 *     cdef IdsPage page
 * 
 *     def __cinit__(self, IdsPage page):             # <<<<<<<<<<<<<<
 *         self.page = page
 *         self.chunk = 0
 */

static int __pyx_pf_8bitfield_8PageIter___cinit__(struct __pyx_obj_8bitfield_PageIter *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "cimpl/field.pyx":77
 * 
 *     def __cinit__(self, IdsPage page):
 *         self.page = page             # <<<<<<<<<<<<<<
 *         self.chunk = 0
 *         self.bit_index = 0
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_page));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_page));
  __Pyx_GOTREF(__pyx_v_self->page);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->page));
  __pyx_v_self->page = __pyx_v_page;

  /* "cimpl/field.pyx":78
 *     def __cinit__(self, IdsPage page):
 *         self.page = page
 *         self.chunk = 0             # <<<<<<<<<<<<<<
 *         self.bit_index = 0
 *         self.number = 0
 */
  __pyx_v_self->chunk = 0;

  /* "cimpl/field.pyx":79
 *         self.page = page
 *         self.chunk = 0
 *         self.bit_index = 0             # <<<<<<<<<<<<<<
 *         self.number = 0
 * 
 */
  __pyx_v_self->bit_index = 0;

  /* "cimpl/field.pyx":80
 *         self.chunk = 0
 *         self.bit_index = 0
 *         self.number = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef usize_t _advance(self):
 */
  __pyx_v_self->number = 0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":82
 *         self.number = 0
 * 
 *     cdef usize_t _advance(self):             # <<<<<<<<<<<<<<
 *         cdef usize_t number = self.number
 *         self.number += 1
 */

static usize_t __pyx_f_8bitfield_8PageIter__advance(struct __pyx_obj_8bitfield_PageIter *__pyx_v_self) {
  usize_t __pyx_v_number;
  usize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  usize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_advance", 0);

  /* "cimpl/field.pyx":83
 * 
 *     cdef usize_t _advance(self):
 *         cdef usize_t number = self.number             # <<<<<<<<<<<<<<
 *         self.number += 1
 *         self.bit_index += 1
 */
  __pyx_t_1 = __pyx_v_self->number;
  __pyx_v_number = __pyx_t_1;

  /* "cimpl/field.pyx":84
 *     cdef usize_t _advance(self):
 *         cdef usize_t number = self.number
 *         self.number += 1             # <<<<<<<<<<<<<<
 *         self.bit_index += 1
 *         if self.bit_index >= CHUNK_FULL_COUNT:
 */
  __pyx_v_self->number = (__pyx_v_self->number + 1);

  /* "cimpl/field.pyx":85
 *         cdef usize_t number = self.number
 *         self.number += 1
 *         self.bit_index += 1             # <<<<<<<<<<<<<<
 *         if self.bit_index >= CHUNK_FULL_COUNT:
 *             self.bit_index = 0
 */
  __pyx_v_self->bit_index = (__pyx_v_self->bit_index + 1);

  /* "cimpl/field.pyx":86
 *         self.number += 1
 *         self.bit_index += 1
 *         if self.bit_index >= CHUNK_FULL_COUNT:             # <<<<<<<<<<<<<<
 *             self.bit_index = 0
 *             self.chunk += 1
 */
  __pyx_t_2 = (__pyx_v_self->bit_index >= CHUNK_FULL_COUNT);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":87
 *         self.bit_index += 1
 *         if self.bit_index >= CHUNK_FULL_COUNT:
 *             self.bit_index = 0             # <<<<<<<<<<<<<<
 *             self.chunk += 1
 *             if self.page.page_state == PAGE_PARTIAL:
 */
    __pyx_v_self->bit_index = 0;

    /* "cimpl/field.pyx":88
 *         if self.bit_index >= CHUNK_FULL_COUNT:
 *             self.bit_index = 0
 *             self.chunk += 1             # <<<<<<<<<<<<<<
 *             if self.page.page_state == PAGE_PARTIAL:
 *                 while self.chunk < PAGE_CHUNKS and self.page.data[self.chunk] == 0:
 */
    __pyx_v_self->chunk = (__pyx_v_self->chunk + 1);

    /* "cimpl/field.pyx":89
 *             self.bit_index = 0
 *             self.chunk += 1
 *             if self.page.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 while self.chunk < PAGE_CHUNKS and self.page.data[self.chunk] == 0:
 *                     self.chunk += 1
 */
    __pyx_t_2 = (__pyx_v_self->page->page_state == 1);
    if (__pyx_t_2) {

      /* "cimpl/field.pyx":90
 *             self.chunk += 1
 *             if self.page.page_state == PAGE_PARTIAL:
 *                 while self.chunk < PAGE_CHUNKS and self.page.data[self.chunk] == 0:             # <<<<<<<<<<<<<<
 *                     self.chunk += 1
 *                     self.number += CHUNK_FULL_COUNT
 */
      while (1) {
        __pyx_t_2 = (__pyx_v_self->chunk < PAGE_CHUNKS);
        if (__pyx_t_2) {
          __pyx_t_3 = ((__pyx_v_self->page->data[__pyx_v_self->chunk]) == 0);
          __pyx_t_4 = __pyx_t_3;
        } else {
          __pyx_t_4 = __pyx_t_2;
        }
        if (!__pyx_t_4) break;

        /* "cimpl/field.pyx":91
 *             if self.page.page_state == PAGE_PARTIAL:
 *                 while self.chunk < PAGE_CHUNKS and self.page.data[self.chunk] == 0:
 *                     self.chunk += 1             # <<<<<<<<<<<<<<
 *                     self.number += CHUNK_FULL_COUNT
 *         return number
 */
        __pyx_v_self->chunk = (__pyx_v_self->chunk + 1);

        /* "cimpl/field.pyx":92
 *                 while self.chunk < PAGE_CHUNKS and self.page.data[self.chunk] == 0:
 *                     self.chunk += 1
 *                     self.number += CHUNK_FULL_COUNT             # <<<<<<<<<<<<<<
 *         return number
 * 
 */
        __pyx_v_self->number = (__pyx_v_self->number + CHUNK_FULL_COUNT);
      }
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":93
 *                     self.chunk += 1
 *                     self.number += CHUNK_FULL_COUNT
 *         return number             # <<<<<<<<<<<<<<
 * 
 *     cdef _next(self):
 */
  __pyx_r = __pyx_v_number;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":95
 *         return number
 * 
 *     cdef _next(self):             # <<<<<<<<<<<<<<
 *         if self.chunk >= PAGE_CHUNKS:
 *             raise StopIteration()
 */

static PyObject *__pyx_f_8bitfield_8PageIter__next(struct __pyx_obj_8bitfield_PageIter *__pyx_v_self) {
  usize_t __pyx_v_test;
  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);

  /* "cimpl/field.pyx":96
 * 
 *     cdef _next(self):
 *         if self.chunk >= PAGE_CHUNKS:             # <<<<<<<<<<<<<<
 *             raise StopIteration()
 *         if self.page.page_state == PAGE_EMPTY:
 */
  __pyx_t_1 = (__pyx_v_self->chunk >= PAGE_CHUNKS);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":97
 *     cdef _next(self):
 *         if self.chunk >= PAGE_CHUNKS:
 *             raise StopIteration()             # <<<<<<<<<<<<<<
 *         if self.page.page_state == PAGE_EMPTY:
 *             raise StopIteration()
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_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 = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":100
 *         if self.page.page_state == PAGE_EMPTY:
 *             raise StopIteration()
 *         elif self.page.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return self._advance()
 *         while 1:
 */
  switch (__pyx_v_self->page->page_state) {

    /* "cimpl/field.pyx":98
 *         if self.chunk >= PAGE_CHUNKS:
 *             raise StopIteration()
 *         if self.page.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             raise StopIteration()
 *         elif self.page.page_state == PAGE_FULL:
 */
    case 3:

    /* "cimpl/field.pyx":99
 *             raise StopIteration()
 *         if self.page.page_state == PAGE_EMPTY:
 *             raise StopIteration()             # <<<<<<<<<<<<<<
 *         elif self.page.page_state == PAGE_FULL:
 *             return self._advance()
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __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 = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;

    /* "cimpl/field.pyx":100
 *         if self.page.page_state == PAGE_EMPTY:
 *             raise StopIteration()
 *         elif self.page.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return self._advance()
 *         while 1:
 */
    case 2:

    /* "cimpl/field.pyx":101
 *             raise StopIteration()
 *         elif self.page.page_state == PAGE_FULL:
 *             return self._advance()             # <<<<<<<<<<<<<<
 *         while 1:
 *             if self.chunk >= PAGE_CHUNKS:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(((struct __pyx_vtabstruct_8bitfield_PageIter *)__pyx_v_self->__pyx_vtab)->_advance(__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    break;
  }

  /* "cimpl/field.pyx":102
 *         elif self.page.page_state == PAGE_FULL:
 *             return self._advance()
 *         while 1:             # <<<<<<<<<<<<<<
 *             if self.chunk >= PAGE_CHUNKS:
 *                 raise StopIteration()
 */
  while (1) {
    if (!1) break;

    /* "cimpl/field.pyx":103
 *             return self._advance()
 *         while 1:
 *             if self.chunk >= PAGE_CHUNKS:             # <<<<<<<<<<<<<<
 *                 raise StopIteration()
 *             test = (self.page.data[self.chunk] & ((<usize_t>1) << self.bit_index))
 */
    __pyx_t_1 = (__pyx_v_self->chunk >= PAGE_CHUNKS);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":104
 *         while 1:
 *             if self.chunk >= PAGE_CHUNKS:
 *                 raise StopIteration()             # <<<<<<<<<<<<<<
 *             test = (self.page.data[self.chunk] & ((<usize_t>1) << self.bit_index))
 *             if test:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __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 = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cimpl/field.pyx":105
 *             if self.chunk >= PAGE_CHUNKS:
 *                 raise StopIteration()
 *             test = (self.page.data[self.chunk] & ((<usize_t>1) << self.bit_index))             # <<<<<<<<<<<<<<
 *             if test:
 *                 return self._advance()
 */
    __pyx_v_test = ((__pyx_v_self->page->data[__pyx_v_self->chunk]) & (((usize_t)1) << __pyx_v_self->bit_index));

    /* "cimpl/field.pyx":106
 *                 raise StopIteration()
 *             test = (self.page.data[self.chunk] & ((<usize_t>1) << self.bit_index))
 *             if test:             # <<<<<<<<<<<<<<
 *                 return self._advance()
 *             self._advance()
 */
    if (__pyx_v_test) {

      /* "cimpl/field.pyx":107
 *             test = (self.page.data[self.chunk] & ((<usize_t>1) << self.bit_index))
 *             if test:
 *                 return self._advance()             # <<<<<<<<<<<<<<
 *             self._advance()
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(((struct __pyx_vtabstruct_8bitfield_PageIter *)__pyx_v_self->__pyx_vtab)->_advance(__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __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_L7;
    }
    __pyx_L7:;

    /* "cimpl/field.pyx":108
 *             if test:
 *                 return self._advance()
 *             self._advance()             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
    ((struct __pyx_vtabstruct_8bitfield_PageIter *)__pyx_v_self->__pyx_vtab)->_advance(__pyx_v_self);
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bitfield.PageIter._next", __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_8bitfield_8PageIter_3__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_8PageIter_3__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8PageIter_2__next__(((struct __pyx_obj_8bitfield_PageIter *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":110
 *             self._advance()
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         return self._next()
 * 
 */

static PyObject *__pyx_pf_8bitfield_8PageIter_2__next__(struct __pyx_obj_8bitfield_PageIter *__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("__next__", 0);

  /* "cimpl/field.pyx":111
 * 
 *     def __next__(self):
 *         return self._next()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_PageIter *)__pyx_v_self->__pyx_vtab)->_next(__pyx_v_self); 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_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("bitfield.PageIter.__next__", __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_8bitfield_16BitfieldIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8bitfield_16BitfieldIterator_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_bitfield = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bitfield,0};
    PyObject* values[1] = {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  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__bitfield)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __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_bitfield = ((struct __pyx_obj_8bitfield_Bitfield *)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.BitfieldIterator.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bitfield), __pyx_ptype_8bitfield_Bitfield, 1, "bitfield", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_16BitfieldIterator___cinit__(((struct __pyx_obj_8bitfield_BitfieldIterator *)__pyx_v_self), __pyx_v_bitfield);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":124
 *     cdef usize_t offset
 * 
 *     def __cinit__(self, Bitfield bitfield):             # <<<<<<<<<<<<<<
 *         self.bitfield = bitfield
 *         self.current_page = 0
 */

static int __pyx_pf_8bitfield_16BitfieldIterator___cinit__(struct __pyx_obj_8bitfield_BitfieldIterator *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_bitfield) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "cimpl/field.pyx":125
 * 
 *     def __cinit__(self, Bitfield bitfield):
 *         self.bitfield = bitfield             # <<<<<<<<<<<<<<
 *         self.current_page = 0
 *         self.current_iter = None
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_bitfield));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_bitfield));
  __Pyx_GOTREF(__pyx_v_self->bitfield);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->bitfield));
  __pyx_v_self->bitfield = __pyx_v_bitfield;

  /* "cimpl/field.pyx":126
 *     def __cinit__(self, Bitfield bitfield):
 *         self.bitfield = bitfield
 *         self.current_page = 0             # <<<<<<<<<<<<<<
 *         self.current_iter = None
 *         self.offset = 0
 */
  __pyx_v_self->current_page = 0;

  /* "cimpl/field.pyx":127
 *         self.bitfield = bitfield
 *         self.current_page = 0
 *         self.current_iter = None             # <<<<<<<<<<<<<<
 *         self.offset = 0
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->current_iter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->current_iter));
  __pyx_v_self->current_iter = ((struct __pyx_obj_8bitfield_PageIter *)Py_None);

  /* "cimpl/field.pyx":128
 *         self.current_page = 0
 *         self.current_iter = None
 *         self.offset = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef inline _next_iter(self):
 */
  __pyx_v_self->offset = 0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":130
 *         self.offset = 0
 * 
 *     cdef inline _next_iter(self):             # <<<<<<<<<<<<<<
 *         cdef IdsPage next_page
 *         while True:
 */

static CYTHON_INLINE PyObject *__pyx_f_8bitfield_16BitfieldIterator__next_iter(struct __pyx_obj_8bitfield_BitfieldIterator *__pyx_v_self) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_next_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_next_iter", 0);

  /* "cimpl/field.pyx":132
 *     cdef inline _next_iter(self):
 *         cdef IdsPage next_page
 *         while True:             # <<<<<<<<<<<<<<
 *             if self.current_page >= len(self.bitfield.pages):
 *                 raise StopIteration()
 */
  while (1) {
    if (!1) break;

    /* "cimpl/field.pyx":133
 *         cdef IdsPage next_page
 *         while True:
 *             if self.current_page >= len(self.bitfield.pages):             # <<<<<<<<<<<<<<
 *                 raise StopIteration()
 *             next_page = self.bitfield.pages[self.current_page]
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->bitfield->pages);
    __Pyx_INCREF(__pyx_t_1);
    if (unlikely(__pyx_t_1 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = (__pyx_v_self->current_page >= __pyx_t_2);
    if (__pyx_t_3) {

      /* "cimpl/field.pyx":134
 *         while True:
 *             if self.current_page >= len(self.bitfield.pages):
 *                 raise StopIteration()             # <<<<<<<<<<<<<<
 *             next_page = self.bitfield.pages[self.current_page]
 *             self.current_iter = next_page._iter()
 */
      __pyx_t_1 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_empty_tuple), NULL); 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);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cimpl/field.pyx":135
 *             if self.current_page >= len(self.bitfield.pages):
 *                 raise StopIteration()
 *             next_page = self.bitfield.pages[self.current_page]             # <<<<<<<<<<<<<<
 *             self.current_iter = next_page._iter()
 *             if self.current_iter is not None:
 */
    if (unlikely(((PyObject *)__pyx_v_self->bitfield->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->bitfield->pages), __pyx_v_self->current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_next_page));
    __pyx_v_next_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":136
 *                 raise StopIteration()
 *             next_page = self.bitfield.pages[self.current_page]
 *             self.current_iter = next_page._iter()             # <<<<<<<<<<<<<<
 *             if self.current_iter is not None:
 *                 return
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_next_page->__pyx_vtab)->_iter(__pyx_v_next_page); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_PageIter))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->current_iter);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->current_iter));
    __pyx_v_self->current_iter = ((struct __pyx_obj_8bitfield_PageIter *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":137
 *             next_page = self.bitfield.pages[self.current_page]
 *             self.current_iter = next_page._iter()
 *             if self.current_iter is not None:             # <<<<<<<<<<<<<<
 *                 return
 *             self.current_page += 1
 */
    __pyx_t_3 = (((PyObject *)__pyx_v_self->current_iter) != Py_None);
    if (__pyx_t_3) {

      /* "cimpl/field.pyx":138
 *             self.current_iter = next_page._iter()
 *             if self.current_iter is not None:
 *                 return             # <<<<<<<<<<<<<<
 *             self.current_page += 1
 *             self.offset += PAGE_FULL_COUNT
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cimpl/field.pyx":139
 *             if self.current_iter is not None:
 *                 return
 *             self.current_page += 1             # <<<<<<<<<<<<<<
 *             self.offset += PAGE_FULL_COUNT
 * 
 */
    __pyx_v_self->current_page = (__pyx_v_self->current_page + 1);

    /* "cimpl/field.pyx":140
 *                 return
 *             self.current_page += 1
 *             self.offset += PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
    __pyx_v_self->offset = (__pyx_v_self->offset + PAGE_FULL_COUNT);
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.BitfieldIterator._next_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_next_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_16BitfieldIterator_3__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_16BitfieldIterator_3__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_16BitfieldIterator_2__next__(((struct __pyx_obj_8bitfield_BitfieldIterator *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":142
 *             self.offset += PAGE_FULL_COUNT
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef usize_t offset
 *         cdef usize_t next_item
 */

static PyObject *__pyx_pf_8bitfield_16BitfieldIterator_2__next__(struct __pyx_obj_8bitfield_BitfieldIterator *__pyx_v_self) {
  usize_t __pyx_v_offset;
  usize_t __pyx_v_next_item;
  struct __pyx_obj_8bitfield_PageIter *__pyx_v_the_iterator = 0;
  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;
  usize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__", 0);

  /* "cimpl/field.pyx":146
 *         cdef usize_t next_item
 *         cdef PageIter the_iterator
 *         if self.current_iter is None:             # <<<<<<<<<<<<<<
 *             self._next_iter()
 *         while True:
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->current_iter) == Py_None);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":147
 *         cdef PageIter the_iterator
 *         if self.current_iter is None:
 *             self._next_iter()             # <<<<<<<<<<<<<<
 *         while True:
 *             try:
 */
    __pyx_t_2 = __pyx_f_8bitfield_16BitfieldIterator__next_iter(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":148
 *         if self.current_iter is None:
 *             self._next_iter()
 *         while True:             # <<<<<<<<<<<<<<
 *             try:
 *                 the_iterator = self.current_iter
 */
  while (1) {
    if (!1) break;

    /* "cimpl/field.pyx":149
 *             self._next_iter()
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 the_iterator = self.current_iter
 *                 next_item = the_iterator._next()
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      /*try:*/ {

        /* "cimpl/field.pyx":150
 *         while True:
 *             try:
 *                 the_iterator = self.current_iter             # <<<<<<<<<<<<<<
 *                 next_item = the_iterator._next()
 *                 offset = self.offset
 */
        __pyx_t_2 = ((PyObject *)__pyx_v_self->current_iter);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF(((PyObject *)__pyx_v_the_iterator));
        __pyx_v_the_iterator = ((struct __pyx_obj_8bitfield_PageIter *)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "cimpl/field.pyx":151
 *             try:
 *                 the_iterator = self.current_iter
 *                 next_item = the_iterator._next()             # <<<<<<<<<<<<<<
 *                 offset = self.offset
 *                 return next_item + offset
 */
        __pyx_t_2 = ((struct __pyx_vtabstruct_8bitfield_PageIter *)__pyx_v_the_iterator->__pyx_vtab)->_next(__pyx_v_the_iterator); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __Pyx_PyInt_from_py_usize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_next_item = __pyx_t_6;

        /* "cimpl/field.pyx":152
 *                 the_iterator = self.current_iter
 *                 next_item = the_iterator._next()
 *                 offset = self.offset             # <<<<<<<<<<<<<<
 *                 return next_item + offset
 *             except StopIteration:
 */
        __pyx_t_6 = __pyx_v_self->offset;
        __pyx_v_offset = __pyx_t_6;

        /* "cimpl/field.pyx":153
 *                 next_item = the_iterator._next()
 *                 offset = self.offset
 *                 return next_item + offset             # <<<<<<<<<<<<<<
 *             except StopIteration:
 *                 self.current_page += 1
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyInt_to_py_usize_t((__pyx_v_next_item + __pyx_v_offset)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L10_try_return;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L13_try_end;
      __pyx_L10_try_return:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L0;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cimpl/field.pyx":154
 *                 offset = self.offset
 *                 return next_item + offset
 *             except StopIteration:             # <<<<<<<<<<<<<<
 *                 self.current_page += 1
 *                 self.offset += PAGE_FULL_COUNT
 */
      __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
      if (__pyx_t_7) {
        __Pyx_AddTraceback("bitfield.BitfieldIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_9);

        /* "cimpl/field.pyx":155
 *                 return next_item + offset
 *             except StopIteration:
 *                 self.current_page += 1             # <<<<<<<<<<<<<<
 *                 self.offset += PAGE_FULL_COUNT
 *                 self._next_iter()
 */
        __pyx_v_self->current_page = (__pyx_v_self->current_page + 1);

        /* "cimpl/field.pyx":156
 *             except StopIteration:
 *                 self.current_page += 1
 *                 self.offset += PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *                 self._next_iter()
 * 
 */
        __pyx_v_self->offset = (__pyx_v_self->offset + PAGE_FULL_COUNT);

        /* "cimpl/field.pyx":157
 *                 self.current_page += 1
 *                 self.offset += PAGE_FULL_COUNT
 *                 self._next_iter()             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_10 = __pyx_f_8bitfield_16BitfieldIterator__next_iter(__pyx_v_self); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_exception_handled;
      }
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      goto __pyx_L1_error;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
      __pyx_L13_try_end:;
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("bitfield.BitfieldIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_iterator);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8bitfield_7IdsPage_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8bitfield_7IdsPage_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
  __pyx_r = __pyx_pf_8bitfield_7IdsPage___cinit__(((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":165
 *     cdef CHUNK* data
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.page_state = PAGE_EMPTY
 *         self._count = 0
 */

static int __pyx_pf_8bitfield_7IdsPage___cinit__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "cimpl/field.pyx":166
 * 
 *     def __cinit__(self):
 *         self.page_state = PAGE_EMPTY             # <<<<<<<<<<<<<<
 *         self._count = 0
 *         self.data = NULL
 */
  __pyx_v_self->page_state = 3;

  /* "cimpl/field.pyx":167
 *     def __cinit__(self):
 *         self.page_state = PAGE_EMPTY
 *         self._count = 0             # <<<<<<<<<<<<<<
 *         self.data = NULL
 * 
 */
  __pyx_v_self->_count = 0;

  /* "cimpl/field.pyx":168
 *         self.page_state = PAGE_EMPTY
 *         self._count = 0
 *         self.data = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_v_self->data = NULL;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_8bitfield_7IdsPage_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_8bitfield_7IdsPage_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_8bitfield_7IdsPage_2__dealloc__(((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":170
 *         self.data = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self._dealloc(PAGE_EMPTY)
 * 
 */

static void __pyx_pf_8bitfield_7IdsPage_2__dealloc__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "cimpl/field.pyx":171
 * 
 *     def __dealloc__(self):
 *         self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _fill(self, CHUNK value):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);

  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":173
 *         self._dealloc(PAGE_EMPTY)
 * 
 *     cdef void _fill(self, CHUNK value):             # <<<<<<<<<<<<<<
 *         cdef usize_t current
 *         for current in range(PAGE_CHUNKS):
 */

static void __pyx_f_8bitfield_7IdsPage__fill(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, CHUNK __pyx_v_value) {
  usize_t __pyx_v_current;
  __Pyx_RefNannyDeclarations
  usize_t __pyx_t_1;
  usize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("_fill", 0);

  /* "cimpl/field.pyx":175
 *     cdef void _fill(self, CHUNK value):
 *         cdef usize_t current
 *         for current in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *             self.data[current] = value
 * 
 */
  __pyx_t_1 = PAGE_CHUNKS;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_current = __pyx_t_2;

    /* "cimpl/field.pyx":176
 *         cdef usize_t current
 *         for current in range(PAGE_CHUNKS):
 *             self.data[current] = value             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_full(self):
 */
    (__pyx_v_self->data[__pyx_v_current]) = __pyx_v_value;
  }

  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":178
 *             self.data[current] = value
 * 
 *     cdef void set_full(self):             # <<<<<<<<<<<<<<
 *         self._dealloc(PAGE_FULL)
 * 
 */

static void __pyx_f_8bitfield_7IdsPage_set_full(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_full", 0);

  /* "cimpl/field.pyx":179
 * 
 *     cdef void set_full(self):
 *         self._dealloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_empty(self):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 2);

  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":181
 *         self._dealloc(PAGE_FULL)
 * 
 *     cdef void set_empty(self):             # <<<<<<<<<<<<<<
 *         self._dealloc(PAGE_EMPTY)
 * 
 */

static void __pyx_f_8bitfield_7IdsPage_set_empty(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_empty", 0);

  /* "cimpl/field.pyx":182
 * 
 *     cdef void set_empty(self):
 *         self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _alloc(self, int fill=0):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);

  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":184
 *         self._dealloc(PAGE_EMPTY)
 * 
 *     cdef void _alloc(self, int fill=0):             # <<<<<<<<<<<<<<
 *         assert(self.data == NULL)
 *         self.page_state = PAGE_PARTIAL
 */

static void __pyx_f_8bitfield_7IdsPage__alloc(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, struct __pyx_opt_args_8bitfield_7IdsPage__alloc *__pyx_optional_args) {
  int __pyx_v_fill = ((int)0);
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_alloc", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_fill = __pyx_optional_args->fill;
    }
  }

  /* "cimpl/field.pyx":185
 * 
 *     cdef void _alloc(self, int fill=0):
 *         assert(self.data == NULL)             # <<<<<<<<<<<<<<
 *         self.page_state = PAGE_PARTIAL
 *         self.data = <CHUNK *>malloc(sizeof(CHUNK) * PAGE_CHUNKS)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_self->data == NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cimpl/field.pyx":186
 *     cdef void _alloc(self, int fill=0):
 *         assert(self.data == NULL)
 *         self.page_state = PAGE_PARTIAL             # <<<<<<<<<<<<<<
 *         self.data = <CHUNK *>malloc(sizeof(CHUNK) * PAGE_CHUNKS)
 *         if fill:
 */
  __pyx_v_self->page_state = 1;

  /* "cimpl/field.pyx":187
 *         assert(self.data == NULL)
 *         self.page_state = PAGE_PARTIAL
 *         self.data = <CHUNK *>malloc(sizeof(CHUNK) * PAGE_CHUNKS)             # <<<<<<<<<<<<<<
 *         if fill:
 *             self._count = PAGE_FULL_COUNT
 */
  __pyx_v_self->data = ((CHUNK *)malloc(((sizeof(CHUNK)) * PAGE_CHUNKS)));

  /* "cimpl/field.pyx":188
 *         self.page_state = PAGE_PARTIAL
 *         self.data = <CHUNK *>malloc(sizeof(CHUNK) * PAGE_CHUNKS)
 *         if fill:             # <<<<<<<<<<<<<<
 *             self._count = PAGE_FULL_COUNT
 *             self._fill(CHUNK_BITS)
 */
  if (__pyx_v_fill) {

    /* "cimpl/field.pyx":189
 *         self.data = <CHUNK *>malloc(sizeof(CHUNK) * PAGE_CHUNKS)
 *         if fill:
 *             self._count = PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *             self._fill(CHUNK_BITS)
 *         else:
 */
    __pyx_v_self->_count = PAGE_FULL_COUNT;

    /* "cimpl/field.pyx":190
 *         if fill:
 *             self._count = PAGE_FULL_COUNT
 *             self._fill(CHUNK_BITS)             # <<<<<<<<<<<<<<
 *         else:
 *             self._count = 0
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_fill(__pyx_v_self, CHUNK_BITS);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cimpl/field.pyx":192
 *             self._fill(CHUNK_BITS)
 *         else:
 *             self._count = 0             # <<<<<<<<<<<<<<
 *             self._fill(0)
 * 
 */
    __pyx_v_self->_count = 0;

    /* "cimpl/field.pyx":193
 *         else:
 *             self._count = 0
 *             self._fill(0)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _dealloc(self, int new_state):
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_fill(__pyx_v_self, 0);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("bitfield.IdsPage._alloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":195
 *             self._fill(0)
 * 
 *     cdef void _dealloc(self, int new_state):             # <<<<<<<<<<<<<<
 *         assert new_state != PAGE_PARTIAL
 *         self.page_state = new_state
 */

static void __pyx_f_8bitfield_7IdsPage__dealloc(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, int __pyx_v_new_state) {
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dealloc", 0);

  /* "cimpl/field.pyx":196
 * 
 *     cdef void _dealloc(self, int new_state):
 *         assert new_state != PAGE_PARTIAL             # <<<<<<<<<<<<<<
 *         self.page_state = new_state
 *         self._count = 0 if new_state == PAGE_EMPTY else PAGE_FULL_COUNT
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_new_state != 1))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cimpl/field.pyx":197
 *     cdef void _dealloc(self, int new_state):
 *         assert new_state != PAGE_PARTIAL
 *         self.page_state = new_state             # <<<<<<<<<<<<<<
 *         self._count = 0 if new_state == PAGE_EMPTY else PAGE_FULL_COUNT
 *         if self.data != NULL:
 */
  __pyx_v_self->page_state = __pyx_v_new_state;

  /* "cimpl/field.pyx":198
 *         assert new_state != PAGE_PARTIAL
 *         self.page_state = new_state
 *         self._count = 0 if new_state == PAGE_EMPTY else PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         if self.data != NULL:
 *             free(self.data)
 */
  if ((__pyx_v_new_state == 3)) {
    __pyx_t_1 = 0;
  } else {
    __pyx_t_1 = PAGE_FULL_COUNT;
  }
  __pyx_v_self->_count = __pyx_t_1;

  /* "cimpl/field.pyx":199
 *         self.page_state = new_state
 *         self._count = 0 if new_state == PAGE_EMPTY else PAGE_FULL_COUNT
 *         if self.data != NULL:             # <<<<<<<<<<<<<<
 *             free(self.data)
 *             self.data = NULL
 */
  __pyx_t_2 = (__pyx_v_self->data != NULL);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":200
 *         self._count = 0 if new_state == PAGE_EMPTY else PAGE_FULL_COUNT
 *         if self.data != NULL:
 *             free(self.data)             # <<<<<<<<<<<<<<
 *             self.data = NULL
 * 
 */
    free(__pyx_v_self->data);

    /* "cimpl/field.pyx":201
 *         if self.data != NULL:
 *             free(self.data)
 *             self.data = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef _iter(self):
 */
    __pyx_v_self->data = NULL;
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("bitfield.IdsPage._dealloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":203
 *             self.data = NULL
 * 
 *     cdef _iter(self):             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             return None
 */

static PyObject *__pyx_f_8bitfield_7IdsPage__iter(struct __pyx_obj_8bitfield_IdsPage *__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);

  /* "cimpl/field.pyx":204
 * 
 *     cdef _iter(self):
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return None
 *         return PageIter(self)
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":205
 *     cdef _iter(self):
 *         if self.page_state == PAGE_EMPTY:
 *             return None             # <<<<<<<<<<<<<<
 *         return PageIter(self)
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":206
 *         if self.page_state == PAGE_EMPTY:
 *             return None
 *         return PageIter(self)             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_PageIter)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __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("bitfield.IdsPage._iter", __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_8bitfield_7IdsPage_5__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_7IdsPage_5__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_7IdsPage_4__iter__(((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":208
 *         return PageIter(self)
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         cdef PageIter iterator = self._iter()
 *         if iterator is None:
 */

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

  /* "cimpl/field.pyx":209
 * 
 *     def __iter__(self):
 *         cdef PageIter iterator = self._iter()             # <<<<<<<<<<<<<<
 *         if iterator is None:
 *             return iter(set())
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_iter(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_PageIter))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_iterator = ((struct __pyx_obj_8bitfield_PageIter *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":210
 *     def __iter__(self):
 *         cdef PageIter iterator = self._iter()
 *         if iterator is None:             # <<<<<<<<<<<<<<
 *             return iter(set())
 *         return iterator
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_iterator) == Py_None);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":211
 *         cdef PageIter iterator = self._iter()
 *         if iterator is None:
 *             return iter(set())             # <<<<<<<<<<<<<<
 *         return iterator
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":212
 *         if iterator is None:
 *             return iter(set())
 *         return iterator             # <<<<<<<<<<<<<<
 * 
 *     cdef void calc_length(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_iterator));
  __pyx_r = ((PyObject *)__pyx_v_iterator);
  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_3);
  __Pyx_AddTraceback("bitfield.IdsPage.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_iterator);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":214
 *         return iterator
 * 
 *     cdef void calc_length(self):             # <<<<<<<<<<<<<<
 *         cdef CHUNK *chunk
 *         cdef usize_t chunk_index
 */

static void __pyx_f_8bitfield_7IdsPage_calc_length(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  usize_t __pyx_v_chunk_index;
  usize_t __pyx_v_bits;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  usize_t __pyx_t_2;
  usize_t __pyx_t_3;
  __Pyx_RefNannySetupContext("calc_length", 0);

  /* "cimpl/field.pyx":217
 *         cdef CHUNK *chunk
 *         cdef usize_t chunk_index
 *         cdef usize_t bits = 0             # <<<<<<<<<<<<<<
 *         if self.page_state != PAGE_PARTIAL:
 *             return
 */
  __pyx_v_bits = 0;

  /* "cimpl/field.pyx":218
 *         cdef usize_t chunk_index
 *         cdef usize_t bits = 0
 *         if self.page_state != PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             return
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->page_state != 1);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":219
 *         cdef usize_t bits = 0
 *         if self.page_state != PAGE_PARTIAL:
 *             return             # <<<<<<<<<<<<<<
 *         else:
 *             for chunk_index in range(PAGE_CHUNKS):
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cimpl/field.pyx":221
 *             return
 *         else:
 *             for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                 bits += __builtin_popcountl(self.data[chunk_index])
 *             if bits == 0:
 */
    __pyx_t_2 = PAGE_CHUNKS;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_chunk_index = __pyx_t_3;

      /* "cimpl/field.pyx":222
 *         else:
 *             for chunk_index in range(PAGE_CHUNKS):
 *                 bits += __builtin_popcountl(self.data[chunk_index])             # <<<<<<<<<<<<<<
 *             if bits == 0:
 *                 self._dealloc(PAGE_EMPTY)
 */
      __pyx_v_bits = (__pyx_v_bits + __builtin_popcountl((__pyx_v_self->data[__pyx_v_chunk_index])));
    }

    /* "cimpl/field.pyx":223
 *             for chunk_index in range(PAGE_CHUNKS):
 *                 bits += __builtin_popcountl(self.data[chunk_index])
 *             if bits == 0:             # <<<<<<<<<<<<<<
 *                 self._dealloc(PAGE_EMPTY)
 *             elif bits == PAGE_FULL_COUNT:
 */
    __pyx_t_1 = (__pyx_v_bits == 0);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":224
 *                 bits += __builtin_popcountl(self.data[chunk_index])
 *             if bits == 0:
 *                 self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *             elif bits == PAGE_FULL_COUNT:
 *                 self._dealloc(PAGE_FULL)
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);
      goto __pyx_L6;
    }

    /* "cimpl/field.pyx":225
 *             if bits == 0:
 *                 self._dealloc(PAGE_EMPTY)
 *             elif bits == PAGE_FULL_COUNT:             # <<<<<<<<<<<<<<
 *                 self._dealloc(PAGE_FULL)
 *             else:
 */
    __pyx_t_1 = (__pyx_v_bits == PAGE_FULL_COUNT);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":226
 *                 self._dealloc(PAGE_EMPTY)
 *             elif bits == PAGE_FULL_COUNT:
 *                 self._dealloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 *             else:
 *                 self._count = bits
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 2);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "cimpl/field.pyx":228
 *                 self._dealloc(PAGE_FULL)
 *             else:
 *                 self._count = bits             # <<<<<<<<<<<<<<
 * 
 *     property count:
 */
      __pyx_v_self->_count = __pyx_v_bits;
    }
    __pyx_L6:;
  }
  __pyx_L3:;

  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

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

/* "cimpl/field.pyx":231
 * 
 *     property count:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._count
 * 
 */

static PyObject *__pyx_pf_8bitfield_7IdsPage_5count___get__(struct __pyx_obj_8bitfield_IdsPage *__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);

  /* "cimpl/field.pyx":232
 *     property count:
 *         def __get__(self):
 *             return self._count             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, usize_t number):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_usize_t(__pyx_v_self->_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __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("bitfield.IdsPage.count.__get__", __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_8bitfield_7IdsPage_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static int __pyx_pw_8bitfield_7IdsPage_7__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  usize_t __pyx_v_number;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  assert(__pyx_arg_number); {
    __pyx_v_number = __Pyx_PyInt_from_py_usize_t(__pyx_arg_number); if (unlikely((__pyx_v_number == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.IdsPage.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_7IdsPage_6__contains__(((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_self), ((usize_t)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":234
 *             return self._count
 * 
 *     def __contains__(self, usize_t number):             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 */

static int __pyx_pf_8bitfield_7IdsPage_6__contains__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, usize_t __pyx_v_number) {
  usize_t __pyx_v_chunk_index;
  usize_t __pyx_v_chunk_bit;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "cimpl/field.pyx":235
 * 
 *     def __contains__(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 */
  __pyx_v_chunk_index = (__pyx_v_number >> CHUNK_SHIFT);

  /* "cimpl/field.pyx":236
 *     def __contains__(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)             # <<<<<<<<<<<<<<
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 *             raise AssertionError("Cannot test for %i in a page (overflow)" % number)
 */
  __pyx_v_chunk_bit = (((usize_t)1) << (__pyx_v_number & CHUNK_MASK));

  /* "cimpl/field.pyx":237
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):             # <<<<<<<<<<<<<<
 *             raise AssertionError("Cannot test for %i in a page (overflow)" % number)
 *         if self.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_chunk_index >= PAGE_CHUNKS);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_chunk_index < 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":238
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 *             raise AssertionError("Cannot test for %i in a page (overflow)" % number)             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_FULL:
 *             return True
 */
    __pyx_t_4 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); 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_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":239
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 *             raise AssertionError("Cannot test for %i in a page (overflow)" % number)
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return True
 *         if self.page_state == PAGE_EMPTY:
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":240
 *             raise AssertionError("Cannot test for %i in a page (overflow)" % number)
 *         if self.page_state == PAGE_FULL:
 *             return True             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             return False
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":241
 *         if self.page_state == PAGE_FULL:
 *             return True
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return False
 *         return self.data[chunk_index] & chunk_bit != 0
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":242
 *             return True
 *         if self.page_state == PAGE_EMPTY:
 *             return False             # <<<<<<<<<<<<<<
 *         return self.data[chunk_index] & chunk_bit != 0
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":243
 *         if self.page_state == PAGE_EMPTY:
 *             return False
 *         return self.data[chunk_index] & chunk_bit != 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (((__pyx_v_self->data[__pyx_v_chunk_index]) & __pyx_v_chunk_bit) != 0);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("bitfield.IdsPage.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":246
 * 
 * 
 *     cdef void add(self, usize_t number):             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 */

static void __pyx_f_8bitfield_7IdsPage_add(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, usize_t __pyx_v_number) {
  usize_t __pyx_v_chunk_index;
  usize_t __pyx_v_chunk_bit;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  usize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add", 0);

  /* "cimpl/field.pyx":247
 * 
 *     cdef void add(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 * 
 */
  __pyx_v_chunk_index = (__pyx_v_number >> CHUNK_SHIFT);

  /* "cimpl/field.pyx":248
 *     cdef void add(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)             # <<<<<<<<<<<<<<
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 */
  __pyx_v_chunk_bit = (((usize_t)1) << (__pyx_v_number & CHUNK_MASK));

  /* "cimpl/field.pyx":250
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):             # <<<<<<<<<<<<<<
 *             raise AssertionError("Cannot add %i to a page (overflow)" % number)
 * 
 */
  __pyx_t_1 = (__pyx_v_chunk_index >= PAGE_CHUNKS);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_chunk_index < 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":251
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 *             raise AssertionError("Cannot add %i to a page (overflow)" % number)             # <<<<<<<<<<<<<<
 * 
 *         if self.page_state == PAGE_FULL:
 */
    __pyx_t_4 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":253
 *             raise AssertionError("Cannot add %i to a page (overflow)" % number)
 * 
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_EMPTY:
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":254
 * 
 *         if self.page_state == PAGE_FULL:
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             self._alloc()
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":255
 *         if self.page_state == PAGE_FULL:
 *             return
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             self._alloc()
 * 
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":256
 *             return
 *         if self.page_state == PAGE_EMPTY:
 *             self._alloc()             # <<<<<<<<<<<<<<
 * 
 *         if self.data[chunk_index] & chunk_bit:
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, NULL);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":258
 *             self._alloc()
 * 
 *         if self.data[chunk_index] & chunk_bit:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_6 = ((__pyx_v_self->data[__pyx_v_chunk_index]) & __pyx_v_chunk_bit);
  if (__pyx_t_6) {

    /* "cimpl/field.pyx":259
 * 
 *         if self.data[chunk_index] & chunk_bit:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.data[chunk_index] |= chunk_bit
 */
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cimpl/field.pyx":261
 *             return
 * 
 *         self.data[chunk_index] |= chunk_bit             # <<<<<<<<<<<<<<
 *         self._count += 1
 *         if self._count == PAGE_FULL_COUNT:
 */
  __pyx_t_6 = __pyx_v_chunk_index;
  (__pyx_v_self->data[__pyx_t_6]) = ((__pyx_v_self->data[__pyx_t_6]) | __pyx_v_chunk_bit);

  /* "cimpl/field.pyx":262
 * 
 *         self.data[chunk_index] |= chunk_bit
 *         self._count += 1             # <<<<<<<<<<<<<<
 *         if self._count == PAGE_FULL_COUNT:
 *             self._dealloc(PAGE_FULL)
 */
  __pyx_v_self->_count = (__pyx_v_self->_count + 1);

  /* "cimpl/field.pyx":263
 *         self.data[chunk_index] |= chunk_bit
 *         self._count += 1
 *         if self._count == PAGE_FULL_COUNT:             # <<<<<<<<<<<<<<
 *             self._dealloc(PAGE_FULL)
 *         return
 */
  __pyx_t_3 = (__pyx_v_self->_count == PAGE_FULL_COUNT);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":264
 *         self._count += 1
 *         if self._count == PAGE_FULL_COUNT:
 *             self._dealloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 2);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "cimpl/field.pyx":265
 *         if self._count == PAGE_FULL_COUNT:
 *             self._dealloc(PAGE_FULL)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     cdef void remove(self, usize_t number):
 */
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("bitfield.IdsPage.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":267
 *         return
 * 
 *     cdef void remove(self, usize_t number):             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 */

static void __pyx_f_8bitfield_7IdsPage_remove(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, usize_t __pyx_v_number) {
  usize_t __pyx_v_chunk_index;
  usize_t __pyx_v_chunk_bit;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  struct __pyx_opt_args_8bitfield_7IdsPage__alloc __pyx_t_6;
  usize_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove", 0);

  /* "cimpl/field.pyx":268
 * 
 *     cdef void remove(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 * 
 */
  __pyx_v_chunk_index = (__pyx_v_number >> CHUNK_SHIFT);

  /* "cimpl/field.pyx":269
 *     cdef void remove(self, usize_t number):
 *         cdef usize_t chunk_index = number >> CHUNK_SHIFT
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)             # <<<<<<<<<<<<<<
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 */
  __pyx_v_chunk_bit = (((usize_t)1) << (__pyx_v_number & CHUNK_MASK));

  /* "cimpl/field.pyx":271
 *         cdef usize_t chunk_bit = (<usize_t>1) << (number & CHUNK_MASK)
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):             # <<<<<<<<<<<<<<
 *             raise AssertionError("Cannot remove %i from a page (overflow)" % number)
 * 
 */
  __pyx_t_1 = (__pyx_v_chunk_index >= PAGE_CHUNKS);
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_chunk_index < 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":272
 * 
 *         if (chunk_index >= PAGE_CHUNKS or chunk_index < 0):
 *             raise AssertionError("Cannot remove %i from a page (overflow)" % number)             # <<<<<<<<<<<<<<
 * 
 *         if self.page_state == PAGE_EMPTY:
 */
    __pyx_t_4 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":274
 *             raise AssertionError("Cannot remove %i from a page (overflow)" % number)
 * 
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_FULL:
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":275
 * 
 *         if self.page_state == PAGE_EMPTY:
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_FULL:
 *             self._alloc(True)
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":276
 *         if self.page_state == PAGE_EMPTY:
 *             return
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             self._alloc(True)
 * 
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":277
 *             return
 *         if self.page_state == PAGE_FULL:
 *             self._alloc(True)             # <<<<<<<<<<<<<<
 * 
 *         if not self.data[chunk_index] & chunk_bit:
 */
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.fill = 1;
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, &__pyx_t_6); 
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":279
 *             self._alloc(True)
 * 
 *         if not self.data[chunk_index] & chunk_bit:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_3 = (!((__pyx_v_self->data[__pyx_v_chunk_index]) & __pyx_v_chunk_bit));
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":280
 * 
 *         if not self.data[chunk_index] & chunk_bit:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.data[chunk_index] &= ~chunk_bit
 */
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cimpl/field.pyx":282
 *             return
 * 
 *         self.data[chunk_index] &= ~chunk_bit             # <<<<<<<<<<<<<<
 *         self._count -= 1
 *         if self._count == 0:
 */
  __pyx_t_7 = __pyx_v_chunk_index;
  (__pyx_v_self->data[__pyx_t_7]) = ((__pyx_v_self->data[__pyx_t_7]) & (~__pyx_v_chunk_bit));

  /* "cimpl/field.pyx":283
 * 
 *         self.data[chunk_index] &= ~chunk_bit
 *         self._count -= 1             # <<<<<<<<<<<<<<
 *         if self._count == 0:
 *             self._dealloc(PAGE_EMPTY)
 */
  __pyx_v_self->_count = (__pyx_v_self->_count - 1);

  /* "cimpl/field.pyx":284
 *         self.data[chunk_index] &= ~chunk_bit
 *         self._count -= 1
 *         if self._count == 0:             # <<<<<<<<<<<<<<
 *             self._dealloc(PAGE_EMPTY)
 *         return
 */
  __pyx_t_3 = (__pyx_v_self->_count == 0);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":285
 *         self._count -= 1
 *         if self._count == 0:
 *             self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "cimpl/field.pyx":286
 *         if self._count == 0:
 *             self._dealloc(PAGE_EMPTY)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, IdsPage other):
 */
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("bitfield.IdsPage.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":288
 *         return
 * 
 *     cdef void update(self, IdsPage other):             # <<<<<<<<<<<<<<
 *         if other.page_state == PAGE_EMPTY:
 *             return
 */

static void __pyx_f_8bitfield_7IdsPage_update(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_other) {
  usize_t __pyx_v_chunk_index;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  usize_t __pyx_t_2;
  usize_t __pyx_t_3;
  usize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("update", 0);

  /* "cimpl/field.pyx":289
 * 
 *     cdef void update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_other->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":290
 *     cdef void update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_FULL:
 *             return
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":291
 *         if other.page_state == PAGE_EMPTY:
 *             return
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return
 *         if other.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":292
 *             return
 *         if self.page_state == PAGE_FULL:
 *             return             # <<<<<<<<<<<<<<
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_FULL)
 */
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":293
 *         if self.page_state == PAGE_FULL:
 *             return
 *         if other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             self._dealloc(PAGE_FULL)
 *             return
 */
  __pyx_t_1 = (__pyx_v_other->page_state == 2);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":294
 *             return
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_EMPTY:
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 2);

    /* "cimpl/field.pyx":295
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_FULL)
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             self._alloc()
 */
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":296
 *             self._dealloc(PAGE_FULL)
 *             return
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             self._alloc()
 *         for chunk_index in range(PAGE_CHUNKS):
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":297
 *             return
 *         if self.page_state == PAGE_EMPTY:
 *             self._alloc()             # <<<<<<<<<<<<<<
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] |= other.data[chunk_index]
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, NULL);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cimpl/field.pyx":298
 *         if self.page_state == PAGE_EMPTY:
 *             self._alloc()
 *         for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *             self.data[chunk_index] |= other.data[chunk_index]
 *         self.calc_length()
 */
  __pyx_t_2 = PAGE_CHUNKS;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_chunk_index = __pyx_t_3;

    /* "cimpl/field.pyx":299
 *             self._alloc()
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] |= other.data[chunk_index]             # <<<<<<<<<<<<<<
 *         self.calc_length()
 * 
 */
    __pyx_t_4 = __pyx_v_chunk_index;
    (__pyx_v_self->data[__pyx_t_4]) = ((__pyx_v_self->data[__pyx_t_4]) | (__pyx_v_other->data[__pyx_v_chunk_index]));
  }

  /* "cimpl/field.pyx":300
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] |= other.data[chunk_index]
 *         self.calc_length()             # <<<<<<<<<<<<<<
 * 
 *     cdef void intersection_update(self, IdsPage other):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);

  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":302
 *         self.calc_length()
 * 
 *     cdef void intersection_update(self, IdsPage other):             # <<<<<<<<<<<<<<
 *         if other.page_state == PAGE_EMPTY:
 *             self._dealloc(PAGE_EMPTY)
 */

static void __pyx_f_8bitfield_7IdsPage_intersection_update(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_other) {
  usize_t __pyx_v_chunk_index;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  usize_t __pyx_t_2;
  usize_t __pyx_t_3;
  usize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("intersection_update", 0);

  /* "cimpl/field.pyx":307
 *         elif other.page_state == PAGE_FULL:
 *             return
 *         elif other.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             if self.page_state == PAGE_EMPTY:
 *                 return
 */
  switch (__pyx_v_other->page_state) {

    /* "cimpl/field.pyx":303
 * 
 *     cdef void intersection_update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             self._dealloc(PAGE_EMPTY)
 *         elif other.page_state == PAGE_FULL:
 */
    case 3:

    /* "cimpl/field.pyx":304
 *     cdef void intersection_update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:
 *             self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *         elif other.page_state == PAGE_FULL:
 *             return
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);
    break;

    /* "cimpl/field.pyx":305
 *         if other.page_state == PAGE_EMPTY:
 *             self._dealloc(PAGE_EMPTY)
 *         elif other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return
 *         elif other.page_state == PAGE_PARTIAL:
 */
    case 2:

    /* "cimpl/field.pyx":306
 *             self._dealloc(PAGE_EMPTY)
 *         elif other.page_state == PAGE_FULL:
 *             return             # <<<<<<<<<<<<<<
 *         elif other.page_state == PAGE_PARTIAL:
 *             if self.page_state == PAGE_EMPTY:
 */
    goto __pyx_L0;
    break;

    /* "cimpl/field.pyx":307
 *         elif other.page_state == PAGE_FULL:
 *             return
 *         elif other.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             if self.page_state == PAGE_EMPTY:
 *                 return
 */
    case 1:

    /* "cimpl/field.pyx":308
 *             return
 *         elif other.page_state == PAGE_PARTIAL:
 *             if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *                 return
 *             elif self.page_state == PAGE_FULL:
 */
    __pyx_t_1 = (__pyx_v_self->page_state == 3);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":309
 *         elif other.page_state == PAGE_PARTIAL:
 *             if self.page_state == PAGE_EMPTY:
 *                 return             # <<<<<<<<<<<<<<
 *             elif self.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)
 */
      goto __pyx_L0;
      goto __pyx_L3;
    }

    /* "cimpl/field.pyx":310
 *             if self.page_state == PAGE_EMPTY:
 *                 return
 *             elif self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *                 self._dealloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 */
    __pyx_t_1 = (__pyx_v_self->page_state == 2);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":311
 *                 return
 *             elif self.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *                 self.calc_length()
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);

      /* "cimpl/field.pyx":312
 *             elif self.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)             # <<<<<<<<<<<<<<
 *                 self.calc_length()
 *                 return
 */
      memcpy(__pyx_v_self->data, __pyx_v_other->data, (CHUNK_BYTES * PAGE_CHUNKS));

      /* "cimpl/field.pyx":313
 *                 self._dealloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *                 self.calc_length()             # <<<<<<<<<<<<<<
 *                 return
 *             elif self.page_state == PAGE_PARTIAL:
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);

      /* "cimpl/field.pyx":314
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *                 self.calc_length()
 *                 return             # <<<<<<<<<<<<<<
 *             elif self.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 */
      goto __pyx_L0;
      goto __pyx_L3;
    }

    /* "cimpl/field.pyx":315
 *                 self.calc_length()
 *                 return
 *             elif self.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] &= other.data[chunk_index]
 */
    __pyx_t_1 = (__pyx_v_self->page_state == 1);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":316
 *                 return
 *             elif self.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                     self.data[chunk_index] &= other.data[chunk_index]
 *                 self.calc_length()
 */
      __pyx_t_2 = PAGE_CHUNKS;
      for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
        __pyx_v_chunk_index = __pyx_t_3;

        /* "cimpl/field.pyx":317
 *             elif self.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] &= other.data[chunk_index]             # <<<<<<<<<<<<<<
 *                 self.calc_length()
 *             else:
 */
        __pyx_t_4 = __pyx_v_chunk_index;
        (__pyx_v_self->data[__pyx_t_4]) = ((__pyx_v_self->data[__pyx_t_4]) & (__pyx_v_other->data[__pyx_v_chunk_index]));
      }

      /* "cimpl/field.pyx":318
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] &= other.data[chunk_index]
 *                 self.calc_length()             # <<<<<<<<<<<<<<
 *             else:
 *                 raise AssertionError("Invalid page state")
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "cimpl/field.pyx":320
 *                 self.calc_length()
 *             else:
 *                 raise AssertionError("Invalid page state")             # <<<<<<<<<<<<<<
 *         else:
 *             raise AssertionError("Invalid page state")
 */
      __pyx_t_5 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __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 = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L3:;
    break;
    default:

    /* "cimpl/field.pyx":322
 *                 raise AssertionError("Invalid page state")
 *         else:
 *             raise AssertionError("Invalid page state")             # <<<<<<<<<<<<<<
 * 
 *     cdef void difference_update(self, IdsPage other):
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __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 = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("bitfield.IdsPage.intersection_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":324
 *             raise AssertionError("Invalid page state")
 * 
 *     cdef void difference_update(self, IdsPage other):             # <<<<<<<<<<<<<<
 *         if other.page_state == PAGE_EMPTY:
 *             return
 */

static void __pyx_f_8bitfield_7IdsPage_difference_update(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_other) {
  usize_t __pyx_v_chunk_index;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_8bitfield_7IdsPage__alloc __pyx_t_2;
  usize_t __pyx_t_3;
  usize_t __pyx_t_4;
  usize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("difference_update", 0);

  /* "cimpl/field.pyx":325
 * 
 *     cdef void difference_update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_other->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":326
 *     cdef void difference_update(self, IdsPage other):
 *         if other.page_state == PAGE_EMPTY:
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_FULL:
 *             self._alloc(True)
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":327
 *         if other.page_state == PAGE_EMPTY:
 *             return
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             self._alloc(True)
 *         if other.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":328
 *             return
 *         if self.page_state == PAGE_FULL:
 *             self._alloc(True)             # <<<<<<<<<<<<<<
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_EMPTY)
 */
    __pyx_t_2.__pyx_n = 1;
    __pyx_t_2.fill = 1;
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, &__pyx_t_2); 
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":329
 *         if self.page_state == PAGE_FULL:
 *             self._alloc(True)
 *         if other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             self._dealloc(PAGE_EMPTY)
 *             return
 */
  __pyx_t_1 = (__pyx_v_other->page_state == 2);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":330
 *             self._alloc(True)
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *             return
 *         if self.page_state == PAGE_EMPTY:
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);

    /* "cimpl/field.pyx":331
 *         if other.page_state == PAGE_FULL:
 *             self._dealloc(PAGE_EMPTY)
 *             return             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             return
 */
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":332
 *             self._dealloc(PAGE_EMPTY)
 *             return
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return
 *         for chunk_index in range(PAGE_CHUNKS):
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":333
 *             return
 *         if self.page_state == PAGE_EMPTY:
 *             return             # <<<<<<<<<<<<<<
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] &= ~other.data[chunk_index]
 */
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cimpl/field.pyx":334
 *         if self.page_state == PAGE_EMPTY:
 *             return
 *         for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *             self.data[chunk_index] &= ~other.data[chunk_index]
 *         self.calc_length()
 */
  __pyx_t_3 = PAGE_CHUNKS;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_chunk_index = __pyx_t_4;

    /* "cimpl/field.pyx":335
 *             return
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] &= ~other.data[chunk_index]             # <<<<<<<<<<<<<<
 *         self.calc_length()
 * 
 */
    __pyx_t_5 = __pyx_v_chunk_index;
    (__pyx_v_self->data[__pyx_t_5]) = ((__pyx_v_self->data[__pyx_t_5]) & (~(__pyx_v_other->data[__pyx_v_chunk_index])));
  }

  /* "cimpl/field.pyx":336
 *         for chunk_index in range(PAGE_CHUNKS):
 *             self.data[chunk_index] &= ~other.data[chunk_index]
 *         self.calc_length()             # <<<<<<<<<<<<<<
 * 
 *     cdef inline const char* _state(self):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);

  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":338
 *         self.calc_length()
 * 
 *     cdef inline const char* _state(self):             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_EMPTY:
 *             return "EMPTY"
 */

static CYTHON_INLINE char const *__pyx_f_8bitfield_7IdsPage__state(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  char const *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_state", 0);

  /* "cimpl/field.pyx":339
 * 
 *     cdef inline const char* _state(self):
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             return "EMPTY"
 *         if self.page_state == PAGE_FULL:
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 3);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":340
 *     cdef inline const char* _state(self):
 *         if self.page_state == PAGE_EMPTY:
 *             return "EMPTY"             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_FULL:
 *             return "FULL"
 */
    __pyx_r = __pyx_k__EMPTY;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":341
 *         if self.page_state == PAGE_EMPTY:
 *             return "EMPTY"
 *         if self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             return "FULL"
 *         if self.page_state == PAGE_PARTIAL:
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 2);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":342
 *             return "EMPTY"
 *         if self.page_state == PAGE_FULL:
 *             return "FULL"             # <<<<<<<<<<<<<<
 *         if self.page_state == PAGE_PARTIAL:
 *             return "PARTIAL"
 */
    __pyx_r = __pyx_k__FULL;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":343
 *         if self.page_state == PAGE_FULL:
 *             return "FULL"
 *         if self.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             return "PARTIAL"
 *         return "ERROR"
 */
  __pyx_t_1 = (__pyx_v_self->page_state == 1);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":344
 *             return "FULL"
 *         if self.page_state == PAGE_PARTIAL:
 *             return "PARTIAL"             # <<<<<<<<<<<<<<
 *         return "ERROR"
 * 
 */
    __pyx_r = __pyx_k__PARTIAL;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":345
 *         if self.page_state == PAGE_PARTIAL:
 *             return "PARTIAL"
 *         return "ERROR"             # <<<<<<<<<<<<<<
 * 
 *     cdef symmetric_difference_update(self, IdsPage other):
 */
  __pyx_r = __pyx_k__ERROR;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":347
 *         return "ERROR"
 * 
 *     cdef symmetric_difference_update(self, IdsPage other):             # <<<<<<<<<<<<<<
 *         cdef usize_t chunk_index
 *         if self.page_state == PAGE_EMPTY:
 */

static PyObject *__pyx_f_8bitfield_7IdsPage_symmetric_difference_update(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_other) {
  usize_t __pyx_v_chunk_index;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  struct __pyx_opt_args_8bitfield_7IdsPage__alloc __pyx_t_2;
  usize_t __pyx_t_3;
  usize_t __pyx_t_4;
  usize_t __pyx_t_5;
  __Pyx_RefNannySetupContext("symmetric_difference_update", 0);

  /* "cimpl/field.pyx":368
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~other.data[chunk_index]
 *         elif self.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 */
  switch (__pyx_v_self->page_state) {

    /* "cimpl/field.pyx":349
 *     cdef symmetric_difference_update(self, IdsPage other):
 *         cdef usize_t chunk_index
 *         if self.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 */
    case 3:

    /* "cimpl/field.pyx":350
 *         cdef usize_t chunk_index
 *         if self.page_state == PAGE_EMPTY:
 *             if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *                 return
 *             elif other.page_state == PAGE_FULL:
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 3);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":351
 *         if self.page_state == PAGE_EMPTY:
 *             if other.page_state == PAGE_EMPTY:
 *                 return             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_FULL)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L3;
    }

    /* "cimpl/field.pyx":352
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 *             elif other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *                 self._dealloc(PAGE_FULL)
 *                 return
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 2);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":353
 *                 return
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 2);

      /* "cimpl/field.pyx":354
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_FULL)
 *                 return             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_EMPTY)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L3;
    }

    /* "cimpl/field.pyx":355
 *                 self._dealloc(PAGE_FULL)
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 self._alloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 1);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":356
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         elif self.page_state == PAGE_FULL:
 */
      __pyx_t_2.__pyx_n = 1;
      __pyx_t_2.fill = 3;
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, &__pyx_t_2); 

      /* "cimpl/field.pyx":357
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)             # <<<<<<<<<<<<<<
 *         elif self.page_state == PAGE_FULL:
 *             if other.page_state == PAGE_EMPTY:
 */
      memcpy(__pyx_v_self->data, __pyx_v_other->data, (CHUNK_BYTES * PAGE_CHUNKS));
      goto __pyx_L3;
    }
    __pyx_L3:;
    break;

    /* "cimpl/field.pyx":358
 *                 self._alloc(PAGE_EMPTY)
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         elif self.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 */
    case 2:

    /* "cimpl/field.pyx":359
 *                 memcpy(self.data, other.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         elif self.page_state == PAGE_FULL:
 *             if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *                 return
 *             elif other.page_state == PAGE_FULL:
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 3);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":360
 *         elif self.page_state == PAGE_FULL:
 *             if other.page_state == PAGE_EMPTY:
 *                 return             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L4;
    }

    /* "cimpl/field.pyx":361
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 *             elif other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *                 self._dealloc(PAGE_EMPTY)
 *                 return
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 2);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":362
 *                 return
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)             # <<<<<<<<<<<<<<
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_dealloc(__pyx_v_self, 3);

      /* "cimpl/field.pyx":363
 *             elif other.page_state == PAGE_FULL:
 *                 self._dealloc(PAGE_EMPTY)
 *                 return             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_FULL)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L4;
    }

    /* "cimpl/field.pyx":364
 *                 self._dealloc(PAGE_EMPTY)
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 self._alloc(PAGE_FULL)
 *                 for chunk_index in range(PAGE_CHUNKS):
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 1);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":365
 *                 return
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_FULL)             # <<<<<<<<<<<<<<
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~other.data[chunk_index]
 */
      __pyx_t_2.__pyx_n = 1;
      __pyx_t_2.fill = 2;
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, &__pyx_t_2); 

      /* "cimpl/field.pyx":366
 *             elif other.page_state == PAGE_PARTIAL:
 *                 self._alloc(PAGE_FULL)
 *                 for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                     self.data[chunk_index] = ~other.data[chunk_index]
 *         elif self.page_state == PAGE_PARTIAL:
 */
      __pyx_t_3 = PAGE_CHUNKS;
      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
        __pyx_v_chunk_index = __pyx_t_4;

        /* "cimpl/field.pyx":367
 *                 self._alloc(PAGE_FULL)
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~other.data[chunk_index]             # <<<<<<<<<<<<<<
 *         elif self.page_state == PAGE_PARTIAL:
 *             if other.page_state == PAGE_EMPTY:
 */
        (__pyx_v_self->data[__pyx_v_chunk_index]) = (~(__pyx_v_other->data[__pyx_v_chunk_index]));
      }
      goto __pyx_L4;
    }
    __pyx_L4:;
    break;

    /* "cimpl/field.pyx":368
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~other.data[chunk_index]
 *         elif self.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 */
    case 1:

    /* "cimpl/field.pyx":369
 *                     self.data[chunk_index] = ~other.data[chunk_index]
 *         elif self.page_state == PAGE_PARTIAL:
 *             if other.page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *                 return
 *             elif other.page_state == PAGE_FULL:
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 3);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":370
 *         elif self.page_state == PAGE_PARTIAL:
 *             if other.page_state == PAGE_EMPTY:
 *                 return             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_FULL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      goto __pyx_L7;
    }

    /* "cimpl/field.pyx":371
 *             if other.page_state == PAGE_EMPTY:
 *                 return
 *             elif other.page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~self.data[chunk_index]
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 2);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":372
 *                 return
 *             elif other.page_state == PAGE_FULL:
 *                 for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                     self.data[chunk_index] = ~self.data[chunk_index]
 *             elif other.page_state == PAGE_PARTIAL:
 */
      __pyx_t_3 = PAGE_CHUNKS;
      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
        __pyx_v_chunk_index = __pyx_t_4;

        /* "cimpl/field.pyx":373
 *             elif other.page_state == PAGE_FULL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~self.data[chunk_index]             # <<<<<<<<<<<<<<
 *             elif other.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 */
        (__pyx_v_self->data[__pyx_v_chunk_index]) = (~(__pyx_v_self->data[__pyx_v_chunk_index]));
      }
      goto __pyx_L7;
    }

    /* "cimpl/field.pyx":374
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] = ~self.data[chunk_index]
 *             elif other.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] ^= other.data[chunk_index]
 */
    __pyx_t_1 = (__pyx_v_other->page_state == 1);
    if (__pyx_t_1) {

      /* "cimpl/field.pyx":375
 *                     self.data[chunk_index] = ~self.data[chunk_index]
 *             elif other.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                     self.data[chunk_index] ^= other.data[chunk_index]
 *         self.calc_length()
 */
      __pyx_t_3 = PAGE_CHUNKS;
      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
        __pyx_v_chunk_index = __pyx_t_4;

        /* "cimpl/field.pyx":376
 *             elif other.page_state == PAGE_PARTIAL:
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] ^= other.data[chunk_index]             # <<<<<<<<<<<<<<
 *         self.calc_length()
 * 
 */
        __pyx_t_5 = __pyx_v_chunk_index;
        (__pyx_v_self->data[__pyx_t_5]) = ((__pyx_v_self->data[__pyx_t_5]) ^ (__pyx_v_other->data[__pyx_v_chunk_index]));
      }
      goto __pyx_L7;
    }
    __pyx_L7:;
    break;
  }

  /* "cimpl/field.pyx":377
 *                 for chunk_index in range(PAGE_CHUNKS):
 *                     self.data[chunk_index] ^= other.data[chunk_index]
 *         self.calc_length()             # <<<<<<<<<<<<<<
 * 
 *     cdef IdsPage clone(self):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);

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

/* "cimpl/field.pyx":379
 *         self.calc_length()
 * 
 *     cdef IdsPage clone(self):             # <<<<<<<<<<<<<<
 *         new_page = IdsPage()
 *         new_page.page_state = self.page_state
 */

static struct __pyx_obj_8bitfield_IdsPage *__pyx_f_8bitfield_7IdsPage_clone(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_new_page = NULL;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  usize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clone", 0);

  /* "cimpl/field.pyx":380
 * 
 *     cdef IdsPage clone(self):
 *         new_page = IdsPage()             # <<<<<<<<<<<<<<
 *         new_page.page_state = self.page_state
 * 
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_IdsPage)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":381
 *     cdef IdsPage clone(self):
 *         new_page = IdsPage()
 *         new_page.page_state = self.page_state             # <<<<<<<<<<<<<<
 * 
 *         if self.page_state == PAGE_PARTIAL:
 */
  __pyx_t_2 = __pyx_v_self->page_state;
  __pyx_v_new_page->page_state = __pyx_t_2;

  /* "cimpl/field.pyx":383
 *         new_page.page_state = self.page_state
 * 
 *         if self.page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *             new_page._alloc()
 *             memcpy(new_page.data, self.data, CHUNK_BYTES * PAGE_CHUNKS)
 */
  __pyx_t_3 = (__pyx_v_self->page_state == 1);
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":384
 * 
 *         if self.page_state == PAGE_PARTIAL:
 *             new_page._alloc()             # <<<<<<<<<<<<<<
 *             memcpy(new_page.data, self.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         new_page._count = self._count
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_new_page->__pyx_vtab)->_alloc(__pyx_v_new_page, NULL);

    /* "cimpl/field.pyx":385
 *         if self.page_state == PAGE_PARTIAL:
 *             new_page._alloc()
 *             memcpy(new_page.data, self.data, CHUNK_BYTES * PAGE_CHUNKS)             # <<<<<<<<<<<<<<
 *         new_page._count = self._count
 *         return new_page
 */
    memcpy(__pyx_v_new_page->data, __pyx_v_self->data, (CHUNK_BYTES * PAGE_CHUNKS));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":386
 *             new_page._alloc()
 *             memcpy(new_page.data, self.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         new_page._count = self._count             # <<<<<<<<<<<<<<
 *         return new_page
 * 
 */
  __pyx_t_4 = __pyx_v_self->_count;
  __pyx_v_new_page->_count = __pyx_t_4;

  /* "cimpl/field.pyx":387
 *             memcpy(new_page.data, self.data, CHUNK_BYTES * PAGE_CHUNKS)
 *         new_page._count = self._count
 *         return new_page             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(IdsPage a,IdsPage b, operator):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_new_page));
  __pyx_r = __pyx_v_new_page;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_8bitfield_IdsPage *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.IdsPage.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new_page);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_7IdsPage_9__richcmp__(PyObject *__pyx_v_a, PyObject *__pyx_v_b, int __pyx_arg_operator); /*proto*/
static PyObject *__pyx_pw_8bitfield_7IdsPage_9__richcmp__(PyObject *__pyx_v_a, PyObject *__pyx_v_b, int __pyx_arg_operator) {
  PyObject *__pyx_v_operator = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_v_operator = PyInt_FromLong(__pyx_arg_operator); if (unlikely(!__pyx_v_operator)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __Pyx_GOTREF(__pyx_v_operator);
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.IdsPage.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_8bitfield_IdsPage, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_8bitfield_IdsPage, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_7IdsPage_8__richcmp__(((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_a), ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_v_b), ((PyObject *)__pyx_v_operator));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_operator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":389
 *         return new_page
 * 
 *     def __richcmp__(IdsPage a,IdsPage b, operator):             # <<<<<<<<<<<<<<
 *         cdef usize_t current
 *         if operator == 2:
 */

static PyObject *__pyx_pf_8bitfield_7IdsPage_8__richcmp__(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_a, struct __pyx_obj_8bitfield_IdsPage *__pyx_v_b, PyObject *__pyx_v_operator) {
  usize_t __pyx_v_current;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  usize_t __pyx_t_5;
  usize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cimpl/field.pyx":391
 *     def __richcmp__(IdsPage a,IdsPage b, operator):
 *         cdef usize_t current
 *         if operator == 2:             # <<<<<<<<<<<<<<
 *             if a.count != b.count: # cheap
 *                 return False
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":392
 *         cdef usize_t current
 *         if operator == 2:
 *             if a.count != b.count: # cheap             # <<<<<<<<<<<<<<
 *                 return False
 *             if a.page_state != b.page_state:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s__count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s__count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cimpl/field.pyx":393
 *         if operator == 2:
 *             if a.count != b.count: # cheap
 *                 return False             # <<<<<<<<<<<<<<
 *             if a.page_state != b.page_state:
 *                 return False
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "cimpl/field.pyx":394
 *             if a.count != b.count: # cheap
 *                 return False
 *             if a.page_state != b.page_state:             # <<<<<<<<<<<<<<
 *                 return False
 *             if a.page_state != PAGE_PARTIAL:
 */
    __pyx_t_2 = (__pyx_v_a->page_state != __pyx_v_b->page_state);
    if (__pyx_t_2) {

      /* "cimpl/field.pyx":395
 *                 return False
 *             if a.page_state != b.page_state:
 *                 return False             # <<<<<<<<<<<<<<
 *             if a.page_state != PAGE_PARTIAL:
 *                 return True
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cimpl/field.pyx":396
 *             if a.page_state != b.page_state:
 *                 return False
 *             if a.page_state != PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 return True
 *             for current in range(PAGE_CHUNKS):
 */
    __pyx_t_2 = (__pyx_v_a->page_state != 1);
    if (__pyx_t_2) {

      /* "cimpl/field.pyx":397
 *                 return False
 *             if a.page_state != PAGE_PARTIAL:
 *                 return True             # <<<<<<<<<<<<<<
 *             for current in range(PAGE_CHUNKS):
 *                 if a.data[current] != b.data[current]:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cimpl/field.pyx":398
 *             if a.page_state != PAGE_PARTIAL:
 *                 return True
 *             for current in range(PAGE_CHUNKS):             # <<<<<<<<<<<<<<
 *                 if a.data[current] != b.data[current]:
 *                     return False
 */
    __pyx_t_5 = PAGE_CHUNKS;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_current = __pyx_t_6;

      /* "cimpl/field.pyx":399
 *                 return True
 *             for current in range(PAGE_CHUNKS):
 *                 if a.data[current] != b.data[current]:             # <<<<<<<<<<<<<<
 *                     return False
 *             return True
 */
      __pyx_t_2 = ((__pyx_v_a->data[__pyx_v_current]) != (__pyx_v_b->data[__pyx_v_current]));
      if (__pyx_t_2) {

        /* "cimpl/field.pyx":400
 *             for current in range(PAGE_CHUNKS):
 *                 if a.data[current] != b.data[current]:
 *                     return False             # <<<<<<<<<<<<<<
 *             return True
 *         elif operator == 3:
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        goto __pyx_L0;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }

    /* "cimpl/field.pyx":401
 *                 if a.data[current] != b.data[current]:
 *                     return False
 *             return True             # <<<<<<<<<<<<<<
 *         elif operator == 3:
 *             return not a == b
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "cimpl/field.pyx":402
 *                     return False
 *             return True
 *         elif operator == 3:             # <<<<<<<<<<<<<<
 *             return not a == b
 *         raise NotImplementedError()
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":403
 *             return True
 *         elif operator == 3:
 *             return not a == b             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_b), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":404
 *         elif operator == 3:
 *             return not a == b
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     cdef char *set_bits(self, char *start, char *end):
 */
  __pyx_t_4 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __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_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bitfield.IdsPage.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":406
 *         raise NotImplementedError()
 * 
 *     cdef char *set_bits(self, char *start, char *end):             # <<<<<<<<<<<<<<
 *         cdef usize_t bytes_to_read = min(PAGE_BYTES, (end - start)+1)
 *         self._alloc()
 */

static char *__pyx_f_8bitfield_7IdsPage_set_bits(struct __pyx_obj_8bitfield_IdsPage *__pyx_v_self, char *__pyx_v_start, char *__pyx_v_end) {
  usize_t __pyx_v_bytes_to_read;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  usize_t __pyx_t_2;
  long __pyx_t_3;
  __Pyx_RefNannySetupContext("set_bits", 0);

  /* "cimpl/field.pyx":407
 * 
 *     cdef char *set_bits(self, char *start, char *end):
 *         cdef usize_t bytes_to_read = min(PAGE_BYTES, (end - start)+1)             # <<<<<<<<<<<<<<
 *         self._alloc()
 *         memcpy(self.data, start, bytes_to_read)
 */
  __pyx_t_1 = ((__pyx_v_end - __pyx_v_start) + 1);
  __pyx_t_2 = PAGE_BYTES;
  if ((__pyx_t_1 < __pyx_t_2)) {
    __pyx_t_3 = __pyx_t_1;
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  __pyx_v_bytes_to_read = __pyx_t_3;

  /* "cimpl/field.pyx":408
 *     cdef char *set_bits(self, char *start, char *end):
 *         cdef usize_t bytes_to_read = min(PAGE_BYTES, (end - start)+1)
 *         self._alloc()             # <<<<<<<<<<<<<<
 *         memcpy(self.data, start, bytes_to_read)
 *         self.calc_length()
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->_alloc(__pyx_v_self, NULL);

  /* "cimpl/field.pyx":409
 *         cdef usize_t bytes_to_read = min(PAGE_BYTES, (end - start)+1)
 *         self._alloc()
 *         memcpy(self.data, start, bytes_to_read)             # <<<<<<<<<<<<<<
 *         self.calc_length()
 *         return start + bytes_to_read
 */
  memcpy(__pyx_v_self->data, __pyx_v_start, __pyx_v_bytes_to_read);

  /* "cimpl/field.pyx":410
 *         self._alloc()
 *         memcpy(self.data, start, bytes_to_read)
 *         self.calc_length()             # <<<<<<<<<<<<<<
 *         return start + bytes_to_read
 * 
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_self->__pyx_vtab)->calc_length(__pyx_v_self);

  /* "cimpl/field.pyx":411
 *         memcpy(self.data, start, bytes_to_read)
 *         self.calc_length()
 *         return start + bytes_to_read             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_start + __pyx_v_bytes_to_read);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8bitfield_8Bitfield_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8bitfield_8Bitfield_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v__data = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s___data,0};
    PyObject* values[1] = {0};

    /* "cimpl/field.pyx":430
 *     __slots__ = ()
 * 
 *     def __cinit__(self, _data=None):             # <<<<<<<<<<<<<<
 *         self.pages = list()
 *         if _data is not None:
 */
    values[0] = ((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 (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s___data);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v__data = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield___cinit__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), __pyx_v__data);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8bitfield_8Bitfield___cinit__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v__data) {
  int __pyx_r;
  __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("__cinit__", 0);

  /* "cimpl/field.pyx":431
 * 
 *     def __cinit__(self, _data=None):
 *         self.pages = list()             # <<<<<<<<<<<<<<
 *         if _data is not None:
 *             self.load(_data)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->pages);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pages));
  __pyx_v_self->pages = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":432
 *     def __cinit__(self, _data=None):
 *         self.pages = list()
 *         if _data is not None:             # <<<<<<<<<<<<<<
 *             self.load(_data)
 * 
 */
  __pyx_t_2 = (__pyx_v__data != Py_None);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":433
 *         self.pages = list()
 *         if _data is not None:
 *             self.load(_data)             # <<<<<<<<<<<<<<
 * 
 *     cdef _ensure_page_exists(self, usize_t page):
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->load(__pyx_v_self, __pyx_v__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":435
 *             self.load(_data)
 * 
 *     cdef _ensure_page_exists(self, usize_t page):             # <<<<<<<<<<<<<<
 *         cdef list pages = self.pages
 *         while page >= len(pages):
 */

static PyObject *__pyx_f_8bitfield_8Bitfield__ensure_page_exists(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_page) {
  PyObject *__pyx_v_pages = 0;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_new_page = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_ensure_page_exists", 0);

  /* "cimpl/field.pyx":436
 * 
 *     cdef _ensure_page_exists(self, usize_t page):
 *         cdef list pages = self.pages             # <<<<<<<<<<<<<<
 *         while page >= len(pages):
 *             new_page = IdsPage()
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_pages = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":437
 *     cdef _ensure_page_exists(self, usize_t page):
 *         cdef list pages = self.pages
 *         while page >= len(pages):             # <<<<<<<<<<<<<<
 *             new_page = IdsPage()
 *             pages.append(new_page)
 */
  while (1) {
    if (unlikely(((PyObject *)__pyx_v_pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_pages)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = (__pyx_v_page >= __pyx_t_2);
    if (!__pyx_t_3) break;

    /* "cimpl/field.pyx":438
 *         cdef list pages = self.pages
 *         while page >= len(pages):
 *             new_page = IdsPage()             # <<<<<<<<<<<<<<
 *             pages.append(new_page)
 * 
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_IdsPage)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_new_page));
    __pyx_v_new_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":439
 *         while page >= len(pages):
 *             new_page = IdsPage()
 *             pages.append(new_page)             # <<<<<<<<<<<<<<
 * 
 *     cdef _cleanup(self):
 */
    if (unlikely(((PyObject *)__pyx_v_pages) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_pages, ((PyObject *)__pyx_v_new_page)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __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("bitfield.Bitfield._ensure_page_exists", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pages);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":441
 *             pages.append(new_page)
 * 
 *     cdef _cleanup(self):             # <<<<<<<<<<<<<<
 *         while len(self.pages) > 0 and self.pages[-1].count == 0:
 *             self.pages.pop()
 */

static PyObject *__pyx_f_8bitfield_8Bitfield__cleanup(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cleanup", 0);

  /* "cimpl/field.pyx":442
 * 
 *     cdef _cleanup(self):
 *         while len(self.pages) > 0 and self.pages[-1].count == 0:             # <<<<<<<<<<<<<<
 *             self.pages.pop()
 * 
 */
  while (1) {
    __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
    __Pyx_INCREF(__pyx_t_1);
    if (unlikely(__pyx_t_1 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = (__pyx_t_2 > 0);
    if (__pyx_t_3) {
      if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), -1, sizeof(long), PyInt_FromLong, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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_RichCompare(__pyx_t_4, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_5;
    } else {
      __pyx_t_6 = __pyx_t_3;
    }
    if (!__pyx_t_6) break;

    /* "cimpl/field.pyx":443
 *     cdef _cleanup(self):
 *         while len(self.pages) > 0 and self.pages[-1].count == 0:
 *             self.pages.pop()             # <<<<<<<<<<<<<<
 * 
 *     cpdef add(self, usize_t number):
 */
    __pyx_t_1 = __Pyx_PyObject_Pop(((PyObject *)__pyx_v_self->pages)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bitfield.Bitfield._cleanup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":445
 *             self.pages.pop()
 * 
 *     cpdef add(self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Add a positive integer to the bitfield"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_3add(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_add(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number, int __pyx_skip_dispatch) {
  usize_t __pyx_v_page;
  usize_t __pyx_v_page_index;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_the_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("add", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__add); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_3add)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":447
 *     cpdef add(self, usize_t number):
 *         """Add a positive integer to the bitfield"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         self._ensure_page_exists(page)
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page = (__pyx_v_number / PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":448
 *         """Add a positive integer to the bitfield"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         self._ensure_page_exists(page)
 *         cdef IdsPage the_page = self.pages[page]
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page_index = (__pyx_v_number % PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":449
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         self._ensure_page_exists(page)             # <<<<<<<<<<<<<<
 *         cdef IdsPage the_page = self.pages[page]
 *         the_page.add(page_index)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->_ensure_page_exists(__pyx_v_self, __pyx_v_page); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":450
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         self._ensure_page_exists(page)
 *         cdef IdsPage the_page = self.pages[page]             # <<<<<<<<<<<<<<
 *         the_page.add(page_index)
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":451
 *         self._ensure_page_exists(page)
 *         cdef IdsPage the_page = self.pages[page]
 *         the_page.add(page_index)             # <<<<<<<<<<<<<<
 * 
 *     cpdef remove(Bitfield self, usize_t number):
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->add(__pyx_v_the_page, __pyx_v_page_index);

  __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_AddTraceback("bitfield.Bitfield.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_3add(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_2add[] = "Add a positive integer to the bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_3add(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  usize_t __pyx_v_number;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add (wrapper)", 0);
  assert(__pyx_arg_number); {
    __pyx_v_number = __Pyx_PyInt_from_py_usize_t(__pyx_arg_number); if (unlikely((__pyx_v_number == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_2add(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((usize_t)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":445
 *             self.pages.pop()
 * 
 *     cpdef add(self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Add a positive integer to the bitfield"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_2add(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number) {
  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("add", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->add(__pyx_v_self, __pyx_v_number, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __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("bitfield.Bitfield.add", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":453
 *         the_page.add(page_index)
 * 
 *     cpdef remove(Bitfield self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Remove a positive integer from the bitfield
 *         If the integer does not exist in the field, raise a KeyError"""
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_5remove(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_remove(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number, int __pyx_skip_dispatch) {
  usize_t __pyx_v_page_no;
  usize_t __pyx_v_page_index;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  size_t __pyx_v_before_count;
  size_t __pyx_v_after_count;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  size_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__remove); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_5remove)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":456
 *         """Remove a positive integer from the bitfield
 *         If the integer does not exist in the field, raise a KeyError"""
 *         cdef usize_t page_no = number / PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page_no >= len(self.pages):
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page_no = (__pyx_v_number / PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":457
 *         If the integer does not exist in the field, raise a KeyError"""
 *         cdef usize_t page_no = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         if page_no >= len(self.pages):
 *             raise KeyError()
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page_index = (__pyx_v_number % PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":458
 *         cdef usize_t page_no = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page_no >= len(self.pages):             # <<<<<<<<<<<<<<
 *             raise KeyError()
 *         cdef IdsPage page = self.pages[page_no]
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__pyx_v_page_no >= __pyx_t_4);
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":459
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page_no >= len(self.pages):
 *             raise KeyError()             # <<<<<<<<<<<<<<
 *         cdef IdsPage page = self.pages[page_no]
 *         cdef size_t before_count = page.count
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __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 = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":460
 *         if page_no >= len(self.pages):
 *             raise KeyError()
 *         cdef IdsPage page = self.pages[page_no]             # <<<<<<<<<<<<<<
 *         cdef size_t before_count = page.count
 *         page.remove(page_index)
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_page_no, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":461
 *             raise KeyError()
 *         cdef IdsPage page = self.pages[page_no]
 *         cdef size_t before_count = page.count             # <<<<<<<<<<<<<<
 *         page.remove(page_index)
 *         cdef size_t after_count = page.count
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_page), __pyx_n_s__count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_AsSize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_before_count = __pyx_t_6;

  /* "cimpl/field.pyx":462
 *         cdef IdsPage page = self.pages[page_no]
 *         cdef size_t before_count = page.count
 *         page.remove(page_index)             # <<<<<<<<<<<<<<
 *         cdef size_t after_count = page.count
 *         if before_count == after_count:
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->remove(__pyx_v_page, __pyx_v_page_index);

  /* "cimpl/field.pyx":463
 *         cdef size_t before_count = page.count
 *         page.remove(page_index)
 *         cdef size_t after_count = page.count             # <<<<<<<<<<<<<<
 *         if before_count == after_count:
 *             raise KeyError()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_page), __pyx_n_s__count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_AsSize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_after_count = __pyx_t_6;

  /* "cimpl/field.pyx":464
 *         page.remove(page_index)
 *         cdef size_t after_count = page.count
 *         if before_count == after_count:             # <<<<<<<<<<<<<<
 *             raise KeyError()
 * 
 */
  __pyx_t_5 = (__pyx_v_before_count == __pyx_v_after_count);
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":465
 *         cdef size_t after_count = page.count
 *         if before_count == after_count:
 *             raise KeyError()             # <<<<<<<<<<<<<<
 * 
 *     cpdef discard(Bitfield self, usize_t number):
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __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 = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_5remove(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_4remove[] = "Remove a positive integer from the bitfield\n        If the integer does not exist in the field, raise a KeyError";
static PyObject *__pyx_pw_8bitfield_8Bitfield_5remove(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  usize_t __pyx_v_number;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove (wrapper)", 0);
  assert(__pyx_arg_number); {
    __pyx_v_number = __Pyx_PyInt_from_py_usize_t(__pyx_arg_number); if (unlikely((__pyx_v_number == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_4remove(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((usize_t)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":453
 *         the_page.add(page_index)
 * 
 *     cpdef remove(Bitfield self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Remove a positive integer from the bitfield
 *         If the integer does not exist in the field, raise a KeyError"""
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_4remove(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number) {
  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("remove", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->remove(__pyx_v_self, __pyx_v_number, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __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("bitfield.Bitfield.remove", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":467
 *             raise KeyError()
 * 
 *     cpdef discard(Bitfield self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Remove a positive integer from the bitfield if it is a member.
 *         If the element is not a member, do nothing."""
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_7discard(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_discard(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number, int __pyx_skip_dispatch) {
  usize_t __pyx_v_page;
  usize_t __pyx_v_page_index;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_the_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("discard", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__discard); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_7discard)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(__pyx_v_number); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":470
 *         """Remove a positive integer from the bitfield if it is a member.
 *         If the element is not a member, do nothing."""
 *         cdef usize_t page = number / PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         if page >= len(self.pages):
 *             return
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page = (__pyx_v_number / PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":471
 *         If the element is not a member, do nothing."""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         if page >= len(self.pages):             # <<<<<<<<<<<<<<
 *             return
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (__pyx_v_page >= __pyx_t_4);
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":472
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         if page >= len(self.pages):
 *             return             # <<<<<<<<<<<<<<
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         cdef IdsPage the_page = self.pages[page]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":473
 *         if page >= len(self.pages):
 *             return
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         cdef IdsPage the_page = self.pages[page]
 *         the_page.remove(page_index)
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_page_index = (__pyx_v_number % PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":474
 *             return
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         cdef IdsPage the_page = self.pages[page]             # <<<<<<<<<<<<<<
 *         the_page.remove(page_index)
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":475
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         cdef IdsPage the_page = self.pages[page]
 *         the_page.remove(page_index)             # <<<<<<<<<<<<<<
 * 
 *     property count:
 */
  ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->remove(__pyx_v_the_page, __pyx_v_page_index);

  __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_AddTraceback("bitfield.Bitfield.discard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_7discard(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_6discard[] = "Remove a positive integer from the bitfield if it is a member.\n        If the element is not a member, do nothing.";
static PyObject *__pyx_pw_8bitfield_8Bitfield_7discard(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  usize_t __pyx_v_number;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("discard (wrapper)", 0);
  assert(__pyx_arg_number); {
    __pyx_v_number = __Pyx_PyInt_from_py_usize_t(__pyx_arg_number); if (unlikely((__pyx_v_number == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.discard", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_6discard(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((usize_t)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":467
 *             raise KeyError()
 * 
 *     cpdef discard(Bitfield self, usize_t number):             # <<<<<<<<<<<<<<
 *         """Remove a positive integer from the bitfield if it is a member.
 *         If the element is not a member, do nothing."""
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_6discard(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_number) {
  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("discard", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->discard(__pyx_v_self, __pyx_v_number, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __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("bitfield.Bitfield.discard", __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_8bitfield_8Bitfield_5count_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_5count_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_5count___get__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":479
 *     property count:
 *         """The number of integers in the field"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef usize_t num = 0
 *             for page in self.pages:
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_5count___get__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  usize_t __pyx_v_num;
  PyObject *__pyx_v_page = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  usize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "cimpl/field.pyx":480
 *         """The number of integers in the field"""
 *         def __get__(self):
 *             cdef usize_t num = 0             # <<<<<<<<<<<<<<
 *             for page in self.pages:
 *                 num += page.count
 */
  __pyx_v_num = 0;

  /* "cimpl/field.pyx":481
 *         def __get__(self):
 *             cdef usize_t num = 0
 *             for page in self.pages:             # <<<<<<<<<<<<<<
 *                 num += page.count
 *             return num
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_page);
    __pyx_v_page = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cimpl/field.pyx":482
 *             cdef usize_t num = 0
 *             for page in self.pages:
 *                 num += page.count             # <<<<<<<<<<<<<<
 *             return num
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_to_py_usize_t(__pyx_v_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_page, __pyx_n_s__count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyInt_from_py_usize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_num = __pyx_t_6;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":483
 *             for page in self.pages:
 *                 num += page.count
 *             return num             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_usize_t(__pyx_v_num); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __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_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("bitfield.Bitfield.count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static Py_ssize_t __pyx_pw_8bitfield_8Bitfield_9__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_8__len__[] = "The number of integers in the field";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_8__len__;
#endif
static Py_ssize_t __pyx_pw_8bitfield_8Bitfield_9__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_8__len__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":485
 *             return num
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         """The number of integers in the field"""
 *         return self.count
 */

static Py_ssize_t __pyx_pf_8bitfield_8Bitfield_8__len__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "cimpl/field.pyx":487
 *     def __len__(self):
 *         """The number of integers in the field"""
 *         return self.count             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, number):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8bitfield_8Bitfield_11__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_number); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_10__contains__[] = "Returns true if number is present in the field";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_10__contains__;
#endif
static int __pyx_pw_8bitfield_8Bitfield_11__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_number) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_10__contains__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((PyObject *)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":489
 *         return self.count
 * 
 *     def __contains__(self, number):             # <<<<<<<<<<<<<<
 *         """Returns true if number is present in the field"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 */

static int __pyx_pf_8bitfield_8Bitfield_10__contains__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_number) {
  usize_t __pyx_v_page;
  usize_t __pyx_v_page_index;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  usize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "cimpl/field.pyx":491
 *     def __contains__(self, number):
 *         """Returns true if number is present in the field"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page >= len(self.pages):
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_usize_t(PAGE_FULL_COUNT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_number, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_from_py_usize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_page = __pyx_t_3;

  /* "cimpl/field.pyx":492
 *         """Returns true if number is present in the field"""
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         if page >= len(self.pages):
 *             return False
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_usize_t(PAGE_FULL_COUNT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Remainder(__pyx_v_number, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyInt_from_py_usize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_page_index = __pyx_t_3;

  /* "cimpl/field.pyx":493
 *         cdef usize_t page = number / PAGE_FULL_COUNT
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page >= len(self.pages):             # <<<<<<<<<<<<<<
 *             return False
 *         return page_index in self.pages[page]
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__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_t_5 = (__pyx_v_page >= __pyx_t_4);
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":494
 *         cdef usize_t page_index = number % PAGE_FULL_COUNT
 *         if page >= len(self.pages):
 *             return False             # <<<<<<<<<<<<<<
 *         return page_index in self.pages[page]
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":495
 *         if page >= len(self.pages):
 *             return False
 *         return page_index in self.pages[page]             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_usize_t(__pyx_v_page_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bitfield.Bitfield.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_13__iter__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_12__iter__[] = "Iterate over all integers in the field";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_12__iter__;
#endif
static PyObject *__pyx_pw_8bitfield_8Bitfield_13__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_12__iter__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":497
 *         return page_index in self.pages[page]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         """Iterate over all integers in the field"""
 *         return BitfieldIterator(self)
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_12__iter__(struct __pyx_obj_8bitfield_Bitfield *__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);

  /* "cimpl/field.pyx":499
 *     def __iter__(self):
 *         """Iterate over all integers in the field"""
 *         return BitfieldIterator(self)             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(Bitfield a,Bitfield b, operator):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_BitfieldIterator)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __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("bitfield.Bitfield.__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_8bitfield_8Bitfield_15__richcmp__(PyObject *__pyx_v_a, PyObject *__pyx_v_b, int __pyx_arg_operator); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_15__richcmp__(PyObject *__pyx_v_a, PyObject *__pyx_v_b, int __pyx_arg_operator) {
  PyObject *__pyx_v_operator = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_v_operator = PyInt_FromLong(__pyx_arg_operator); if (unlikely(!__pyx_v_operator)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __Pyx_GOTREF(__pyx_v_operator);
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_8bitfield_Bitfield, 1, "a", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_8bitfield_Bitfield, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_14__richcmp__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_a), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_b), ((PyObject *)__pyx_v_operator));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_operator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":501
 *         return BitfieldIterator(self)
 * 
 *     def __richcmp__(Bitfield a,Bitfield b, operator):             # <<<<<<<<<<<<<<
 *         cdef usize_t current
 *         if operator == 0:
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_14__richcmp__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_a, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_b, PyObject *__pyx_v_operator) {
  usize_t __pyx_v_current;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  usize_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cimpl/field.pyx":503
 *     def __richcmp__(Bitfield a,Bitfield b, operator):
 *         cdef usize_t current
 *         if operator == 0:             # <<<<<<<<<<<<<<
 *             return (b != a) and (a.issubset(b))
 *         if operator == 1:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":504
 *         cdef usize_t current
 *         if operator == 0:
 *             return (b != a) and (a.issubset(b))             # <<<<<<<<<<<<<<
 *         if operator == 1:
 *             return a.issubset(b)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_b), ((PyObject *)__pyx_v_a), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_2) {
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_a->__pyx_vtab)->issubset(__pyx_v_a, __pyx_v_b, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __pyx_t_3;
      __pyx_t_3 = 0;
    } else {
      __pyx_t_4 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":505
 *         if operator == 0:
 *             return (b != a) and (a.issubset(b))
 *         if operator == 1:             # <<<<<<<<<<<<<<
 *             return a.issubset(b)
 *         if operator == 2:
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":506
 *             return (b != a) and (a.issubset(b))
 *         if operator == 1:
 *             return a.issubset(b)             # <<<<<<<<<<<<<<
 *         if operator == 2:
 *             a._cleanup()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_a->__pyx_vtab)->issubset(__pyx_v_a, __pyx_v_b, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":507
 *         if operator == 1:
 *             return a.issubset(b)
 *         if operator == 2:             # <<<<<<<<<<<<<<
 *             a._cleanup()
 *             b._cleanup()
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":508
 *             return a.issubset(b)
 *         if operator == 2:
 *             a._cleanup()             # <<<<<<<<<<<<<<
 *             b._cleanup()
 *             if len(a.pages) != len(b.pages):
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_a->__pyx_vtab)->_cleanup(__pyx_v_a); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cimpl/field.pyx":509
 *         if operator == 2:
 *             a._cleanup()
 *             b._cleanup()             # <<<<<<<<<<<<<<
 *             if len(a.pages) != len(b.pages):
 *                 return False
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_b->__pyx_vtab)->_cleanup(__pyx_v_b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cimpl/field.pyx":510
 *             a._cleanup()
 *             b._cleanup()
 *             if len(a.pages) != len(b.pages):             # <<<<<<<<<<<<<<
 *                 return False
 *             for current in range(len(a.pages)):
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_a->pages);
    __Pyx_INCREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = ((PyObject *)__pyx_v_b->pages);
    __Pyx_INCREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = (__pyx_t_5 != __pyx_t_6);
    if (__pyx_t_2) {

      /* "cimpl/field.pyx":511
 *             b._cleanup()
 *             if len(a.pages) != len(b.pages):
 *                 return False             # <<<<<<<<<<<<<<
 *             for current in range(len(a.pages)):
 *                 if a.pages[current] != b.pages[current]:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "cimpl/field.pyx":512
 *             if len(a.pages) != len(b.pages):
 *                 return False
 *             for current in range(len(a.pages)):             # <<<<<<<<<<<<<<
 *                 if a.pages[current] != b.pages[current]:
 *                     return False
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_a->pages);
    __Pyx_INCREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_current = __pyx_t_7;

      /* "cimpl/field.pyx":513
 *                 return False
 *             for current in range(len(a.pages)):
 *                 if a.pages[current] != b.pages[current]:             # <<<<<<<<<<<<<<
 *                     return False
 *             return True
 */
      if (unlikely(((PyObject *)__pyx_v_a->pages) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_a->pages), __pyx_v_current, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(((PyObject *)__pyx_v_b->pages) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_b->pages), __pyx_v_current, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {

        /* "cimpl/field.pyx":514
 *             for current in range(len(a.pages)):
 *                 if a.pages[current] != b.pages[current]:
 *                     return False             # <<<<<<<<<<<<<<
 *             return True
 *         if operator == 3:
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L0;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }

    /* "cimpl/field.pyx":515
 *                 if a.pages[current] != b.pages[current]:
 *                     return False
 *             return True             # <<<<<<<<<<<<<<
 *         if operator == 3:
 *             return not a == b
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "cimpl/field.pyx":516
 *                     return False
 *             return True
 *         if operator == 3:             # <<<<<<<<<<<<<<
 *             return not a == b
 *         if operator == 4:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":517
 *             return True
 *         if operator == 3:
 *             return not a == b             # <<<<<<<<<<<<<<
 *         if operator == 4:
 *             return (a != b) and (b.issubset(a))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_b), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "cimpl/field.pyx":518
 *         if operator == 3:
 *             return not a == b
 *         if operator == 4:             # <<<<<<<<<<<<<<
 *             return (a != b) and (b.issubset(a))
 *         if operator == 5:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":519
 *             return not a == b
 *         if operator == 4:
 *             return (a != b) and (b.issubset(a))             # <<<<<<<<<<<<<<
 *         if operator == 5:
 *             return b.issubset(a)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_b), Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_2) {
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_b->__pyx_vtab)->issubset(__pyx_v_b, __pyx_v_a, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1;
      __pyx_t_1 = 0;
    } else {
      __pyx_t_4 = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "cimpl/field.pyx":520
 *         if operator == 4:
 *             return (a != b) and (b.issubset(a))
 *         if operator == 5:             # <<<<<<<<<<<<<<
 *             return b.issubset(a)
 *         raise NotImplementedError()
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_operator, __pyx_int_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":521
 *             return (a != b) and (b.issubset(a))
 *         if operator == 5:
 *             return b.issubset(a)             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_b->__pyx_vtab)->issubset(__pyx_v_b, __pyx_v_a, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "cimpl/field.pyx":522
 *         if operator == 5:
 *             return b.issubset(a)
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     def __or__(Bitfield x, Bitfield y):
 */
  __pyx_t_4 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __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_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bitfield.Bitfield.__richcmp__", __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_8bitfield_8Bitfield_17__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_16__or__[] = "Return a new object that is the union of two bitfields";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_16__or__;
#endif
static PyObject *__pyx_pw_8bitfield_8Bitfield_17__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_8bitfield_Bitfield, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_8bitfield_Bitfield, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_16__or__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":524
 *         raise NotImplementedError()
 * 
 *     def __or__(Bitfield x, Bitfield y):             # <<<<<<<<<<<<<<
 *         """Return a new object that is the union of two bitfields"""
 *         cdef Bitfield new
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_16__or__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  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("__or__", 0);

  /* "cimpl/field.pyx":527
 *         """Return a new object that is the union of two bitfields"""
 *         cdef Bitfield new
 *         new = x.clone()             # <<<<<<<<<<<<<<
 *         new.update(y)
 *         return new
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->clone(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_Bitfield))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":528
 *         cdef Bitfield new
 *         new = x.clone()
 *         new.update(y)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->update(__pyx_v_new, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":529
 *         new = x.clone()
 *         new.update(y)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __ior__(Bitfield x, Bitfield y):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__or__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_19__ior__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_19__ior__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ior__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_8bitfield_Bitfield, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_18__ior__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":531
 *         return new
 * 
 *     def __ior__(Bitfield x, Bitfield y):             # <<<<<<<<<<<<<<
 *         return x.update(y)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_18__ior__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y) {
  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("__ior__", 0);

  /* "cimpl/field.pyx":532
 * 
 *     def __ior__(Bitfield x, Bitfield y):
 *         return x.update(y)             # <<<<<<<<<<<<<<
 * 
 *     def union(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->update(__pyx_v_x, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __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("bitfield.Bitfield.__ior__", __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_8bitfield_8Bitfield_21union(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_21union(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("union (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_20union(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":534
 *         return x.update(y)
 * 
 *     def union(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return self | other
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_20union(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("union", 0);

  /* "cimpl/field.pyx":535
 * 
 *     def union(Bitfield self, Bitfield other):
 *         return self | other             # <<<<<<<<<<<<<<
 * 
 *     def __add__(Bitfield x, usize_t y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyNumber_Or(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __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("bitfield.Bitfield.union", __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_8bitfield_8Bitfield_23__add__(PyObject *__pyx_v_x, PyObject *__pyx_arg_y); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_22__add__[] = "Return a new field with the integer added";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_22__add__;
#endif
static PyObject *__pyx_pw_8bitfield_8Bitfield_23__add__(PyObject *__pyx_v_x, PyObject *__pyx_arg_y) {
  usize_t __pyx_v_y;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
  assert(__pyx_arg_y); {
    __pyx_v_y = __Pyx_PyInt_from_py_usize_t(__pyx_arg_y); if (unlikely((__pyx_v_y == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_8bitfield_Bitfield, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_22__add__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((usize_t)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":537
 *         return self | other
 * 
 *     def __add__(Bitfield x, usize_t y):             # <<<<<<<<<<<<<<
 *         """Return a new field with the integer added"""
 *         cdef Bitfield new
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_22__add__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, usize_t __pyx_v_y) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  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("__add__", 0);

  /* "cimpl/field.pyx":540
 *         """Return a new field with the integer added"""
 *         cdef Bitfield new
 *         new = x.clone()             # <<<<<<<<<<<<<<
 *         new.add(y)
 *         return new
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->clone(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_Bitfield))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":541
 *         cdef Bitfield new
 *         new = x.clone()
 *         new.add(y)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->add(__pyx_v_new, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":542
 *         new = x.clone()
 *         new.add(y)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __iadd__(Bitfield x, usize_t y):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_25__iadd__(PyObject *__pyx_v_x, PyObject *__pyx_arg_y); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_24__iadd__[] = "Add a positive integer to the field";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_8bitfield_8Bitfield_24__iadd__;
#endif
static PyObject *__pyx_pw_8bitfield_8Bitfield_25__iadd__(PyObject *__pyx_v_x, PyObject *__pyx_arg_y) {
  usize_t __pyx_v_y;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
  assert(__pyx_arg_y); {
    __pyx_v_y = __Pyx_PyInt_from_py_usize_t(__pyx_arg_y); if (unlikely((__pyx_v_y == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.__iadd__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_24__iadd__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((usize_t)__pyx_v_y));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":544
 *         return new
 * 
 *     def __iadd__(Bitfield x, usize_t y):             # <<<<<<<<<<<<<<
 *         """Add a positive integer to the field"""
 *         x.add(y)
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_24__iadd__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, usize_t __pyx_v_y) {
  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("__iadd__", 0);

  /* "cimpl/field.pyx":546
 *     def __iadd__(Bitfield x, usize_t y):
 *         """Add a positive integer to the field"""
 *         x.add(y)             # <<<<<<<<<<<<<<
 *         return x
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->add(__pyx_v_x, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":547
 *         """Add a positive integer to the field"""
 *         x.add(y)
 *         return x             # <<<<<<<<<<<<<<
 * 
 *     def __sub__(Bitfield x, Bitfield y):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __pyx_r = ((PyObject *)__pyx_v_x);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__iadd__", __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_8bitfield_8Bitfield_27__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_27__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_8bitfield_Bitfield, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_8bitfield_Bitfield, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_26__sub__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":549
 *         return x
 * 
 *     def __sub__(Bitfield x, Bitfield y):             # <<<<<<<<<<<<<<
 *         cdef Bitfield new
 *         new = x.clone()
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_26__sub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  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("__sub__", 0);

  /* "cimpl/field.pyx":551
 *     def __sub__(Bitfield x, Bitfield y):
 *         cdef Bitfield new
 *         new = x.clone()             # <<<<<<<<<<<<<<
 *         new.difference_update(y)
 *         return new
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->clone(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_Bitfield))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":552
 *         cdef Bitfield new
 *         new = x.clone()
 *         new.difference_update(y)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->difference_update(__pyx_v_new, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":553
 *         new = x.clone()
 *         new.difference_update(y)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(Bitfield x, Bitfield y):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_29__isub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_29__isub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_8bitfield_Bitfield, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_28__isub__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":555
 *         return new
 * 
 *     def __isub__(Bitfield x, Bitfield y):             # <<<<<<<<<<<<<<
 *         return x.difference_update(y)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_28__isub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y) {
  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("__isub__", 0);

  /* "cimpl/field.pyx":556
 * 
 *     def __isub__(Bitfield x, Bitfield y):
 *         return x.difference_update(y)             # <<<<<<<<<<<<<<
 * 
 *     def __isub__(Bitfield x, Bitfield y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->difference_update(__pyx_v_x, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __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("bitfield.Bitfield.__isub__", __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_8bitfield_8Bitfield_31__isub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_31__isub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_8bitfield_Bitfield, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_30__isub__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_x), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_y));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":558
 *         return x.difference_update(y)
 * 
 *     def __isub__(Bitfield x, Bitfield y):             # <<<<<<<<<<<<<<
 *         return x.difference_update(y)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_30__isub__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_x, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_y) {
  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("__isub__", 0);

  /* "cimpl/field.pyx":559
 * 
 *     def __isub__(Bitfield x, Bitfield y):
 *         return x.difference_update(y)             # <<<<<<<<<<<<<<
 * 
 *     def __xor__(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_x->__pyx_vtab)->difference_update(__pyx_v_x, __pyx_v_y, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __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("bitfield.Bitfield.__isub__", __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_8bitfield_8Bitfield_33__xor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_33__xor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__xor__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_8bitfield_Bitfield, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_32__xor__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":561
 *         return x.difference_update(y)
 * 
 *     def __xor__(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return self.symmetric_difference(other)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_32__xor__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("__xor__", 0);

  /* "cimpl/field.pyx":562
 * 
 *     def __xor__(Bitfield self, Bitfield other):
 *         return self.symmetric_difference(other)             # <<<<<<<<<<<<<<
 * 
 *     def __ixor__(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->symmetric_difference(__pyx_v_self, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __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("bitfield.Bitfield.__xor__", __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_8bitfield_8Bitfield_35__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_35__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ixor__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_34__ixor__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":564
 *         return self.symmetric_difference(other)
 * 
 *     def __ixor__(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return self.symmetric_difference_update(other)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_34__ixor__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("__ixor__", 0);

  /* "cimpl/field.pyx":565
 * 
 *     def __ixor__(Bitfield self, Bitfield other):
 *         return self.symmetric_difference_update(other)             # <<<<<<<<<<<<<<
 * 
 *     def __and__(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->symmetric_difference_update(__pyx_v_self, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __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("bitfield.Bitfield.__ixor__", __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_8bitfield_8Bitfield_37__and__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_37__and__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__and__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_8bitfield_Bitfield, 1, "self", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_36__and__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":567
 *         return self.symmetric_difference_update(other)
 * 
 *     def __and__(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return self.intersection(other)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_36__and__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("__and__", 0);

  /* "cimpl/field.pyx":568
 * 
 *     def __and__(Bitfield self, Bitfield other):
 *         return self.intersection(other)             # <<<<<<<<<<<<<<
 * 
 *     def __iand__(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->intersection(__pyx_v_self, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __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("bitfield.Bitfield.__and__", __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_8bitfield_8Bitfield_39__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_39__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iand__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_38__iand__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":570
 *         return self.intersection(other)
 * 
 *     def __iand__(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return self.intersection_update(other)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_38__iand__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("__iand__", 0);

  /* "cimpl/field.pyx":571
 * 
 *     def __iand__(Bitfield self, Bitfield other):
 *         return self.intersection_update(other)             # <<<<<<<<<<<<<<
 * 
 *     cpdef update(self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->intersection_update(__pyx_v_self, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __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("bitfield.Bitfield.__iand__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":573
 *         return self.intersection_update(other)
 * 
 *     cpdef update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Add all integers in 'other' to this bitfield"""
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_41update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  usize_t __pyx_v_current_page;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_the_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  usize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("update", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_41update)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":577
 *         cdef usize_t current_page
 *         cdef IdsPage the_page
 *         self._ensure_page_exists(len(other.pages))             # <<<<<<<<<<<<<<
 *         for current_page in range(len(other.pages)):
 *             the_page = self.pages[current_page]
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->_ensure_page_exists(__pyx_v_self, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":578
 *         cdef IdsPage the_page
 *         self._ensure_page_exists(len(other.pages))
 *         for current_page in range(len(other.pages)):             # <<<<<<<<<<<<<<
 *             the_page = self.pages[current_page]
 *             the_page.update(other.pages[current_page])
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_current_page = __pyx_t_5;

    /* "cimpl/field.pyx":579
 *         self._ensure_page_exists(len(other.pages))
 *         for current_page in range(len(other.pages)):
 *             the_page = self.pages[current_page]             # <<<<<<<<<<<<<<
 *             the_page.update(other.pages[current_page])
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_the_page));
    __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":580
 *         for current_page in range(len(other.pages)):
 *             the_page = self.pages[current_page]
 *             the_page.update(other.pages[current_page])             # <<<<<<<<<<<<<<
 * 
 *     cpdef difference_update(self, Bitfield other):
 */
    if (unlikely(((PyObject *)__pyx_v_other->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_other->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->update(__pyx_v_the_page, ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_41update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_40update[] = "Add all integers in 'other' to this bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_41update(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_40update(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":573
 *         return self.intersection_update(other)
 * 
 *     cpdef update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Add all integers in 'other' to this bitfield"""
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_40update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("update", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->update(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __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("bitfield.Bitfield.update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":582
 *             the_page.update(other.pages[current_page])
 * 
 *     cpdef difference_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Remove all integers in 'other' from this bitfield"""
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_43difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  usize_t __pyx_v_current_page;
  usize_t __pyx_v_affected_pages;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_the_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  usize_t __pyx_t_7;
  usize_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("difference_update", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__difference_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_43difference_update)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":585
 *         """Remove all integers in 'other' from this bitfield"""
 *         cdef usize_t current_page
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))             # <<<<<<<<<<<<<<
 *         cdef IdsPage the_page
 *         for current_page in range(affected_pages):
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((__pyx_t_4 < __pyx_t_5)) {
    __pyx_t_6 = __pyx_t_4;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  __pyx_v_affected_pages = __pyx_t_6;

  /* "cimpl/field.pyx":587
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))
 *         cdef IdsPage the_page
 *         for current_page in range(affected_pages):             # <<<<<<<<<<<<<<
 *             the_page = self.pages[current_page]
 *             the_page.difference_update(other.pages[current_page])
 */
  __pyx_t_7 = __pyx_v_affected_pages;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_current_page = __pyx_t_8;

    /* "cimpl/field.pyx":588
 *         cdef IdsPage the_page
 *         for current_page in range(affected_pages):
 *             the_page = self.pages[current_page]             # <<<<<<<<<<<<<<
 *             the_page.difference_update(other.pages[current_page])
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_the_page));
    __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":589
 *         for current_page in range(affected_pages):
 *             the_page = self.pages[current_page]
 *             the_page.difference_update(other.pages[current_page])             # <<<<<<<<<<<<<<
 * 
 *     cpdef symmetric_difference_update(self, Bitfield other):
 */
    if (unlikely(((PyObject *)__pyx_v_other->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_other->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->difference_update(__pyx_v_the_page, ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.difference_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_43difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_42difference_update[] = "Remove all integers in 'other' from this bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_43difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("difference_update (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_42difference_update(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":582
 *             the_page.update(other.pages[current_page])
 * 
 *     cpdef difference_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Remove all integers in 'other' from this bitfield"""
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_42difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("difference_update", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->difference_update(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __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("bitfield.Bitfield.difference_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":591
 *             the_page.difference_update(other.pages[current_page])
 * 
 *     cpdef symmetric_difference_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Update this bitfield to only contain items present in self or other, but not both    """
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_45symmetric_difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_symmetric_difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  usize_t __pyx_v_current_page;
  CYTHON_UNUSED usize_t __pyx_v_other_pages;
  usize_t __pyx_v_affected_pages;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_the_page = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  usize_t __pyx_t_8;
  usize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("symmetric_difference_update", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_45symmetric_difference_update)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":594
 *         """Update this bitfield to only contain items present in self or other, but not both    """
 *         cdef usize_t current_page
 *         cdef usize_t other_pages = 0             # <<<<<<<<<<<<<<
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))
 *         cdef IdsPage the_page
 */
  __pyx_v_other_pages = 0;

  /* "cimpl/field.pyx":595
 *         cdef usize_t current_page
 *         cdef usize_t other_pages = 0
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))             # <<<<<<<<<<<<<<
 *         cdef IdsPage the_page
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((__pyx_t_4 < __pyx_t_5)) {
    __pyx_t_6 = __pyx_t_4;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  __pyx_v_affected_pages = __pyx_t_6;

  /* "cimpl/field.pyx":598
 *         cdef IdsPage the_page
 * 
 *         if affected_pages < len(other.pages):             # <<<<<<<<<<<<<<
 *             other_pages = len(other.pages) - affected_pages
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (__pyx_v_affected_pages < __pyx_t_6);
  if (__pyx_t_7) {

    /* "cimpl/field.pyx":599
 * 
 *         if affected_pages < len(other.pages):
 *             other_pages = len(other.pages) - affected_pages             # <<<<<<<<<<<<<<
 * 
 *         for current_page in range(affected_pages):
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
    __Pyx_INCREF(__pyx_t_1);
    if (unlikely(__pyx_t_1 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_other_pages = (__pyx_t_6 - __pyx_v_affected_pages);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":601
 *             other_pages = len(other.pages) - affected_pages
 * 
 *         for current_page in range(affected_pages):             # <<<<<<<<<<<<<<
 *             the_page = self.pages[current_page]
 *             the_page.symmetric_difference_update(other.pages[current_page])
 */
  __pyx_t_8 = __pyx_v_affected_pages;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_current_page = __pyx_t_9;

    /* "cimpl/field.pyx":602
 * 
 *         for current_page in range(affected_pages):
 *             the_page = self.pages[current_page]             # <<<<<<<<<<<<<<
 *             the_page.symmetric_difference_update(other.pages[current_page])
 *         if affected_pages < len(other.pages):
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_the_page));
    __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":603
 *         for current_page in range(affected_pages):
 *             the_page = self.pages[current_page]
 *             the_page.symmetric_difference_update(other.pages[current_page])             # <<<<<<<<<<<<<<
 *         if affected_pages < len(other.pages):
 *             for current_page in range(affected_pages, len(other.pages)):
 */
    if (unlikely(((PyObject *)__pyx_v_other->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_other->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->symmetric_difference_update(__pyx_v_the_page, ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  /* "cimpl/field.pyx":604
 *             the_page = self.pages[current_page]
 *             the_page.symmetric_difference_update(other.pages[current_page])
 *         if affected_pages < len(other.pages):             # <<<<<<<<<<<<<<
 *             for current_page in range(affected_pages, len(other.pages)):
 *                 the_page = other.pages[current_page]
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = (__pyx_v_affected_pages < __pyx_t_6);
  if (__pyx_t_7) {

    /* "cimpl/field.pyx":605
 *             the_page.symmetric_difference_update(other.pages[current_page])
 *         if affected_pages < len(other.pages):
 *             for current_page in range(affected_pages, len(other.pages)):             # <<<<<<<<<<<<<<
 *                 the_page = other.pages[current_page]
 *                 self.pages.append(the_page.clone())
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_other->pages);
    __Pyx_INCREF(__pyx_t_3);
    if (unlikely(__pyx_t_3 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (__pyx_t_8 = __pyx_v_affected_pages; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
      __pyx_v_current_page = __pyx_t_8;

      /* "cimpl/field.pyx":606
 *         if affected_pages < len(other.pages):
 *             for current_page in range(affected_pages, len(other.pages)):
 *                 the_page = other.pages[current_page]             # <<<<<<<<<<<<<<
 *                 self.pages.append(the_page.clone())
 * 
 */
      if (unlikely(((PyObject *)__pyx_v_other->pages) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_other->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF(((PyObject *)__pyx_v_the_page));
      __pyx_v_the_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "cimpl/field.pyx":607
 *             for current_page in range(affected_pages, len(other.pages)):
 *                 the_page = other.pages[current_page]
 *                 self.pages.append(the_page.clone())             # <<<<<<<<<<<<<<
 * 
 *     cpdef symmetric_difference(self, Bitfield other):
 */
      if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_the_page->__pyx_vtab)->clone(__pyx_v_the_page)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_self->pages, __pyx_t_3); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    goto __pyx_L6;
  }
  __pyx_L6:;

  __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_AddTraceback("bitfield.Bitfield.symmetric_difference_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_the_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_45symmetric_difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_44symmetric_difference_update[] = "Update this bitfield to only contain items present in self or other, but not both    ";
static PyObject *__pyx_pw_8bitfield_8Bitfield_45symmetric_difference_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("symmetric_difference_update (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_44symmetric_difference_update(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":591
 *             the_page.difference_update(other.pages[current_page])
 * 
 *     cpdef symmetric_difference_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Update this bitfield to only contain items present in self or other, but not both    """
 *         cdef usize_t current_page
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_44symmetric_difference_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("symmetric_difference_update", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->symmetric_difference_update(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __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("bitfield.Bitfield.symmetric_difference_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":609
 *                 self.pages.append(the_page.clone())
 * 
 *     cpdef symmetric_difference(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         cdef Bitfield new = self.clone()
 *         new.symmetric_difference_update(other)
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_47symmetric_difference(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_symmetric_difference(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("symmetric_difference", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_47symmetric_difference)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":610
 * 
 *     cpdef symmetric_difference(self, Bitfield other):
 *         cdef Bitfield new = self.clone()             # <<<<<<<<<<<<<<
 *         new.symmetric_difference_update(other)
 *         return new
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->clone(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_Bitfield))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":611
 *     cpdef symmetric_difference(self, Bitfield other):
 *         cdef Bitfield new = self.clone()
 *         new.symmetric_difference_update(other)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->symmetric_difference_update(__pyx_v_new, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":612
 *         cdef Bitfield new = self.clone()
 *         new.symmetric_difference_update(other)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     cpdef intersection_update(self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  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_AddTraceback("bitfield.Bitfield.symmetric_difference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_47symmetric_difference(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_47symmetric_difference(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("symmetric_difference (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_46symmetric_difference(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":609
 *                 self.pages.append(the_page.clone())
 * 
 *     cpdef symmetric_difference(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         cdef Bitfield new = self.clone()
 *         new.symmetric_difference_update(other)
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_46symmetric_difference(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("symmetric_difference", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->symmetric_difference(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __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("bitfield.Bitfield.symmetric_difference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":614
 *         return new
 * 
 *     cpdef intersection_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Update the bitfield, keeping only integers found in it and 'other'."""
 *         cdef IdsPage page
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_49intersection_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_intersection_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  usize_t __pyx_v_current_page;
  usize_t __pyx_v_affected_pages;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  usize_t __pyx_t_7;
  usize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("intersection_update", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__intersection_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_49intersection_update)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":618
 *         cdef IdsPage page
 *         cdef usize_t current_page
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))             # <<<<<<<<<<<<<<
 *         for current_page in range(affected_pages):
 *             page = self.pages[current_page]
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((__pyx_t_4 < __pyx_t_5)) {
    __pyx_t_6 = __pyx_t_4;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  __pyx_v_affected_pages = __pyx_t_6;

  /* "cimpl/field.pyx":619
 *         cdef usize_t current_page
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))
 *         for current_page in range(affected_pages):             # <<<<<<<<<<<<<<
 *             page = self.pages[current_page]
 *             page.intersection_update(other.pages[current_page])
 */
  __pyx_t_7 = __pyx_v_affected_pages;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_current_page = __pyx_t_8;

    /* "cimpl/field.pyx":620
 *         cdef usize_t affected_pages = min(len(self.pages), len(other.pages))
 *         for current_page in range(affected_pages):
 *             page = self.pages[current_page]             # <<<<<<<<<<<<<<
 *             page.intersection_update(other.pages[current_page])
 *         if len(self.pages) > affected_pages:
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":621
 *         for current_page in range(affected_pages):
 *             page = self.pages[current_page]
 *             page.intersection_update(other.pages[current_page])             # <<<<<<<<<<<<<<
 *         if len(self.pages) > affected_pages:
 *             for current_page in range(affected_pages, len(self.pages)):
 */
    if (unlikely(((PyObject *)__pyx_v_other->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_other->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->intersection_update(__pyx_v_page, ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":622
 *             page = self.pages[current_page]
 *             page.intersection_update(other.pages[current_page])
 *         if len(self.pages) > affected_pages:             # <<<<<<<<<<<<<<
 *             for current_page in range(affected_pages, len(self.pages)):
 *                 page = self.pages[current_page]
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = (__pyx_t_6 > __pyx_v_affected_pages);
  if (__pyx_t_9) {

    /* "cimpl/field.pyx":623
 *             page.intersection_update(other.pages[current_page])
 *         if len(self.pages) > affected_pages:
 *             for current_page in range(affected_pages, len(self.pages)):             # <<<<<<<<<<<<<<
 *                 page = self.pages[current_page]
 *                 page.set_empty()
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->pages);
    __Pyx_INCREF(__pyx_t_1);
    if (unlikely(__pyx_t_1 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (__pyx_t_7 = __pyx_v_affected_pages; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_current_page = __pyx_t_7;

      /* "cimpl/field.pyx":624
 *         if len(self.pages) > affected_pages:
 *             for current_page in range(affected_pages, len(self.pages)):
 *                 page = self.pages[current_page]             # <<<<<<<<<<<<<<
 *                 page.set_empty()
 * 
 */
      if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_current_page, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF(((PyObject *)__pyx_v_page));
      __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "cimpl/field.pyx":625
 *             for current_page in range(affected_pages, len(self.pages)):
 *                 page = self.pages[current_page]
 *                 page.set_empty()             # <<<<<<<<<<<<<<
 * 
 *     cpdef intersection(Bitfield self, Bitfield other):
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->set_empty(__pyx_v_page);
    }
    goto __pyx_L5;
  }
  __pyx_L5:;

  __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_AddTraceback("bitfield.Bitfield.intersection_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_49intersection_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_48intersection_update[] = "Update the bitfield, keeping only integers found in it and 'other'.";
static PyObject *__pyx_pw_8bitfield_8Bitfield_49intersection_update(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("intersection_update (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_48intersection_update(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":614
 *         return new
 * 
 *     cpdef intersection_update(self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Update the bitfield, keeping only integers found in it and 'other'."""
 *         cdef IdsPage page
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_48intersection_update(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("intersection_update", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->intersection_update(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __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("bitfield.Bitfield.intersection_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":627
 *                 page.set_empty()
 * 
 *     cpdef intersection(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Return a new bitfield with integers common to both this field, and 'other'."""
 *         cdef Bitfield new = self.clone()
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_51intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_intersection(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("intersection", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__intersection); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_51intersection)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":629
 *     cpdef intersection(Bitfield self, Bitfield other):
 *         """Return a new bitfield with integers common to both this field, and 'other'."""
 *         cdef Bitfield new = self.clone()             # <<<<<<<<<<<<<<
 *         new.intersection_update(other)
 *         return new
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->clone(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_Bitfield))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":630
 *         """Return a new bitfield with integers common to both this field, and 'other'."""
 *         cdef Bitfield new = self.clone()
 *         new.intersection_update(other)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->intersection_update(__pyx_v_new, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":631
 *         cdef Bitfield new = self.clone()
 *         new.intersection_update(other)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     cpdef isdisjoint(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  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_AddTraceback("bitfield.Bitfield.intersection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_51intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_50intersection[] = "Return a new bitfield with integers common to both this field, and 'other'.";
static PyObject *__pyx_pw_8bitfield_8Bitfield_51intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("intersection (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_50intersection(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":627
 *                 page.set_empty()
 * 
 *     cpdef intersection(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Return a new bitfield with integers common to both this field, and 'other'."""
 *         cdef Bitfield new = self.clone()
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_50intersection(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("intersection", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->intersection(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __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("bitfield.Bitfield.intersection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":633
 *         return new
 * 
 *     cpdef isdisjoint(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Return True if the bitfield has no integers in common with other.
 *         Bitfields are disjoint if and only if their intersection is the empty set."""
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_53isdisjoint(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_isdisjoint(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("isdisjoint", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__isdisjoint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_53isdisjoint)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":636
 *         """Return True if the bitfield has no integers in common with other.
 *         Bitfields are disjoint if and only if their intersection is the empty set."""
 *         return len(self.intersection(other)) == 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef issubset(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->intersection(__pyx_v_self, __pyx_v_other, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_t_4 == 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __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_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.isdisjoint", __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_8bitfield_8Bitfield_53isdisjoint(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_52isdisjoint[] = "Return True if the bitfield has no integers in common with other. \n        Bitfields are disjoint if and only if their intersection is the empty set.";
static PyObject *__pyx_pw_8bitfield_8Bitfield_53isdisjoint(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("isdisjoint (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_52isdisjoint(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":633
 *         return new
 * 
 *     cpdef isdisjoint(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         """Return True if the bitfield has no integers in common with other.
 *         Bitfields are disjoint if and only if their intersection is the empty set."""
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_52isdisjoint(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("isdisjoint", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->isdisjoint(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __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("bitfield.Bitfield.isdisjoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":638
 *         return len(self.intersection(other)) == 0
 * 
 *     cpdef issubset(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return len(self - other) == 0
 * 
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_55issubset(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_issubset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("issubset", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__issubset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_55issubset)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":639
 * 
 *     cpdef issubset(Bitfield self, Bitfield other):
 *         return len(self - other) == 0             # <<<<<<<<<<<<<<
 * 
 *     cpdef issuperset(Bitfield self, Bitfield other):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyNumber_Subtract(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_t_4 == 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __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_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.issubset", __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_8bitfield_8Bitfield_55issubset(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_55issubset(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("issubset (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_54issubset(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":638
 *         return len(self.intersection(other)) == 0
 * 
 *     cpdef issubset(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return len(self - other) == 0
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_54issubset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("issubset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->issubset(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __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("bitfield.Bitfield.issubset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":641
 *         return len(self - other) == 0
 * 
 *     cpdef issuperset(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return other.issubset(self)
 * 
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_57issuperset(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_issuperset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("issuperset", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__issuperset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_57issuperset)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __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;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":642
 * 
 *     cpdef issuperset(Bitfield self, Bitfield other):
 *         return other.issubset(self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef copy(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_other->__pyx_vtab)->issubset(__pyx_v_other, __pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __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_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.issuperset", __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_8bitfield_8Bitfield_57issuperset(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_57issuperset(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("issuperset (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_8bitfield_Bitfield, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_56issuperset(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_other));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":641
 *         return len(self - other) == 0
 * 
 *     cpdef issuperset(Bitfield self, Bitfield other):             # <<<<<<<<<<<<<<
 *         return other.issubset(self)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_56issuperset(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, struct __pyx_obj_8bitfield_Bitfield *__pyx_v_other) {
  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("issuperset", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->issuperset(__pyx_v_self, __pyx_v_other, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __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("bitfield.Bitfield.issuperset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":644
 *         return other.issubset(self)
 * 
 *     cpdef copy(self):             # <<<<<<<<<<<<<<
 *         """Create a copy of the bitfield"""
 *         return self.clone()
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_59copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_copy(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, int __pyx_skip_dispatch) {
  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("copy", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_59copy)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":646
 *     cpdef copy(self):
 *         """Create a copy of the bitfield"""
 *         return self.clone()             # <<<<<<<<<<<<<<
 * 
 *     cpdef clone(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->clone(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __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_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bitfield.Bitfield.copy", __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_8bitfield_8Bitfield_59copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_58copy[] = "Create a copy of the bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_59copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_58copy(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":644
 *         return other.issubset(self)
 * 
 *     cpdef copy(self):             # <<<<<<<<<<<<<<
 *         """Create a copy of the bitfield"""
 *         return self.clone()
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_58copy(struct __pyx_obj_8bitfield_Bitfield *__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("copy", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->copy(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __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("bitfield.Bitfield.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":648
 *         return self.clone()
 * 
 *     cpdef clone(self):             # <<<<<<<<<<<<<<
 *         """Create a copy of the bitfield"""
 *         new = Bitfield()
 */

static PyObject *__pyx_pw_8bitfield_8Bitfield_61clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_8bitfield_8Bitfield_clone(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = NULL;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("clone", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__clone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_8bitfield_8Bitfield_61clone)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cimpl/field.pyx":650
 *     cpdef clone(self):
 *         """Create a copy of the bitfield"""
 *         new = Bitfield()             # <<<<<<<<<<<<<<
 *         cdef IdsPage page
 *         for page in self.pages:
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_Bitfield)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":652
 *         new = Bitfield()
 *         cdef IdsPage page
 *         for page in self.pages:             # <<<<<<<<<<<<<<
 *             new.pages.append(page.clone())
 *         return new
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = ((PyObject *)__pyx_v_self->pages); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cimpl/field.pyx":653
 *         cdef IdsPage page
 *         for page in self.pages:
 *             new.pages.append(page.clone())             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_new->pages) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->clone(__pyx_v_page)); 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);
    __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_new->pages, __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":654
 *         for page in self.pages:
 *             new.pages.append(page.clone())
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __getbuffer__(self, Py_buffer *view, int flags):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  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("bitfield.Bitfield.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_61clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_60clone[] = "Create a copy of the bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_61clone(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clone (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_60clone(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":648
 *         return self.clone()
 * 
 *     cpdef clone(self):             # <<<<<<<<<<<<<<
 *         """Create a copy of the bitfield"""
 *         new = Bitfield()
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_60clone(struct __pyx_obj_8bitfield_Bitfield *__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("clone", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->clone(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __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("bitfield.Bitfield.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_8bitfield_8Bitfield_63__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_view, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_8bitfield_8Bitfield_63__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_view, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_62__getbuffer__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((Py_buffer *)__pyx_v_view), ((int)__pyx_v_flags));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":656
 *         return new
 * 
 *     def __getbuffer__(self, Py_buffer *view, int flags):             # <<<<<<<<<<<<<<
 *         cdef IdsPage page
 *         cdef size_t partial_page_count = 0
 */

static int __pyx_pf_8bitfield_8Bitfield_62__getbuffer__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, Py_buffer *__pyx_v_view, int __pyx_v_flags) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  size_t __pyx_v_partial_page_count;
  size_t __pyx_v_buffer_len;
  char *__pyx_v_pointer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_view != NULL) {
    __pyx_v_view->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_view->obj);
  }

  /* "cimpl/field.pyx":658
 *     def __getbuffer__(self, Py_buffer *view, int flags):
 *         cdef IdsPage page
 *         cdef size_t partial_page_count = 0             # <<<<<<<<<<<<<<
 *         cdef size_t buffer_len
 *         cdef char * pointer
 */
  __pyx_v_partial_page_count = 0;

  /* "cimpl/field.pyx":662
 *         cdef char * pointer
 * 
 *         if flags & pybuf.PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
 *             raise ValueError("bitfields do not provide writable buffers")
 * 
 */
  __pyx_t_1 = (__pyx_v_flags & PyBUF_WRITABLE);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":663
 * 
 *         if flags & pybuf.PyBUF_WRITABLE:
 *             raise ValueError("bitfields do not provide writable buffers")             # <<<<<<<<<<<<<<
 * 
 *         if flags & pybuf.PyBUF_FORMAT:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __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 = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":665
 *             raise ValueError("bitfields do not provide writable buffers")
 * 
 *         if flags & pybuf.PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             view.format = "B"
 * 
 */
  __pyx_t_1 = (__pyx_v_flags & PyBUF_FORMAT);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":666
 * 
 *         if flags & pybuf.PyBUF_FORMAT:
 *             view.format = "B"             # <<<<<<<<<<<<<<
 * 
 *         view.readonly = True
 */
    __pyx_v_view->format = __pyx_k__B;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":668
 *             view.format = "B"
 * 
 *         view.readonly = True             # <<<<<<<<<<<<<<
 *         for page in self.pages:
 *             if page.data:
 */
  __pyx_v_view->readonly = 1;

  /* "cimpl/field.pyx":669
 * 
 *         view.readonly = True
 *         for page in self.pages:             # <<<<<<<<<<<<<<
 *             if page.data:
 *                 partial_page_count += 1
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = ((PyObject *)__pyx_v_self->pages); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cimpl/field.pyx":670
 *         view.readonly = True
 *         for page in self.pages:
 *             if page.data:             # <<<<<<<<<<<<<<
 *                 partial_page_count += 1
 * 
 */
    __pyx_t_5 = (__pyx_v_page->data != 0);
    if (__pyx_t_5) {

      /* "cimpl/field.pyx":671
 *         for page in self.pages:
 *             if page.data:
 *                 partial_page_count += 1             # <<<<<<<<<<<<<<
 * 
 *         buffer_len = len(self.pages) + (PAGE_BYTES * partial_page_count)
 */
      __pyx_v_partial_page_count = (__pyx_v_partial_page_count + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":673
 *                 partial_page_count += 1
 * 
 *         buffer_len = len(self.pages) + (PAGE_BYTES * partial_page_count)             # <<<<<<<<<<<<<<
 *         view.len = buffer_len
 *         view.buf = malloc(buffer_len)
 */
  __pyx_t_2 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_buffer_len = (__pyx_t_3 + (PAGE_BYTES * __pyx_v_partial_page_count));

  /* "cimpl/field.pyx":674
 * 
 *         buffer_len = len(self.pages) + (PAGE_BYTES * partial_page_count)
 *         view.len = buffer_len             # <<<<<<<<<<<<<<
 *         view.buf = malloc(buffer_len)
 *         view.itemsize = 1
 */
  __pyx_v_view->len = __pyx_v_buffer_len;

  /* "cimpl/field.pyx":675
 *         buffer_len = len(self.pages) + (PAGE_BYTES * partial_page_count)
 *         view.len = buffer_len
 *         view.buf = malloc(buffer_len)             # <<<<<<<<<<<<<<
 *         view.itemsize = 1
 *         view.suboffsets = NULL
 */
  __pyx_v_view->buf = malloc(__pyx_v_buffer_len);

  /* "cimpl/field.pyx":676
 *         view.len = buffer_len
 *         view.buf = malloc(buffer_len)
 *         view.itemsize = 1             # <<<<<<<<<<<<<<
 *         view.suboffsets = NULL
 *         pointer = <char *> view.buf
 */
  __pyx_v_view->itemsize = 1;

  /* "cimpl/field.pyx":677
 *         view.buf = malloc(buffer_len)
 *         view.itemsize = 1
 *         view.suboffsets = NULL             # <<<<<<<<<<<<<<
 *         pointer = <char *> view.buf
 *         for page in self.pages:
 */
  __pyx_v_view->suboffsets = NULL;

  /* "cimpl/field.pyx":678
 *         view.itemsize = 1
 *         view.suboffsets = NULL
 *         pointer = <char *> view.buf             # <<<<<<<<<<<<<<
 *         for page in self.pages:
 *             pointer[0] = <unsigned char>page.page_state
 */
  __pyx_v_pointer = ((char *)__pyx_v_view->buf);

  /* "cimpl/field.pyx":679
 *         view.suboffsets = NULL
 *         pointer = <char *> view.buf
 *         for page in self.pages:             # <<<<<<<<<<<<<<
 *             pointer[0] = <unsigned char>page.page_state
 *             pointer += 1
 */
  if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = ((PyObject *)__pyx_v_self->pages); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cimpl/field.pyx":680
 *         pointer = <char *> view.buf
 *         for page in self.pages:
 *             pointer[0] = <unsigned char>page.page_state             # <<<<<<<<<<<<<<
 *             pointer += 1
 *             if page.data != NULL:
 */
    (__pyx_v_pointer[0]) = ((unsigned char)__pyx_v_page->page_state);

    /* "cimpl/field.pyx":681
 *         for page in self.pages:
 *             pointer[0] = <unsigned char>page.page_state
 *             pointer += 1             # <<<<<<<<<<<<<<
 *             if page.data != NULL:
 *                 memcpy(<void *>pointer, <void*>page.data, PAGE_BYTES)
 */
    __pyx_v_pointer = (__pyx_v_pointer + 1);

    /* "cimpl/field.pyx":682
 *             pointer[0] = <unsigned char>page.page_state
 *             pointer += 1
 *             if page.data != NULL:             # <<<<<<<<<<<<<<
 *                 memcpy(<void *>pointer, <void*>page.data, PAGE_BYTES)
 *                 pointer += PAGE_BYTES
 */
    __pyx_t_5 = (__pyx_v_page->data != NULL);
    if (__pyx_t_5) {

      /* "cimpl/field.pyx":683
 *             pointer += 1
 *             if page.data != NULL:
 *                 memcpy(<void *>pointer, <void*>page.data, PAGE_BYTES)             # <<<<<<<<<<<<<<
 *                 pointer += PAGE_BYTES
 * 
 */
      memcpy(((void *)__pyx_v_pointer), ((void *)__pyx_v_page->data), PAGE_BYTES);

      /* "cimpl/field.pyx":684
 *             if page.data != NULL:
 *                 memcpy(<void *>pointer, <void*>page.data, PAGE_BYTES)
 *                 pointer += PAGE_BYTES             # <<<<<<<<<<<<<<
 * 
 *         if flags & pybuf.PyBUF_ND or flags & pybuf.PyBUF_STRIDES:
 */
      __pyx_v_pointer = (__pyx_v_pointer + PAGE_BYTES);
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cimpl/field.pyx":686
 *                 pointer += PAGE_BYTES
 * 
 *         if flags & pybuf.PyBUF_ND or flags & pybuf.PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             view.ndim = 0
 *             view.shape = NULL
 */
  __pyx_t_1 = (__pyx_v_flags & PyBUF_ND);
  if (!__pyx_t_1) {
    __pyx_t_6 = (__pyx_v_flags & PyBUF_STRIDES);
    __pyx_t_5 = __pyx_t_6;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":687
 * 
 *         if flags & pybuf.PyBUF_ND or flags & pybuf.PyBUF_STRIDES:
 *             view.ndim = 0             # <<<<<<<<<<<<<<
 *             view.shape = NULL
 *             view.strides = NULL
 */
    __pyx_v_view->ndim = 0;

    /* "cimpl/field.pyx":688
 *         if flags & pybuf.PyBUF_ND or flags & pybuf.PyBUF_STRIDES:
 *             view.ndim = 0
 *             view.shape = NULL             # <<<<<<<<<<<<<<
 *             view.strides = NULL
 * 
 */
    __pyx_v_view->shape = NULL;

    /* "cimpl/field.pyx":689
 *             view.ndim = 0
 *             view.shape = NULL
 *             view.strides = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __releasebuffer__(self, Py_buffer *view):
 */
    __pyx_v_view->strides = NULL;
    goto __pyx_L11;
  }
  __pyx_L11:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bitfield.Bitfield.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_view != NULL && __pyx_v_view->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_view->obj);
    __Pyx_DECREF(__pyx_v_view->obj); __pyx_v_view->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_view != NULL && __pyx_v_view->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_view->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_8bitfield_8Bitfield_65__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_view); /*proto*/
static CYTHON_UNUSED void __pyx_pw_8bitfield_8Bitfield_65__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_view) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_8bitfield_8Bitfield_64__releasebuffer__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), ((Py_buffer *)__pyx_v_view));
  __Pyx_RefNannyFinishContext();
}

/* "cimpl/field.pyx":691
 *             view.strides = NULL
 * 
 *     def __releasebuffer__(self, Py_buffer *view):             # <<<<<<<<<<<<<<
 *         if view.buf == NULL:
 *             return
 */

static void __pyx_pf_8bitfield_8Bitfield_64__releasebuffer__(CYTHON_UNUSED struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, Py_buffer *__pyx_v_view) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "cimpl/field.pyx":692
 * 
 *     def __releasebuffer__(self, Py_buffer *view):
 *         if view.buf == NULL:             # <<<<<<<<<<<<<<
 *             return
 *         free(view.buf)
 */
  __pyx_t_1 = (__pyx_v_view->buf == NULL);
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":693
 *     def __releasebuffer__(self, Py_buffer *view):
 *         if view.buf == NULL:
 *             return             # <<<<<<<<<<<<<<
 *         free(view.buf)
 * 
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":694
 *         if view.buf == NULL:
 *             return
 *         free(view.buf)             # <<<<<<<<<<<<<<
 * 
 *     def pickle(self, compress=True):
 */
  free(__pyx_v_view->buf);

  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_67pickle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_66pickle[] = "Return a string representation of the bitfield";
static PyObject *__pyx_pw_8bitfield_8Bitfield_67pickle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_compress = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pickle (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__compress,0};
    PyObject* values[1] = {0};
    values[0] = __pyx_k_11;
    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 (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__compress);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pickle") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_compress = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pickle", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bitfield.Bitfield.pickle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_66pickle(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self), __pyx_v_compress);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":696
 *         free(view.buf)
 * 
 *     def pickle(self, compress=True):             # <<<<<<<<<<<<<<
 *         """Return a string representation of the bitfield"""
 *         cdef bytes marker = PICKLE_MARKER
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_66pickle(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_compress) {
  PyObject *__pyx_v_marker = 0;
  PyObject *__pyx_v_base = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("pickle", 0);

  /* "cimpl/field.pyx":698
 *     def pickle(self, compress=True):
 *         """Return a string representation of the bitfield"""
 *         cdef bytes marker = PICKLE_MARKER             # <<<<<<<<<<<<<<
 *         cdef bytes base = memoryview(self).tobytes()
 *         if compress:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER));
  __pyx_v_marker = __pyx_v_8bitfield_PICKLE_MARKER;

  /* "cimpl/field.pyx":699
 *         """Return a string representation of the bitfield"""
 *         cdef bytes marker = PICKLE_MARKER
 *         cdef bytes base = memoryview(self).tobytes()             # <<<<<<<<<<<<<<
 *         if compress:
 *             base = zlib.compress(base)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_memoryview, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__tobytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __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 = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_base = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cimpl/field.pyx":700
 *         cdef bytes marker = PICKLE_MARKER
 *         cdef bytes base = memoryview(self).tobytes()
 *         if compress:             # <<<<<<<<<<<<<<
 *             base = zlib.compress(base)
 *             marker = PICKLE_MARKER_zlib
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_compress); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "cimpl/field.pyx":701
 *         cdef bytes base = memoryview(self).tobytes()
 *         if compress:
 *             base = zlib.compress(base)             # <<<<<<<<<<<<<<
 *             marker = PICKLE_MARKER_zlib
 *         return marker + base
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__zlib); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__compress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_base));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_base));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_base));
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __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_2)); __pyx_t_2 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_base));
    __pyx_v_base = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "cimpl/field.pyx":702
 *         if compress:
 *             base = zlib.compress(base)
 *             marker = PICKLE_MARKER_zlib             # <<<<<<<<<<<<<<
 *         return marker + base
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER_zlib));
    __Pyx_DECREF(((PyObject *)__pyx_v_marker));
    __pyx_v_marker = __pyx_v_8bitfield_PICKLE_MARKER_zlib;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":703
 *             base = zlib.compress(base)
 *             marker = PICKLE_MARKER_zlib
 *         return marker + base             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_v_marker), ((PyObject *)__pyx_v_base)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_r = ((PyObject *)__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_4);
  __Pyx_AddTraceback("bitfield.Bitfield.pickle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_marker);
  __Pyx_XDECREF(__pyx_v_base);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_69unpickle(PyObject *__pyx_v_cls, PyObject *__pyx_v_data); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_68unpickle[] = "Read a bitfield object from a string created by Bitfield.piclke";
static PyObject *__pyx_pw_8bitfield_8Bitfield_69unpickle(PyObject *__pyx_v_cls, PyObject *__pyx_v_data) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpickle (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_68unpickle(((PyObject*)__pyx_v_cls), ((PyObject*)__pyx_v_data));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":706
 * 
 *     @classmethod
 *     def unpickle(cls, bytes data):             # <<<<<<<<<<<<<<
 *         """Read a bitfield object from a string created by Bitfield.piclke"""
 *         cdef Bitfield new = Bitfield()
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_68unpickle(CYTHON_UNUSED PyObject *__pyx_v_cls, PyObject *__pyx_v_data) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  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("unpickle", 0);

  /* "cimpl/field.pyx":708
 *     def unpickle(cls, bytes data):
 *         """Read a bitfield object from a string created by Bitfield.piclke"""
 *         cdef Bitfield new = Bitfield()             # <<<<<<<<<<<<<<
 *         new.load_from_bytes(data)
 *         return new
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_Bitfield)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":709
 *         """Read a bitfield object from a string created by Bitfield.piclke"""
 *         cdef Bitfield new = Bitfield()
 *         new.load_from_bytes(data)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->load_from_bytes(__pyx_v_new, __pyx_v_data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":710
 *         cdef Bitfield new = Bitfield()
 *         new.load_from_bytes(data)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.unpickle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_71__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_71__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_70__reduce__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":712
 *         return new
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (unpickle_bitfield, (self.pickle(), ))
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_70__reduce__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__reduce__", 0);

  /* "cimpl/field.pyx":713
 * 
 *     def __reduce__(self):
 *         return (unpickle_bitfield, (self.pickle(), ))             # <<<<<<<<<<<<<<
 * 
 *     cdef load(Bitfield self, data):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__unpickle_bitfield); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__pickle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __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 = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __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, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.Bitfield.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":715
 *         return (unpickle_bitfield, (self.pickle(), ))
 * 
 *     cdef load(Bitfield self, data):             # <<<<<<<<<<<<<<
 *         if isinstance(data, bytes):
 *             return self.load_from_bytes(data)
 */

static PyObject *__pyx_f_8bitfield_8Bitfield_load(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_data) {
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_low = NULL;
  PyObject *__pyx_v_high = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  usize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  usize_t __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load", 0);

  /* "cimpl/field.pyx":716
 * 
 *     cdef load(Bitfield self, data):
 *         if isinstance(data, bytes):             # <<<<<<<<<<<<<<
 *             return self.load_from_bytes(data)
 *         for item in data:
 */
  __pyx_t_1 = PyBytes_Check(__pyx_v_data); 
  if (__pyx_t_1) {

    /* "cimpl/field.pyx":717
 *     cdef load(Bitfield self, data):
 *         if isinstance(data, bytes):
 *             return self.load_from_bytes(data)             # <<<<<<<<<<<<<<
 *         for item in data:
 *             if isinstance(item, (int, long)):
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyBytes_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_data)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->load_from_bytes(__pyx_v_self, ((PyObject*)__pyx_v_data)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __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;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":718
 *         if isinstance(data, bytes):
 *             return self.load_from_bytes(data)
 *         for item in data:             # <<<<<<<<<<<<<<
 *             if isinstance(item, (int, long)):
 *                 self.add(item)
 */
  if (PyList_CheckExact(__pyx_v_data) || PyTuple_CheckExact(__pyx_v_data)) {
    __pyx_t_2 = __pyx_v_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF(__pyx_v_item);
    __pyx_v_item = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cimpl/field.pyx":719
 *             return self.load_from_bytes(data)
 *         for item in data:
 *             if isinstance(item, (int, long)):             # <<<<<<<<<<<<<<
 *                 self.add(item)
 *             else:
 */
    __Pyx_INCREF(__pyx_v_item);
    __pyx_t_5 = __pyx_v_item;
    __pyx_t_1 = PyInt_Check(__pyx_t_5); 
    if (!__pyx_t_1) {
      __pyx_t_6 = PyLong_Check(__pyx_t_5); 
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_1;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {

      /* "cimpl/field.pyx":720
 *         for item in data:
 *             if isinstance(item, (int, long)):
 *                 self.add(item)             # <<<<<<<<<<<<<<
 *             else:
 *                 low, high = item
 */
      __pyx_t_8 = __Pyx_PyInt_from_py_usize_t(__pyx_v_item); if (unlikely((__pyx_t_8 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->add(__pyx_v_self, __pyx_t_8, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "cimpl/field.pyx":722
 *                 self.add(item)
 *             else:
 *                 low, high = item             # <<<<<<<<<<<<<<
 *                 self.fill_range(low, high)
 * 
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_item))) || (PyList_CheckExact(__pyx_v_item))) {
        PyObject* sequence = __pyx_v_item;
        #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 = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_v_item); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_low);
      __pyx_v_low = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_high);
      __pyx_v_high = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "cimpl/field.pyx":723
 *             else:
 *                 low, high = item
 *                 self.fill_range(low, high)             # <<<<<<<<<<<<<<
 * 
 *     cdef load_from_bytes(self, bytes data):
 */
      __pyx_t_8 = __Pyx_PyInt_from_py_usize_t(__pyx_v_low); if (unlikely((__pyx_t_8 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __Pyx_PyInt_from_py_usize_t(__pyx_v_high); if (unlikely((__pyx_t_12 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->fill_range(__pyx_v_self, __pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __pyx_L6:;
  }
  __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_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("bitfield.Bitfield.load", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_low);
  __Pyx_XDECREF(__pyx_v_high);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":725
 *                 self.fill_range(low, high)
 * 
 *     cdef load_from_bytes(self, bytes data):             # <<<<<<<<<<<<<<
 *         cdef usize_t marker_len = len(PICKLE_MARKER)
 *         cdef bytes marker = data[:marker_len]
 */

static PyObject *__pyx_f_8bitfield_8Bitfield_load_from_bytes(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, PyObject *__pyx_v_data) {
  usize_t __pyx_v_marker_len;
  PyObject *__pyx_v_marker = 0;
  usize_t __pyx_v_length;
  char *__pyx_v_buf;
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  usize_t __pyx_v_position;
  char __pyx_v_page_state;
  char *__pyx_v_write_position;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  char *__pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load_from_bytes", 0);
  __Pyx_INCREF(__pyx_v_data);

  /* "cimpl/field.pyx":726
 * 
 *     cdef load_from_bytes(self, bytes data):
 *         cdef usize_t marker_len = len(PICKLE_MARKER)             # <<<<<<<<<<<<<<
 *         cdef bytes marker = data[:marker_len]
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_marker_len = __pyx_t_2;

  /* "cimpl/field.pyx":727
 *     cdef load_from_bytes(self, bytes data):
 *         cdef usize_t marker_len = len(PICKLE_MARKER)
 *         cdef bytes marker = data[:marker_len]             # <<<<<<<<<<<<<<
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:
 *             raise ValueError("Could not unpickle data")
 */
  if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_data), 0, __pyx_v_marker_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_marker = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":728
 *         cdef usize_t marker_len = len(PICKLE_MARKER)
 *         cdef bytes marker = data[:marker_len]
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:             # <<<<<<<<<<<<<<
 *             raise ValueError("Could not unpickle data")
 *         if marker == PICKLE_MARKER_zlib:
 */
  __pyx_t_3 = (__Pyx_PyBytes_Equals(((PyObject *)__pyx_v_marker), ((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER), Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {
    __pyx_t_4 = (__Pyx_PyBytes_Equals(((PyObject *)__pyx_v_marker), ((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER_zlib), Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_3;
  }
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":729
 *         cdef bytes marker = data[:marker_len]
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:
 *             raise ValueError("Could not unpickle data")             # <<<<<<<<<<<<<<
 *         if marker == PICKLE_MARKER_zlib:
 *             data = zlib.decompress(data[marker_len:])
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __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 = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":730
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:
 *             raise ValueError("Could not unpickle data")
 *         if marker == PICKLE_MARKER_zlib:             # <<<<<<<<<<<<<<
 *             data = zlib.decompress(data[marker_len:])
 *         cdef usize_t length = len(data)
 */
  __pyx_t_5 = (__Pyx_PyBytes_Equals(((PyObject *)__pyx_v_marker), ((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER_zlib), Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_5) {

    /* "cimpl/field.pyx":731
 *             raise ValueError("Could not unpickle data")
 *         if marker == PICKLE_MARKER_zlib:
 *             data = zlib.decompress(data[marker_len:])             # <<<<<<<<<<<<<<
 *         cdef usize_t length = len(data)
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__zlib); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__decompress); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_data), __pyx_v_marker_len, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_data));
    __pyx_v_data = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":732
 *         if marker == PICKLE_MARKER_zlib:
 *             data = zlib.decompress(data[marker_len:])
 *         cdef usize_t length = len(data)             # <<<<<<<<<<<<<<
 * 
 *         cdef char *buf = data
 */
  if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_data)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length = __pyx_t_2;

  /* "cimpl/field.pyx":734
 *         cdef usize_t length = len(data)
 * 
 *         cdef char *buf = data             # <<<<<<<<<<<<<<
 *         cdef IdsPage page
 *         cdef usize_t position = 0
 */
  __pyx_t_8 = __Pyx_PyObject_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_buf = __pyx_t_8;

  /* "cimpl/field.pyx":736
 *         cdef char *buf = data
 *         cdef IdsPage page
 *         cdef usize_t position = 0             # <<<<<<<<<<<<<<
 *         cdef char page_state
 *         cdef char * write_position
 */
  __pyx_v_position = 0;

  /* "cimpl/field.pyx":739
 *         cdef char page_state
 *         cdef char * write_position
 *         while position < length:             # <<<<<<<<<<<<<<
 *             page_state = buf[position]
 *             position += 1
 */
  while (1) {
    __pyx_t_5 = (__pyx_v_position < __pyx_v_length);
    if (!__pyx_t_5) break;

    /* "cimpl/field.pyx":740
 *         cdef char * write_position
 *         while position < length:
 *             page_state = buf[position]             # <<<<<<<<<<<<<<
 *             position += 1
 *             page = IdsPage()
 */
    __pyx_v_page_state = (__pyx_v_buf[__pyx_v_position]);

    /* "cimpl/field.pyx":741
 *         while position < length:
 *             page_state = buf[position]
 *             position += 1             # <<<<<<<<<<<<<<
 *             page = IdsPage()
 *             if page_state == PAGE_FULL:
 */
    __pyx_v_position = (__pyx_v_position + 1);

    /* "cimpl/field.pyx":742
 *             page_state = buf[position]
 *             position += 1
 *             page = IdsPage()             # <<<<<<<<<<<<<<
 *             if page_state == PAGE_FULL:
 *                 page.set_full()
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_IdsPage)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":747
 *             elif page_state == PAGE_EMPTY:
 *                 pass
 *             elif page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 write_position = page.set_bits(buf + position, buf + position + PAGE_BYTES)
 *                 assert write_position == buf + (position + PAGE_BYTES)
 */
    switch (__pyx_v_page_state) {

      /* "cimpl/field.pyx":743
 *             position += 1
 *             page = IdsPage()
 *             if page_state == PAGE_FULL:             # <<<<<<<<<<<<<<
 *                 page.set_full()
 *             elif page_state == PAGE_EMPTY:
 */
      case 2:

      /* "cimpl/field.pyx":744
 *             page = IdsPage()
 *             if page_state == PAGE_FULL:
 *                 page.set_full()             # <<<<<<<<<<<<<<
 *             elif page_state == PAGE_EMPTY:
 *                 pass
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->set_full(__pyx_v_page);
      break;

      /* "cimpl/field.pyx":745
 *             if page_state == PAGE_FULL:
 *                 page.set_full()
 *             elif page_state == PAGE_EMPTY:             # <<<<<<<<<<<<<<
 *                 pass
 *             elif page_state == PAGE_PARTIAL:
 */
      case 3:
      break;

      /* "cimpl/field.pyx":747
 *             elif page_state == PAGE_EMPTY:
 *                 pass
 *             elif page_state == PAGE_PARTIAL:             # <<<<<<<<<<<<<<
 *                 write_position = page.set_bits(buf + position, buf + position + PAGE_BYTES)
 *                 assert write_position == buf + (position + PAGE_BYTES)
 */
      case 1:

      /* "cimpl/field.pyx":748
 *                 pass
 *             elif page_state == PAGE_PARTIAL:
 *                 write_position = page.set_bits(buf + position, buf + position + PAGE_BYTES)             # <<<<<<<<<<<<<<
 *                 assert write_position == buf + (position + PAGE_BYTES)
 *                 position += PAGE_BYTES
 */
      __pyx_v_write_position = ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->set_bits(__pyx_v_page, (__pyx_v_buf + __pyx_v_position), ((__pyx_v_buf + __pyx_v_position) + PAGE_BYTES));

      /* "cimpl/field.pyx":749
 *             elif page_state == PAGE_PARTIAL:
 *                 write_position = page.set_bits(buf + position, buf + position + PAGE_BYTES)
 *                 assert write_position == buf + (position + PAGE_BYTES)             # <<<<<<<<<<<<<<
 *                 position += PAGE_BYTES
 *             else:
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_write_position == (__pyx_v_buf + (__pyx_v_position + PAGE_BYTES))))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "cimpl/field.pyx":750
 *                 write_position = page.set_bits(buf + position, buf + position + PAGE_BYTES)
 *                 assert write_position == buf + (position + PAGE_BYTES)
 *                 position += PAGE_BYTES             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Could not unpickle data. Invalid page state: %s" % page_state)
 */
      __pyx_v_position = (__pyx_v_position + PAGE_BYTES);
      break;
      default:

      /* "cimpl/field.pyx":752
 *                 position += PAGE_BYTES
 *             else:
 *                 raise ValueError("Could not unpickle data. Invalid page state: %s" % page_state)             # <<<<<<<<<<<<<<
 *             self.pages.append(page)
 * 
 */
      __pyx_t_1 = PyInt_FromLong(__pyx_v_page_state); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_7));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "cimpl/field.pyx":753
 *             else:
 *                 raise ValueError("Could not unpickle data. Invalid page state: %s" % page_state)
 *             self.pages.append(page)             # <<<<<<<<<<<<<<
 * 
 *     cdef fill_range(self, usize_t low, usize_t high):
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_self->pages, ((PyObject *)__pyx_v_page)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("bitfield.Bitfield.load_from_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_marker);
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":755
 *             self.pages.append(page)
 * 
 *     cdef fill_range(self, usize_t low, usize_t high):             # <<<<<<<<<<<<<<
 *         """Add all numbers in range(low, high) to the bitfield, optimising the case where large
 *         ranges are supplied"""
 */

static PyObject *__pyx_f_8bitfield_8Bitfield_fill_range(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self, usize_t __pyx_v_low, usize_t __pyx_v_high) {
  struct __pyx_obj_8bitfield_IdsPage *__pyx_v_page = 0;
  usize_t __pyx_v_lower_page_boundary;
  usize_t __pyx_v_upper_page_boundary;
  usize_t __pyx_v_offset;
  usize_t __pyx_v_num;
  usize_t __pyx_v_page_num;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  usize_t __pyx_t_3;
  usize_t __pyx_t_4;
  long __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fill_range", 0);

  /* "cimpl/field.pyx":758
 *         """Add all numbers in range(low, high) to the bitfield, optimising the case where large
 *         ranges are supplied"""
 *         cdef IdsPage page = None             # <<<<<<<<<<<<<<
 *         cdef usize_t lower_page_boundary = (low // PAGE_FULL_COUNT)
 *         cdef usize_t upper_page_boundary = high // PAGE_FULL_COUNT
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)Py_None);

  /* "cimpl/field.pyx":759
 *         ranges are supplied"""
 *         cdef IdsPage page = None
 *         cdef usize_t lower_page_boundary = (low // PAGE_FULL_COUNT)             # <<<<<<<<<<<<<<
 *         cdef usize_t upper_page_boundary = high // PAGE_FULL_COUNT
 *         cdef usize_t offset = lower_page_boundary * PAGE_FULL_COUNT
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_lower_page_boundary = (__pyx_v_low / PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":760
 *         cdef IdsPage page = None
 *         cdef usize_t lower_page_boundary = (low // PAGE_FULL_COUNT)
 *         cdef usize_t upper_page_boundary = high // PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         cdef usize_t offset = lower_page_boundary * PAGE_FULL_COUNT
 *         # start by allocating all the pages we need
 */
  if (unlikely(PAGE_FULL_COUNT == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_upper_page_boundary = (__pyx_v_high / PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":761
 *         cdef usize_t lower_page_boundary = (low // PAGE_FULL_COUNT)
 *         cdef usize_t upper_page_boundary = high // PAGE_FULL_COUNT
 *         cdef usize_t offset = lower_page_boundary * PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *         # start by allocating all the pages we need
 *         assert high > 0
 */
  __pyx_v_offset = (__pyx_v_lower_page_boundary * PAGE_FULL_COUNT);

  /* "cimpl/field.pyx":763
 *         cdef usize_t offset = lower_page_boundary * PAGE_FULL_COUNT
 *         # start by allocating all the pages we need
 *         assert high > 0             # <<<<<<<<<<<<<<
 *         self.add(high - 1)
 *         # Find if there are any whole pages that can be allocated in one go
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_high > 0))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "cimpl/field.pyx":764
 *         # start by allocating all the pages we need
 *         assert high > 0
 *         self.add(high - 1)             # <<<<<<<<<<<<<<
 *         # Find if there are any whole pages that can be allocated in one go
 *         if lower_page_boundary * PAGE_FULL_COUNT != low:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->add(__pyx_v_self, (__pyx_v_high - 1), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":766
 *         self.add(high - 1)
 *         # Find if there are any whole pages that can be allocated in one go
 *         if lower_page_boundary * PAGE_FULL_COUNT != low:             # <<<<<<<<<<<<<<
 *             lower_page_boundary += 1
 *         if upper_page_boundary < lower_page_boundary:
 */
  __pyx_t_2 = ((__pyx_v_lower_page_boundary * PAGE_FULL_COUNT) != __pyx_v_low);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":767
 *         # Find if there are any whole pages that can be allocated in one go
 *         if lower_page_boundary * PAGE_FULL_COUNT != low:
 *             lower_page_boundary += 1             # <<<<<<<<<<<<<<
 *         if upper_page_boundary < lower_page_boundary:
 *             page = self.pages[upper_page_boundary]
 */
    __pyx_v_lower_page_boundary = (__pyx_v_lower_page_boundary + 1);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cimpl/field.pyx":768
 *         if lower_page_boundary * PAGE_FULL_COUNT != low:
 *             lower_page_boundary += 1
 *         if upper_page_boundary < lower_page_boundary:             # <<<<<<<<<<<<<<
 *             page = self.pages[upper_page_boundary]
 *             for num in range(low - offset, high - offset):
 */
  __pyx_t_2 = (__pyx_v_upper_page_boundary < __pyx_v_lower_page_boundary);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":769
 *             lower_page_boundary += 1
 *         if upper_page_boundary < lower_page_boundary:
 *             page = self.pages[upper_page_boundary]             # <<<<<<<<<<<<<<
 *             for num in range(low - offset, high - offset):
 *                 page.add(num)
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_upper_page_boundary, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":770
 *         if upper_page_boundary < lower_page_boundary:
 *             page = self.pages[upper_page_boundary]
 *             for num in range(low - offset, high - offset):             # <<<<<<<<<<<<<<
 *                 page.add(num)
 *             return
 */
    __pyx_t_3 = (__pyx_v_high - __pyx_v_offset);
    for (__pyx_t_4 = (__pyx_v_low - __pyx_v_offset); __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_num = __pyx_t_4;

      /* "cimpl/field.pyx":771
 *             page = self.pages[upper_page_boundary]
 *             for num in range(low - offset, high - offset):
 *                 page.add(num)             # <<<<<<<<<<<<<<
 *             return
 *         for page_num in range(lower_page_boundary, upper_page_boundary):
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->add(__pyx_v_page, __pyx_v_num);
    }

    /* "cimpl/field.pyx":772
 *             for num in range(low - offset, high - offset):
 *                 page.add(num)
 *             return             # <<<<<<<<<<<<<<
 *         for page_num in range(lower_page_boundary, upper_page_boundary):
 *             page = self.pages[page_num]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "cimpl/field.pyx":773
 *                 page.add(num)
 *             return
 *         for page_num in range(lower_page_boundary, upper_page_boundary):             # <<<<<<<<<<<<<<
 *             page = self.pages[page_num]
 *             page.set_full()
 */
  __pyx_t_3 = __pyx_v_upper_page_boundary;
  for (__pyx_t_4 = __pyx_v_lower_page_boundary; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_page_num = __pyx_t_4;

    /* "cimpl/field.pyx":774
 *             return
 *         for page_num in range(lower_page_boundary, upper_page_boundary):
 *             page = self.pages[page_num]             # <<<<<<<<<<<<<<
 *             page.set_full()
 *         if lower_page_boundary > 0:
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_v_page_num, sizeof(usize_t)+1, __Pyx_PyInt_to_py_usize_t, 1, 0, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":775
 *         for page_num in range(lower_page_boundary, upper_page_boundary):
 *             page = self.pages[page_num]
 *             page.set_full()             # <<<<<<<<<<<<<<
 *         if lower_page_boundary > 0:
 *             offset = (lower_page_boundary - 1) * PAGE_FULL_COUNT
 */
    ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->set_full(__pyx_v_page);
  }

  /* "cimpl/field.pyx":776
 *             page = self.pages[page_num]
 *             page.set_full()
 *         if lower_page_boundary > 0:             # <<<<<<<<<<<<<<
 *             offset = (lower_page_boundary - 1) * PAGE_FULL_COUNT
 *             page = self.pages[lower_page_boundary - 1]
 */
  __pyx_t_2 = (__pyx_v_lower_page_boundary > 0);
  if (__pyx_t_2) {

    /* "cimpl/field.pyx":777
 *             page.set_full()
 *         if lower_page_boundary > 0:
 *             offset = (lower_page_boundary - 1) * PAGE_FULL_COUNT             # <<<<<<<<<<<<<<
 *             page = self.pages[lower_page_boundary - 1]
 *             for num in range(low - offset, (lower_page_boundary * PAGE_FULL_COUNT) - offset):
 */
    __pyx_v_offset = ((__pyx_v_lower_page_boundary - 1) * PAGE_FULL_COUNT);

    /* "cimpl/field.pyx":778
 *         if lower_page_boundary > 0:
 *             offset = (lower_page_boundary - 1) * PAGE_FULL_COUNT
 *             page = self.pages[lower_page_boundary - 1]             # <<<<<<<<<<<<<<
 *             for num in range(low - offset, (lower_page_boundary * PAGE_FULL_COUNT) - offset):
 *                 page.add(num)
 */
    if (unlikely(((PyObject *)__pyx_v_self->pages) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = (__pyx_v_lower_page_boundary - 1);
    __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_self->pages), __pyx_t_5, sizeof(long), PyInt_FromLong, 1, 1, 1); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8bitfield_IdsPage))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_page));
    __pyx_v_page = ((struct __pyx_obj_8bitfield_IdsPage *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cimpl/field.pyx":779
 *             offset = (lower_page_boundary - 1) * PAGE_FULL_COUNT
 *             page = self.pages[lower_page_boundary - 1]
 *             for num in range(low - offset, (lower_page_boundary * PAGE_FULL_COUNT) - offset):             # <<<<<<<<<<<<<<
 *                 page.add(num)
 *         for num in range(upper_page_boundary * PAGE_FULL_COUNT, high):
 */
    __pyx_t_3 = ((__pyx_v_lower_page_boundary * PAGE_FULL_COUNT) - __pyx_v_offset);
    for (__pyx_t_4 = (__pyx_v_low - __pyx_v_offset); __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_num = __pyx_t_4;

      /* "cimpl/field.pyx":780
 *             page = self.pages[lower_page_boundary - 1]
 *             for num in range(low - offset, (lower_page_boundary * PAGE_FULL_COUNT) - offset):
 *                 page.add(num)             # <<<<<<<<<<<<<<
 *         for num in range(upper_page_boundary * PAGE_FULL_COUNT, high):
 *             self.add(num)
 */
      ((struct __pyx_vtabstruct_8bitfield_IdsPage *)__pyx_v_page->__pyx_vtab)->add(__pyx_v_page, __pyx_v_num);
    }
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "cimpl/field.pyx":781
 *             for num in range(low - offset, (lower_page_boundary * PAGE_FULL_COUNT) - offset):
 *                 page.add(num)
 *         for num in range(upper_page_boundary * PAGE_FULL_COUNT, high):             # <<<<<<<<<<<<<<
 *             self.add(num)
 * 
 */
  __pyx_t_3 = __pyx_v_high;
  for (__pyx_t_4 = (__pyx_v_upper_page_boundary * PAGE_FULL_COUNT); __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_num = __pyx_t_4;

    /* "cimpl/field.pyx":782
 *                 page.add(num)
 *         for num in range(upper_page_boundary * PAGE_FULL_COUNT, high):
 *             self.add(num)             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_self->__pyx_vtab)->add(__pyx_v_self, __pyx_v_num, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("bitfield.Bitfield.fill_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_page);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_73from_intervals(PyObject *__pyx_v_cls, PyObject *__pyx_v_list); /*proto*/
static char __pyx_doc_8bitfield_8Bitfield_72from_intervals[] = "Given a list of ranges in the form:  [[low1, high1], [low2, high2], ...]\n        Construct a bitfield in which every integer in each range is present";
static PyObject *__pyx_pw_8bitfield_8Bitfield_73from_intervals(PyObject *__pyx_v_cls, PyObject *__pyx_v_list) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_intervals (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_72from_intervals(((PyObject*)__pyx_v_cls), ((PyObject *)__pyx_v_list));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":785
 * 
 *     @classmethod
 *     def from_intervals(type cls, list):             # <<<<<<<<<<<<<<
 *         """Given a list of ranges in the form:  [[low1, high1], [low2, high2], ...]
 *         Construct a bitfield in which every integer in each range is present"""
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_72from_intervals(CYTHON_UNUSED PyObject *__pyx_v_cls, PyObject *__pyx_v_list) {
  struct __pyx_obj_8bitfield_Bitfield *__pyx_v_new = 0;
  PyObject *__pyx_v_low = NULL;
  PyObject *__pyx_v_high = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  usize_t __pyx_t_9;
  usize_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_intervals", 0);

  /* "cimpl/field.pyx":788
 *         """Given a list of ranges in the form:  [[low1, high1], [low2, high2], ...]
 *         Construct a bitfield in which every integer in each range is present"""
 *         cdef Bitfield new = Bitfield()             # <<<<<<<<<<<<<<
 *         for (low, high) in list:
 *             new.fill_range(low, high)
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_Bitfield)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new = ((struct __pyx_obj_8bitfield_Bitfield *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":789
 *         Construct a bitfield in which every integer in each range is present"""
 *         cdef Bitfield new = Bitfield()
 *         for (low, high) in list:             # <<<<<<<<<<<<<<
 *             new.fill_range(low, high)
 *         return new
 */
  if (PyList_CheckExact(__pyx_v_list) || PyTuple_CheckExact(__pyx_v_list)) {
    __pyx_t_1 = __pyx_v_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_list); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #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 = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_low);
    __pyx_v_low = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_high);
    __pyx_v_high = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cimpl/field.pyx":790
 *         cdef Bitfield new = Bitfield()
 *         for (low, high) in list:
 *             new.fill_range(low, high)             # <<<<<<<<<<<<<<
 *         return new
 * 
 */
    __pyx_t_9 = __Pyx_PyInt_from_py_usize_t(__pyx_v_low); if (unlikely((__pyx_t_9 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_from_py_usize_t(__pyx_v_high); if (unlikely((__pyx_t_10 == (usize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((struct __pyx_vtabstruct_8bitfield_Bitfield *)__pyx_v_new->__pyx_vtab)->fill_range(__pyx_v_new, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":791
 *         for (low, high) in list:
 *             new.fill_range(low, high)
 *         return new             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_new));
  __pyx_r = ((PyObject *)__pyx_v_new);
  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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("bitfield.Bitfield.from_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new);
  __Pyx_XDECREF(__pyx_v_low);
  __Pyx_XDECREF(__pyx_v_high);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_75__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_75__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_74__str__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":793
 *         return new
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "Bitfield(len=%i, range=0 > ~%i)" % (len(self), len(self.pages) * PAGE_FULL_COUNT)
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_74__str__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __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("__str__", 0);

  /* "cimpl/field.pyx":794
 * 
 *     def __str__(self):
 *         return "Bitfield(len=%i, range=0 > ~%i)" % (len(self), len(self.pages) * PAGE_FULL_COUNT)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->pages);
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_t_1 * PAGE_FULL_COUNT)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __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 = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_r = ((PyObject *)__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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bitfield.Bitfield.__str__", __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_8bitfield_8Bitfield_77__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_77__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_76__repr__(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":796
 *         return "Bitfield(len=%i, range=0 > ~%i)" % (len(self), len(self.pages) * PAGE_FULL_COUNT)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cls = type(self)
 *         return "%s.%s(%r)" % (cls.__module__, cls.__name__, self.pickle())
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_76__repr__(struct __pyx_obj_8bitfield_Bitfield *__pyx_v_self) {
  PyObject *__pyx_v_cls = NULL;
  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("__repr__", 0);

  /* "cimpl/field.pyx":797
 * 
 *     def __repr__(self):
 *         cls = type(self)             # <<<<<<<<<<<<<<
 *         return "%s.%s(%r)" % (cls.__module__, cls.__name__, self.pickle())
 * 
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
  __pyx_v_cls = ((PyObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));

  /* "cimpl/field.pyx":798
 *     def __repr__(self):
 *         cls = type(self)
 *         return "%s.%s(%r)" % (cls.__module__, cls.__name__, self.pickle())             # <<<<<<<<<<<<<<
 * 
 *     def clear(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s____module__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__pickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __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);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__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("bitfield.Bitfield.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cls);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8bitfield_8Bitfield_79clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8bitfield_8Bitfield_79clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("clear (wrapper)", 0);
  __pyx_r = __pyx_pf_8bitfield_8Bitfield_78clear(((struct __pyx_obj_8bitfield_Bitfield *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":800
 *         return "%s.%s(%r)" % (cls.__module__, cls.__name__, self.pickle())
 * 
 *     def clear(self):             # <<<<<<<<<<<<<<
 *         self.pages = []
 * 
 */

static PyObject *__pyx_pf_8bitfield_8Bitfield_78clear(struct __pyx_obj_8bitfield_Bitfield *__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("clear", 0);

  /* "cimpl/field.pyx":801
 * 
 *     def clear(self):
 *         self.pages = []             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->pages);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pages));
  __pyx_v_self->pages = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

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

/* "cimpl/field.pyx":804
 * 
 * 
 * cpdef unpickle_bitfield(bytes data):             # <<<<<<<<<<<<<<
 *     return Bitfield.unpickle(data)
 */

static PyObject *__pyx_pw_8bitfield_3unpickle_bitfield(PyObject *__pyx_self, PyObject *__pyx_v_data); /*proto*/
static PyObject *__pyx_f_8bitfield_unpickle_bitfield(PyObject *__pyx_v_data, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("unpickle_bitfield", 0);

  /* "cimpl/field.pyx":805
 * 
 * cpdef unpickle_bitfield(bytes data):
 *     return Bitfield.unpickle(data)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)((PyObject*)__pyx_ptype_8bitfield_Bitfield)), __pyx_n_s__unpickle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bitfield.unpickle_bitfield", __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_8bitfield_3unpickle_bitfield(PyObject *__pyx_self, PyObject *__pyx_v_data); /*proto*/
static PyObject *__pyx_pw_8bitfield_3unpickle_bitfield(PyObject *__pyx_self, PyObject *__pyx_v_data) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unpickle_bitfield (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_8bitfield_2unpickle_bitfield(__pyx_self, ((PyObject*)__pyx_v_data));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cimpl/field.pyx":804
 * 
 * 
 * cpdef unpickle_bitfield(bytes data):             # <<<<<<<<<<<<<<
 *     return Bitfield.unpickle(data)
 */

static PyObject *__pyx_pf_8bitfield_2unpickle_bitfield(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data) {
  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("unpickle_bitfield", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_8bitfield_unpickle_bitfield(__pyx_v_data, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __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("bitfield.unpickle_bitfield", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_8bitfield_PageIter __pyx_vtable_8bitfield_PageIter;

static PyObject *__pyx_tp_new_8bitfield_PageIter(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8bitfield_PageIter *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8bitfield_PageIter *)o);
  p->__pyx_vtab = __pyx_vtabptr_8bitfield_PageIter;
  p->page = ((struct __pyx_obj_8bitfield_IdsPage *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_8bitfield_8PageIter_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8bitfield_PageIter(PyObject *o) {
  struct __pyx_obj_8bitfield_PageIter *p = (struct __pyx_obj_8bitfield_PageIter *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->page);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8bitfield_PageIter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8bitfield_PageIter *p = (struct __pyx_obj_8bitfield_PageIter *)o;
  if (p->page) {
    e = (*v)(((PyObject*)p->page), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8bitfield_PageIter(PyObject *o) {
  struct __pyx_obj_8bitfield_PageIter *p = (struct __pyx_obj_8bitfield_PageIter *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->page);
  p->page = ((struct __pyx_obj_8bitfield_IdsPage *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_8bitfield_PageIter[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_8bitfield_8PageIter_3__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PageIter = {
  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_PageIter = {
  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_PageIter = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PageIter = {
  #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_8bitfield_PageIter = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("bitfield.PageIter"), /*tp_name*/
  sizeof(struct __pyx_obj_8bitfield_PageIter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8bitfield_PageIter, /*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_PageIter, /*tp_as_number*/
  &__pyx_tp_as_sequence_PageIter, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PageIter, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PageIter, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8bitfield_PageIter, /*tp_traverse*/
  __pyx_tp_clear_8bitfield_PageIter, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  __pyx_pw_8bitfield_8PageIter_3__next__, /*tp_iternext*/
  __pyx_methods_8bitfield_PageIter, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8bitfield_PageIter, /*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_8bitfield_BitfieldIterator __pyx_vtable_8bitfield_BitfieldIterator;

static PyObject *__pyx_tp_new_8bitfield_BitfieldIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8bitfield_BitfieldIterator *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8bitfield_BitfieldIterator *)o);
  p->__pyx_vtab = __pyx_vtabptr_8bitfield_BitfieldIterator;
  p->bitfield = ((struct __pyx_obj_8bitfield_Bitfield *)Py_None); Py_INCREF(Py_None);
  p->current_iter = ((struct __pyx_obj_8bitfield_PageIter *)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_8bitfield_16BitfieldIterator_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8bitfield_BitfieldIterator(PyObject *o) {
  struct __pyx_obj_8bitfield_BitfieldIterator *p = (struct __pyx_obj_8bitfield_BitfieldIterator *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->bitfield);
  Py_CLEAR(p->current_iter);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8bitfield_BitfieldIterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8bitfield_BitfieldIterator *p = (struct __pyx_obj_8bitfield_BitfieldIterator *)o;
  if (p->bitfield) {
    e = (*v)(((PyObject*)p->bitfield), a); if (e) return e;
  }
  if (p->current_iter) {
    e = (*v)(((PyObject*)p->current_iter), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8bitfield_BitfieldIterator(PyObject *o) {
  struct __pyx_obj_8bitfield_BitfieldIterator *p = (struct __pyx_obj_8bitfield_BitfieldIterator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->bitfield);
  p->bitfield = ((struct __pyx_obj_8bitfield_Bitfield *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->current_iter);
  p->current_iter = ((struct __pyx_obj_8bitfield_PageIter *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_8bitfield_BitfieldIterator[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_8bitfield_16BitfieldIterator_3__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_BitfieldIterator = {
  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_BitfieldIterator = {
  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_BitfieldIterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_BitfieldIterator = {
  #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_8bitfield_BitfieldIterator = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("bitfield.BitfieldIterator"), /*tp_name*/
  sizeof(struct __pyx_obj_8bitfield_BitfieldIterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8bitfield_BitfieldIterator, /*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_BitfieldIterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_BitfieldIterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_BitfieldIterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_BitfieldIterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Performs correctly when bitfields are mutating during iteration.\n    "), /*tp_doc*/
  __pyx_tp_traverse_8bitfield_BitfieldIterator, /*tp_traverse*/
  __pyx_tp_clear_8bitfield_BitfieldIterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  __pyx_pw_8bitfield_16BitfieldIterator_3__next__, /*tp_iternext*/
  __pyx_methods_8bitfield_BitfieldIterator, /*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*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8bitfield_BitfieldIterator, /*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_8bitfield_IdsPage __pyx_vtable_8bitfield_IdsPage;

static PyObject *__pyx_tp_new_8bitfield_IdsPage(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_8bitfield_IdsPage *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8bitfield_IdsPage *)o);
  p->__pyx_vtab = __pyx_vtabptr_8bitfield_IdsPage;
  if (unlikely(__pyx_pw_8bitfield_7IdsPage_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8bitfield_IdsPage(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_8bitfield_7IdsPage_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_8bitfield_7IdsPage_count(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8bitfield_7IdsPage_5count_1__get__(o);
}

static PyMethodDef __pyx_methods_8bitfield_IdsPage[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_8bitfield_IdsPage[] = {
  {(char *)"count", __pyx_getprop_8bitfield_7IdsPage_count, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_IdsPage = {
  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_IdsPage = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_8bitfield_7IdsPage_7__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_IdsPage = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_IdsPage = {
  #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_8bitfield_IdsPage = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("bitfield.IdsPage"), /*tp_name*/
  sizeof(struct __pyx_obj_8bitfield_IdsPage), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8bitfield_IdsPage, /*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_IdsPage, /*tp_as_number*/
  &__pyx_tp_as_sequence_IdsPage, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_IdsPage, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_IdsPage, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  __pyx_pw_8bitfield_7IdsPage_9__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_8bitfield_7IdsPage_5__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8bitfield_IdsPage, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8bitfield_IdsPage, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8bitfield_IdsPage, /*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_8bitfield_Bitfield __pyx_vtable_8bitfield_Bitfield;

static PyObject *__pyx_tp_new_8bitfield_Bitfield(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8bitfield_Bitfield *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8bitfield_Bitfield *)o);
  p->__pyx_vtab = __pyx_vtabptr_8bitfield_Bitfield;
  p->pages = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_8bitfield_8Bitfield_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8bitfield_Bitfield(PyObject *o) {
  struct __pyx_obj_8bitfield_Bitfield *p = (struct __pyx_obj_8bitfield_Bitfield *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->pages);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8bitfield_Bitfield(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8bitfield_Bitfield *p = (struct __pyx_obj_8bitfield_Bitfield *)o;
  if (p->pages) {
    e = (*v)(p->pages, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8bitfield_Bitfield(PyObject *o) {
  struct __pyx_obj_8bitfield_Bitfield *p = (struct __pyx_obj_8bitfield_Bitfield *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->pages);
  p->pages = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_8bitfield_8Bitfield_count(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8bitfield_8Bitfield_5count_1__get__(o);
}

static PyMethodDef __pyx_methods_8bitfield_Bitfield[] = {
  {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_3add, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_2add)},
  {__Pyx_NAMESTR("remove"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_5remove, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_4remove)},
  {__Pyx_NAMESTR("discard"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_7discard, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_6discard)},
  {__Pyx_NAMESTR("union"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_21union, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("update"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_41update, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_40update)},
  {__Pyx_NAMESTR("difference_update"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_43difference_update, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_42difference_update)},
  {__Pyx_NAMESTR("symmetric_difference_update"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_45symmetric_difference_update, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_44symmetric_difference_update)},
  {__Pyx_NAMESTR("symmetric_difference"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_47symmetric_difference, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("intersection_update"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_49intersection_update, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_48intersection_update)},
  {__Pyx_NAMESTR("intersection"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_51intersection, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_50intersection)},
  {__Pyx_NAMESTR("isdisjoint"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_53isdisjoint, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_52isdisjoint)},
  {__Pyx_NAMESTR("issubset"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_55issubset, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("issuperset"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_57issuperset, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_59copy, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_58copy)},
  {__Pyx_NAMESTR("clone"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_61clone, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_60clone)},
  {__Pyx_NAMESTR("pickle"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_67pickle, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_66pickle)},
  {__Pyx_NAMESTR("unpickle"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_69unpickle, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_68unpickle)},
  {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_71__reduce__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("from_intervals"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_73from_intervals, METH_O, __Pyx_DOCSTR(__pyx_doc_8bitfield_8Bitfield_72from_intervals)},
  {__Pyx_NAMESTR("clear"), (PyCFunction)__pyx_pw_8bitfield_8Bitfield_79clear, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_8bitfield_Bitfield[] = {
  {(char *)"count", __pyx_getprop_8bitfield_8Bitfield_count, 0, __Pyx_DOCSTR(__pyx_k_17), 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Bitfield = {
  __pyx_pw_8bitfield_8Bitfield_23__add__, /*nb_add*/
  __pyx_pw_8bitfield_8Bitfield_27__sub__, /*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*/
  __pyx_pw_8bitfield_8Bitfield_37__and__, /*nb_and*/
  __pyx_pw_8bitfield_8Bitfield_33__xor__, /*nb_xor*/
  __pyx_pw_8bitfield_8Bitfield_17__or__, /*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
  __pyx_pw_8bitfield_8Bitfield_25__iadd__, /*nb_inplace_add*/
  __pyx_pw_8bitfield_8Bitfield_31__isub__, /*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*/
  __pyx_pw_8bitfield_8Bitfield_39__iand__, /*nb_inplace_and*/
  __pyx_pw_8bitfield_8Bitfield_35__ixor__, /*nb_inplace_xor*/
  __pyx_pw_8bitfield_8Bitfield_19__ior__, /*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_Bitfield = {
  __pyx_pw_8bitfield_8Bitfield_9__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_8bitfield_8Bitfield_11__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Bitfield = {
  __pyx_pw_8bitfield_8Bitfield_9__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Bitfield = {
  #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
  __pyx_pw_8bitfield_8Bitfield_63__getbuffer__, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  __pyx_pw_8bitfield_8Bitfield_65__releasebuffer__, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_8bitfield_Bitfield = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("bitfield.Bitfield"), /*tp_name*/
  sizeof(struct __pyx_obj_8bitfield_Bitfield), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8bitfield_Bitfield, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_8bitfield_8Bitfield_77__repr__, /*tp_repr*/
  &__pyx_tp_as_number_Bitfield, /*tp_as_number*/
  &__pyx_tp_as_sequence_Bitfield, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Bitfield, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_8bitfield_8Bitfield_75__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Bitfield, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Efficient storage, and set-like operations on groups of positive integers\n    Currently, all integers must be in the range 0 >= x >= bitfield.get_all_sizes()[\"BITFIELD_MAX\"].\n    Note this does not take into consideration memory limits, which may become a factor in extreme cases.\n\n    The bitfield is designed to handle sets of numbers incrementing from 0.  Adding arbitrary, large numbers\n    to the set will not be efficient."), /*tp_doc*/
  __pyx_tp_traverse_8bitfield_Bitfield, /*tp_traverse*/
  __pyx_tp_clear_8bitfield_Bitfield, /*tp_clear*/
  __pyx_pw_8bitfield_8Bitfield_15__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_8bitfield_8Bitfield_13__iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8bitfield_Bitfield, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8bitfield_Bitfield, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8bitfield_Bitfield, /*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[] = {
  {__Pyx_NAMESTR("unpickle_bitfield"), (PyCFunction)__pyx_pw_8bitfield_3unpickle_bitfield, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    __Pyx_NAMESTR("bitfield"),
    0, /* 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_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_n_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 1},
  {&__pyx_n_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 1},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__AssertionError, __pyx_k__AssertionError, sizeof(__pyx_k__AssertionError), 0, 0, 1, 1},
  {&__pyx_n_s__BITFIELD_MAX, __pyx_k__BITFIELD_MAX, sizeof(__pyx_k__BITFIELD_MAX), 0, 0, 1, 1},
  {&__pyx_n_s__CHUNK_BITS, __pyx_k__CHUNK_BITS, sizeof(__pyx_k__CHUNK_BITS), 0, 0, 1, 1},
  {&__pyx_n_s__CHUNK_BYTES, __pyx_k__CHUNK_BYTES, sizeof(__pyx_k__CHUNK_BYTES), 0, 0, 1, 1},
  {&__pyx_n_s__CHUNK_FULL_COUNT, __pyx_k__CHUNK_FULL_COUNT, sizeof(__pyx_k__CHUNK_FULL_COUNT), 0, 0, 1, 1},
  {&__pyx_n_s__CHUNK_MASK, __pyx_k__CHUNK_MASK, sizeof(__pyx_k__CHUNK_MASK), 0, 0, 1, 1},
  {&__pyx_n_s__CHUNK_SHIFT, __pyx_k__CHUNK_SHIFT, sizeof(__pyx_k__CHUNK_SHIFT), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__PAGE_BYTES, __pyx_k__PAGE_BYTES, sizeof(__pyx_k__PAGE_BYTES), 0, 0, 1, 1},
  {&__pyx_n_s__PAGE_CHUNKS, __pyx_k__PAGE_CHUNKS, sizeof(__pyx_k__PAGE_CHUNKS), 0, 0, 1, 1},
  {&__pyx_n_s__PAGE_FULL_COUNT, __pyx_k__PAGE_FULL_COUNT, sizeof(__pyx_k__PAGE_FULL_COUNT), 0, 0, 1, 1},
  {&__pyx_n_s__PAGE_MAX, __pyx_k__PAGE_MAX, sizeof(__pyx_k__PAGE_MAX), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____module__, __pyx_k____module__, sizeof(__pyx_k____module__), 0, 0, 1, 1},
  {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
  {&__pyx_n_s____slots__, __pyx_k____slots__, sizeof(__pyx_k____slots__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___data, __pyx_k___data, sizeof(__pyx_k___data), 0, 0, 1, 1},
  {&__pyx_n_s__add, __pyx_k__add, sizeof(__pyx_k__add), 0, 0, 1, 1},
  {&__pyx_n_s__bin, __pyx_k__bin, sizeof(__pyx_k__bin), 0, 0, 1, 1},
  {&__pyx_n_s__bitfield, __pyx_k__bitfield, sizeof(__pyx_k__bitfield), 0, 0, 1, 1},
  {&__pyx_n_s__clone, __pyx_k__clone, sizeof(__pyx_k__clone), 0, 0, 1, 1},
  {&__pyx_n_s__compress, __pyx_k__compress, sizeof(__pyx_k__compress), 0, 0, 1, 1},
  {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
  {&__pyx_n_s__count, __pyx_k__count, sizeof(__pyx_k__count), 0, 0, 1, 1},
  {&__pyx_n_s__decompress, __pyx_k__decompress, sizeof(__pyx_k__decompress), 0, 0, 1, 1},
  {&__pyx_n_s__difference_update, __pyx_k__difference_update, sizeof(__pyx_k__difference_update), 0, 0, 1, 1},
  {&__pyx_n_s__discard, __pyx_k__discard, sizeof(__pyx_k__discard), 0, 0, 1, 1},
  {&__pyx_n_s__from_intervals, __pyx_k__from_intervals, sizeof(__pyx_k__from_intervals), 0, 0, 1, 1},
  {&__pyx_n_s__get_all_sizes, __pyx_k__get_all_sizes, sizeof(__pyx_k__get_all_sizes), 0, 0, 1, 1},
  {&__pyx_n_s__intersection, __pyx_k__intersection, sizeof(__pyx_k__intersection), 0, 0, 1, 1},
  {&__pyx_n_s__intersection_update, __pyx_k__intersection_update, sizeof(__pyx_k__intersection_update), 0, 0, 1, 1},
  {&__pyx_n_s__isdisjoint, __pyx_k__isdisjoint, sizeof(__pyx_k__isdisjoint), 0, 0, 1, 1},
  {&__pyx_n_s__issubset, __pyx_k__issubset, sizeof(__pyx_k__issubset), 0, 0, 1, 1},
  {&__pyx_n_s__issuperset, __pyx_k__issuperset, sizeof(__pyx_k__issuperset), 0, 0, 1, 1},
  {&__pyx_n_s__memoryview, __pyx_k__memoryview, sizeof(__pyx_k__memoryview), 0, 0, 1, 1},
  {&__pyx_n_s__page, __pyx_k__page, sizeof(__pyx_k__page), 0, 0, 1, 1},
  {&__pyx_n_s__pickle, __pyx_k__pickle, sizeof(__pyx_k__pickle), 0, 0, 1, 1},
  {&__pyx_n_s__pop, __pyx_k__pop, sizeof(__pyx_k__pop), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__tobytes, __pyx_k__tobytes, sizeof(__pyx_k__tobytes), 0, 0, 1, 1},
  {&__pyx_n_s__unpickle, __pyx_k__unpickle, sizeof(__pyx_k__unpickle), 0, 0, 1, 1},
  {&__pyx_n_s__unpickle_bitfield, __pyx_k__unpickle_bitfield, sizeof(__pyx_k__unpickle_bitfield), 0, 0, 1, 1},
  {&__pyx_n_s__update, __pyx_k__update, sizeof(__pyx_k__update), 0, 0, 1, 1},
  {&__pyx_n_s__zlib, __pyx_k__zlib, sizeof(__pyx_k__zlib), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_bin = __Pyx_GetBuiltinName(__pyx_n_s__bin); if (!__pyx_builtin_bin) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s__AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_memoryview = __Pyx_GetBuiltinName(__pyx_n_s__memoryview); if (!__pyx_builtin_memoryview) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __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);

  /* "cimpl/field.pyx":320
 *                 self.calc_length()
 *             else:
 *                 raise AssertionError("Invalid page state")             # <<<<<<<<<<<<<<
 *         else:
 *             raise AssertionError("Invalid page state")
 */
  __pyx_k_tuple_5 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_5);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "cimpl/field.pyx":322
 *                 raise AssertionError("Invalid page state")
 *         else:
 *             raise AssertionError("Invalid page state")             # <<<<<<<<<<<<<<
 * 
 *     cdef void difference_update(self, IdsPage other):
 */
  __pyx_k_tuple_6 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_6);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));

  /* "cimpl/field.pyx":663
 * 
 *         if flags & pybuf.PyBUF_WRITABLE:
 *             raise ValueError("bitfields do not provide writable buffers")             # <<<<<<<<<<<<<<
 * 
 *         if flags & pybuf.PyBUF_FORMAT:
 */
  __pyx_k_tuple_10 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_9)); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_10);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));

  /* "cimpl/field.pyx":729
 *         cdef bytes marker = data[:marker_len]
 *         if marker != PICKLE_MARKER and marker != PICKLE_MARKER_zlib:
 *             raise ValueError("Could not unpickle data")             # <<<<<<<<<<<<<<
 *         if marker == PICKLE_MARKER_zlib:
 *             data = zlib.decompress(data[marker_len:])
 */
  __pyx_k_tuple_13 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_12)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_13);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));

  /* "cimpl/field.pyx":55
 * 
 * 
 * def get_all_sizes():             # <<<<<<<<<<<<<<
 *     return dict(
 *         CHUNK_BYTES=CHUNK_BYTES,
 */
  __pyx_k_codeobj_18 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_19, __pyx_n_s__get_all_sizes, 55, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __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_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_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_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__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 initbitfield(void); /*proto*/
PyMODINIT_FUNC initbitfield(void)
#else
PyMODINIT_FUNC PyInit_bitfield(void); /*proto*/
PyMODINIT_FUNC PyInit_bitfield(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_bitfield(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("bitfield"), __pyx_methods, 0, 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_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "bitfield")) {
      if (unlikely(PyDict_SetItemString(modules, "bitfield", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  __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 PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_bitfield) {
    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 ---*/
  __pyx_v_8bitfield_PICKLE_MARKER = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_8bitfield_PICKLE_MARKER_zlib = ((PyObject*)Py_None); Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_8bitfield_PageIter = &__pyx_vtable_8bitfield_PageIter;
  __pyx_vtable_8bitfield_PageIter._advance = (usize_t (*)(struct __pyx_obj_8bitfield_PageIter *))__pyx_f_8bitfield_8PageIter__advance;
  __pyx_vtable_8bitfield_PageIter._next = (PyObject *(*)(struct __pyx_obj_8bitfield_PageIter *))__pyx_f_8bitfield_8PageIter__next;
  if (PyType_Ready(&__pyx_type_8bitfield_PageIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8bitfield_PageIter.tp_dict, __pyx_vtabptr_8bitfield_PageIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "PageIter", (PyObject *)&__pyx_type_8bitfield_PageIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8bitfield_PageIter = &__pyx_type_8bitfield_PageIter;
  __pyx_vtabptr_8bitfield_BitfieldIterator = &__pyx_vtable_8bitfield_BitfieldIterator;
  __pyx_vtable_8bitfield_BitfieldIterator._next_iter = (PyObject *(*)(struct __pyx_obj_8bitfield_BitfieldIterator *))__pyx_f_8bitfield_16BitfieldIterator__next_iter;
  if (PyType_Ready(&__pyx_type_8bitfield_BitfieldIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8bitfield_BitfieldIterator.tp_dict, __pyx_vtabptr_8bitfield_BitfieldIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "BitfieldIterator", (PyObject *)&__pyx_type_8bitfield_BitfieldIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8bitfield_BitfieldIterator = &__pyx_type_8bitfield_BitfieldIterator;
  __pyx_vtabptr_8bitfield_IdsPage = &__pyx_vtable_8bitfield_IdsPage;
  __pyx_vtable_8bitfield_IdsPage._fill = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, CHUNK))__pyx_f_8bitfield_7IdsPage__fill;
  __pyx_vtable_8bitfield_IdsPage.set_full = (void (*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_set_full;
  __pyx_vtable_8bitfield_IdsPage.set_empty = (void (*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_set_empty;
  __pyx_vtable_8bitfield_IdsPage._alloc = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_opt_args_8bitfield_7IdsPage__alloc *__pyx_optional_args))__pyx_f_8bitfield_7IdsPage__alloc;
  __pyx_vtable_8bitfield_IdsPage._dealloc = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, int))__pyx_f_8bitfield_7IdsPage__dealloc;
  __pyx_vtable_8bitfield_IdsPage._iter = (PyObject *(*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage__iter;
  __pyx_vtable_8bitfield_IdsPage.calc_length = (void (*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_calc_length;
  __pyx_vtable_8bitfield_IdsPage.add = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, usize_t))__pyx_f_8bitfield_7IdsPage_add;
  __pyx_vtable_8bitfield_IdsPage.remove = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, usize_t))__pyx_f_8bitfield_7IdsPage_remove;
  __pyx_vtable_8bitfield_IdsPage.update = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_update;
  __pyx_vtable_8bitfield_IdsPage.intersection_update = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_intersection_update;
  __pyx_vtable_8bitfield_IdsPage.difference_update = (void (*)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_difference_update;
  __pyx_vtable_8bitfield_IdsPage._state = (char const *(*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage__state;
  __pyx_vtable_8bitfield_IdsPage.symmetric_difference_update = (PyObject *(*)(struct __pyx_obj_8bitfield_IdsPage *, struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_symmetric_difference_update;
  __pyx_vtable_8bitfield_IdsPage.clone = (struct __pyx_obj_8bitfield_IdsPage *(*)(struct __pyx_obj_8bitfield_IdsPage *))__pyx_f_8bitfield_7IdsPage_clone;
  __pyx_vtable_8bitfield_IdsPage.set_bits = (char *(*)(struct __pyx_obj_8bitfield_IdsPage *, char *, char *))__pyx_f_8bitfield_7IdsPage_set_bits;
  if (PyType_Ready(&__pyx_type_8bitfield_IdsPage) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_8bitfield_IdsPage.tp_dict, __pyx_vtabptr_8bitfield_IdsPage) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "IdsPage", (PyObject *)&__pyx_type_8bitfield_IdsPage) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8bitfield_IdsPage = &__pyx_type_8bitfield_IdsPage;
  __pyx_vtabptr_8bitfield_Bitfield = &__pyx_vtable_8bitfield_Bitfield;
  __pyx_vtable_8bitfield_Bitfield._ensure_page_exists = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, usize_t))__pyx_f_8bitfield_8Bitfield__ensure_page_exists;
  __pyx_vtable_8bitfield_Bitfield._cleanup = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *))__pyx_f_8bitfield_8Bitfield__cleanup;
  __pyx_vtable_8bitfield_Bitfield.add = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_add;
  __pyx_vtable_8bitfield_Bitfield.remove = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_remove;
  __pyx_vtable_8bitfield_Bitfield.discard = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_discard;
  __pyx_vtable_8bitfield_Bitfield.update = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_update;
  __pyx_vtable_8bitfield_Bitfield.difference_update = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_difference_update;
  __pyx_vtable_8bitfield_Bitfield.symmetric_difference_update = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_symmetric_difference_update;
  __pyx_vtable_8bitfield_Bitfield.symmetric_difference = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_symmetric_difference;
  __pyx_vtable_8bitfield_Bitfield.intersection_update = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_intersection_update;
  __pyx_vtable_8bitfield_Bitfield.intersection = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_intersection;
  __pyx_vtable_8bitfield_Bitfield.isdisjoint = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_isdisjoint;
  __pyx_vtable_8bitfield_Bitfield.issubset = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_issubset;
  __pyx_vtable_8bitfield_Bitfield.issuperset = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_issuperset;
  __pyx_vtable_8bitfield_Bitfield.copy = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_copy;
  __pyx_vtable_8bitfield_Bitfield.clone = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, int __pyx_skip_dispatch))__pyx_f_8bitfield_8Bitfield_clone;
  __pyx_vtable_8bitfield_Bitfield.load = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, PyObject *))__pyx_f_8bitfield_8Bitfield_load;
  __pyx_vtable_8bitfield_Bitfield.load_from_bytes = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, PyObject *))__pyx_f_8bitfield_8Bitfield_load_from_bytes;
  __pyx_vtable_8bitfield_Bitfield.fill_range = (PyObject *(*)(struct __pyx_obj_8bitfield_Bitfield *, usize_t, usize_t))__pyx_f_8bitfield_8Bitfield_fill_range;
  if (PyType_Ready(&__pyx_type_8bitfield_Bitfield) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_8__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_8__len__.doc = __pyx_doc_8bitfield_8Bitfield_8__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_8__len__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__contains__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_10__contains__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_10__contains__.doc = __pyx_doc_8bitfield_8Bitfield_10__contains__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_10__contains__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__iter__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_12__iter__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_12__iter__.doc = __pyx_doc_8bitfield_8Bitfield_12__iter__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_12__iter__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__or__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_16__or__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_16__or__.doc = __pyx_doc_8bitfield_8Bitfield_16__or__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_16__or__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__add__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_22__add__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_22__add__.doc = __pyx_doc_8bitfield_8Bitfield_22__add__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_22__add__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_8bitfield_Bitfield, "__iadd__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_8bitfield_8Bitfield_24__iadd__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_8bitfield_8Bitfield_24__iadd__.doc = __pyx_doc_8bitfield_8Bitfield_24__iadd__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8bitfield_8Bitfield_24__iadd__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_8bitfield_Bitfield.tp_dict, __pyx_vtabptr_8bitfield_Bitfield) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Bitfield", (PyObject *)&__pyx_type_8bitfield_Bitfield) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8bitfield_Bitfield = &__pyx_type_8bitfield_Bitfield;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "cimpl/field.pyx":4
 * # Imports and boilerplate
 * import cython
 * import zlib             # <<<<<<<<<<<<<<
 * import sys
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__zlib), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__zlib, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":5
 * import cython
 * import zlib
 * import sys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":55
 * 
 * 
 * def get_all_sizes():             # <<<<<<<<<<<<<<
 *     return dict(
 *         CHUNK_BYTES=CHUNK_BYTES,
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8bitfield_1get_all_sizes, NULL, __pyx_n_s__bitfield); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__get_all_sizes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cimpl/field.pyx":415
 * 
 * # Markers must be the same length
 * cdef bytes PICKLE_MARKER = <char *>"BF:"             # <<<<<<<<<<<<<<
 * cdef bytes PICKLE_MARKER_zlib = <char *>"BZ:"
 * 
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(((char *)__pyx_k_20)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_XGOTREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER));
  __Pyx_DECREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_v_8bitfield_PICKLE_MARKER = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":416
 * # Markers must be the same length
 * cdef bytes PICKLE_MARKER = <char *>"BF:"
 * cdef bytes PICKLE_MARKER_zlib = <char *>"BZ:"             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(((char *)__pyx_k_21)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_XGOTREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER_zlib));
  __Pyx_DECREF(((PyObject *)__pyx_v_8bitfield_PICKLE_MARKER_zlib));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_v_8bitfield_PICKLE_MARKER_zlib = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":428
 * 
 *     cdef list pages
 *     __slots__ = ()             # <<<<<<<<<<<<<<
 * 
 *     def __cinit__(self, _data=None):
 */
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8bitfield_Bitfield->tp_dict, __pyx_n_s____slots__, ((PyObject *)__pyx_empty_tuple)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_8bitfield_Bitfield);

  /* "cimpl/field.pyx":696
 *         free(view.buf)
 * 
 *     def pickle(self, compress=True):             # <<<<<<<<<<<<<<
 *         """Return a string representation of the bitfield"""
 *         cdef bytes marker = PICKLE_MARKER
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k_11 = __pyx_t_1;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cimpl/field.pyx":706
 * 
 *     @classmethod
 *     def unpickle(cls, bytes data):             # <<<<<<<<<<<<<<
 *         """Read a bitfield object from a string created by Bitfield.piclke"""
 *         cdef Bitfield new = Bitfield()
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8bitfield_Bitfield, __pyx_n_s__unpickle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8bitfield_Bitfield->tp_dict, __pyx_n_s__unpickle, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_8bitfield_Bitfield);

  /* "cimpl/field.pyx":785
 * 
 *     @classmethod
 *     def from_intervals(type cls, list):             # <<<<<<<<<<<<<<
 *         """Given a list of ranges in the form:  [[low1, high1], [low2, high2], ...]
 *         Construct a bitfield in which every integer in each range is present"""
 */
  __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8bitfield_Bitfield, __pyx_n_s__from_intervals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8bitfield_Bitfield->tp_dict, __pyx_n_s__from_intervals, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_8bitfield_Bitfield);

  /* "cimpl/field.pyx":1
 * # cython: profile=False             # <<<<<<<<<<<<<<
 * # Imports and boilerplate
 * import cython
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    __Pyx_AddTraceback("init bitfield", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init bitfield");
  }
  __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_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

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 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 PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else 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 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;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (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 = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

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 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 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 PyObject* __Pyx_PyObject_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02040000
    if (likely(PyList_CheckExact(L))
        && likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        Py_SIZE(L) -= 1;
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
#if PY_VERSION_HEX >= 0x02050000
    else if (Py_TYPE(L) == (&PySet_Type)) {
        return PySet_Pop(L);
    }
#endif
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s__pop);
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (result) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

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 int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyBytes_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
            else
                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
        } else {
            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

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, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__);
    if (!py_import)
        goto bad;
    #endif
    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, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                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);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            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
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
    #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:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE usize_t __Pyx_PyInt_from_py_usize_t(PyObject* x) {
    const usize_t neg_one = (usize_t)-1, const_zero = (usize_t)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(usize_t) == sizeof(char)) {
        if (is_unsigned)
            return (usize_t)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (usize_t)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(usize_t) == sizeof(short)) {
        if (is_unsigned)
            return (usize_t)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (usize_t)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(usize_t) == sizeof(int)) {
        if (is_unsigned)
            return (usize_t)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (usize_t)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(usize_t) == sizeof(long)) {
        if (is_unsigned)
            return (usize_t)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (usize_t)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(usize_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (usize_t)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (usize_t)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
        PyErr_SetString(PyExc_RuntimeError,
                        "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
        #else
        usize_t val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_MAJOR_VERSION < 3
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        #endif
        return (usize_t)-1;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_usize_t(usize_t val) {
    const usize_t neg_one = (usize_t)-1, const_zero = (usize_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(usize_t) == sizeof(char))  ||
        (sizeof(usize_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(usize_t) == sizeof(int)) ||
               (sizeof(usize_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(usize_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(usize_t),
                                     little, !is_unsigned);
    }
}

static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) { /* cdef classes */
        return PyClassMethod_New(method);
    }
#else
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) { /* python classes */
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __Pyx_CyFunction_USED
    else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
        return PyClassMethod_New(method);
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "Class-level classmethod() can only be called on "
                 "a method_descriptor or instance method.");
    return NULL;
}

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);
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
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_MAJOR_VERSION < 3
    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 CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            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 void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

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;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */
        if (PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_DATA_SIZE(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
        return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */
    } else
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (r < 0) {
            return NULL;
        } else {
            return result;
        }
    }
}
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_MAJOR_VERSION < 3
  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_MAJOR_VERSION < 3
  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_MAJOR_VERSION < 3
    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)(size_t)val)) {
       if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred())
           PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
