/* Generated by Pyrex 0.9.5.1 on Wed Jan 31 16:35:25 2007 */

#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
__PYX_EXTERN_C double pow(double, double);


typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

static char __pyx_mdoc[] = "C Speedups for commonly-used operations";

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

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

static PyObject *__Pyx_GetExcValue(void); /*proto*/

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

static void __Pyx_ReRaise(void); /*proto*/

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/

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

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from _speedups */


struct __pyx_obj_9_speedups_metamethod {
  PyObject_HEAD
  PyObject *func;
};

static PyTypeObject *__pyx_ptype_9_speedups_metamethod = 0;
static PyObject *__pyx_v_9_speedups__marker;
static PyObject *__pyx_v_9_speedups___conform;
static PyObject *__pyx_v_9_speedups___adapt;
static PyObject *__pyx_v_9_speedups___mro;
static PyObject *__pyx_v_9_speedups___ECType;
static PyObject *__pyx_k19;
static PyObject *__pyx_k20;
static PyObject *__pyx_k21;
static PyObject *__pyx_k22;
static PyObject *__pyx_k23;
static PyObject *__pyx_k24;
static PyObject *__pyx_k25;
static PyObject *(__pyx_f_9_speedups__adapt(PyObject *,PyObject *,PyObject *)); /*proto*/
static PyObject *(__pyx_f_9_speedups_buildClassicMRO(PyClassObject (*),PyListObject (*))); /*proto*/
static PyObject *(__pyx_f_9_speedups_buildECMRO(PyObject *,PyListObject (*))); /*proto*/


/* Implementation of _speedups */

static char (__pyx_k11[]) = "protocols.adapters";
static char (__pyx_k15[]) = "__conform__";
static char (__pyx_k16[]) = "__adapt__";
static char (__pyx_k17[]) = "__class__";
static char (__pyx_k18[]) = "__mro__";

static PyObject *__pyx_n___all__;
static PyObject *__pyx_n_exc_info;
static PyObject *__pyx_n_AdaptationFailure;
static PyObject *__pyx_n_ExtensionClass;
static PyObject *__pyx_n___class;
static PyObject *__pyx_n_NO_ADAPTER_NEEDED;
static PyObject *__pyx_n_DOES_NOT_SUPPORT;
static PyObject *__pyx_n_adapt;
static PyObject *__pyx_n_Protocol__call__;
static PyObject *__pyx_n_classicMRO;
static PyObject *__pyx_n_extClassMRO;
static PyObject *__pyx_n_getMRO;
static PyObject *__pyx_n_Protocol__adapt__;
static PyObject *__pyx_n_metamethod;
static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_ImportError;
static PyObject *__pyx_n_object;
static PyObject *__pyx_n_False;

static PyObject *__pyx_k11p;

static PyObject *__pyx_f_9_speedups_NO_ADAPTER_NEEDED(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9_speedups_NO_ADAPTER_NEEDED[] = "Assume \'obj\' implements \'protocol\' directly";
static PyObject *__pyx_f_9_speedups_NO_ADAPTER_NEEDED(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_protocol = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"obj","protocol",0};
  __pyx_v_protocol = __pyx_k19;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_obj, &__pyx_v_protocol)) return 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":87 */
  Py_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_DOES_NOT_SUPPORT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9_speedups_DOES_NOT_SUPPORT[] = "Prevent \'obj\' from supporting \'protocol\'";
static PyObject *__pyx_f_9_speedups_DOES_NOT_SUPPORT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_protocol = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"obj","protocol",0};
  __pyx_v_protocol = __pyx_k20;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_obj, &__pyx_v_protocol)) return 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":91 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  return __pyx_r;
}

static int __pyx_f_9_speedups_10metamethod___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_9_speedups_10metamethod___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_func = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {"func",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_func)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_func);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":100 */
  Py_INCREF(__pyx_v_func);
  Py_DECREF(((struct __pyx_obj_9_speedups_metamethod *)__pyx_v_self)->func);
  ((struct __pyx_obj_9_speedups_metamethod *)__pyx_v_self)->func = __pyx_v_func;

  __pyx_r = 0;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_func);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_10metamethod___get__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_typ); /*proto*/
static PyObject *__pyx_f_9_speedups_10metamethod___get__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_typ) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_typ);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":103 */
  __pyx_1 = __pyx_v_ob == Py_None;
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":104 */
    Py_INCREF(__pyx_v_self);
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":105 */
  __pyx_2 = PyMethod_New(((struct __pyx_obj_9_speedups_metamethod *)__pyx_v_self)->func,__pyx_v_ob,__pyx_v_typ); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_speedups.metamethod.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_typ);
  return __pyx_r;
}

static PyObject *__pyx_n_AttributeError;

static PyObject *__pyx_k26p;

static char (__pyx_k26[]) = "Read-only attribute";

static int __pyx_f_9_speedups_10metamethod___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_value); /*proto*/
static int __pyx_f_9_speedups_10metamethod___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_value) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_value);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":108 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_AttributeError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  Py_INCREF(__pyx_k26p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k26p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_speedups.metamethod.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}

static PyObject *__pyx_k27p;

static char (__pyx_k27[]) = "Read-only attribute";

static int __pyx_f_9_speedups_10metamethod___delete__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob); /*proto*/
static int __pyx_f_9_speedups_10metamethod___delete__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_ob);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":111 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_AttributeError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  Py_INCREF(__pyx_k27p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k27p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_speedups.metamethod.__delete__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_ob);
  return __pyx_r;
}

static PyObject *__pyx_n_TypeError;
static PyObject *__pyx_n_tb_next;

static PyObject *__pyx_k28p;

static char (__pyx_k28[]) = "Can't adapt";

static PyObject *__pyx_f_9_speedups__adapt(PyObject *__pyx_v_obj,PyObject *__pyx_v_protocol,PyObject *__pyx_v_default) {
  void (*__pyx_v_tmp);
  PyObject *__pyx_v_meth;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_err;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);
  Py_INCREF(__pyx_v_default);
  __pyx_v_meth = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_err = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":131 */
  __pyx_1 = PyType_Check(__pyx_v_protocol);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":132 */
    __pyx_1 = PyObject_TypeCheck(__pyx_v_obj,__pyx_v_protocol);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":133 */
      Py_INCREF(__pyx_v_obj);
      __pyx_r = __pyx_v_obj;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":135 */
  __pyx_1 = PyClass_Check(__pyx_v_protocol);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":136 */
    __pyx_1 = PyInstance_Check(__pyx_v_obj);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":137 */
      __pyx_1 = PyObject_IsInstance(__pyx_v_obj,__pyx_v_protocol);
      if (__pyx_1) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":138 */
        Py_INCREF(__pyx_v_obj);
        __pyx_r = __pyx_v_obj;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":140 */
  __pyx_v_tmp = PyObject_GetAttr(__pyx_v_obj,__pyx_v_9_speedups___conform);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":141 */
  __pyx_1 = (__pyx_v_tmp != 0);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":142 */
    __pyx_2 = (PyObject *)__pyx_v_tmp;
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_meth);
    __pyx_v_meth = __pyx_2;
    __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":143 */
    Py_DECREF(((PyObject (*))__pyx_v_tmp));

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":144 */
    /*try:*/ {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":145 */
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L8;}
      Py_INCREF(__pyx_v_protocol);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_protocol);
      __pyx_3 = PyObject_CallObject(__pyx_v_meth, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L8;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_3;
      __pyx_3 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":146 */
      __pyx_1 = __pyx_v_result != Py_None;
      if (__pyx_1) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":147 */
        Py_INCREF(__pyx_v_result);
        __pyx_r = __pyx_v_result;
        goto __pyx_L0;
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
    goto __pyx_L9;
    __pyx_L8:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":148 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
    __pyx_1 = PyErr_ExceptionMatches(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {
      __Pyx_AddTraceback("_speedups._adapt");
      __pyx_3 = __Pyx_GetExcValue(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":149 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_exc_info); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_tb_next); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_1 = __pyx_3 != Py_None;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__pyx_1) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":150 */
        __Pyx_ReRaise();
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;}
        goto __pyx_L11;
      }
      __pyx_L11:;
      goto __pyx_L9;
    }
    goto __pyx_L1;
    __pyx_L9:;
    goto __pyx_L7;
  }
  __pyx_1 = PyErr_ExceptionMatches(PyExc_AttributeError);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":152 */
    PyErr_Clear();
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":154 */
    __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; goto __pyx_L1;}
    Py_DECREF(__pyx_v_err);
    __pyx_v_err = __pyx_2;
    __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":155 */
    __Pyx_ReRaise();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; goto __pyx_L1;}
  }
  __pyx_L7:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":165 */
  __pyx_v_tmp = PyObject_GetAttr(__pyx_v_protocol,__pyx_v_9_speedups___adapt);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":166 */
  __pyx_1 = (__pyx_v_tmp != 0);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":167 */
    __pyx_4 = (PyObject *)__pyx_v_tmp;
    Py_INCREF(__pyx_4);
    Py_DECREF(__pyx_v_meth);
    __pyx_v_meth = __pyx_4;
    __pyx_4 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":168 */
    Py_DECREF(((PyObject (*))__pyx_v_tmp));

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":169 */
    /*try:*/ {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":170 */
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L13;}
      Py_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_obj);
      __pyx_2 = PyObject_CallObject(__pyx_v_meth, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L13;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":171 */
      __pyx_1 = __pyx_v_result != Py_None;
      if (__pyx_1) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":172 */
        Py_INCREF(__pyx_v_result);
        __pyx_r = __pyx_v_result;
        goto __pyx_L0;
        goto __pyx_L15;
      }
      __pyx_L15:;
    }
    goto __pyx_L14;
    __pyx_L13:;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":173 */
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    __pyx_1 = PyErr_ExceptionMatches(__pyx_4);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {
      __Pyx_AddTraceback("_speedups._adapt");
      __pyx_3 = __Pyx_GetExcValue(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":174 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_exc_info); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_tb_next); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_1 = __pyx_4 != Py_None;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (__pyx_1) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":175 */
        __Pyx_ReRaise();
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
        goto __pyx_L16;
      }
      __pyx_L16:;
      goto __pyx_L14;
    }
    goto __pyx_L1;
    __pyx_L14:;
    goto __pyx_L12;
  }
  __pyx_1 = PyErr_ExceptionMatches(PyExc_AttributeError);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":177 */
    PyErr_Clear();
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":179 */
    __pyx_3 = __Pyx_GetExcValue(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
    Py_DECREF(__pyx_v_err);
    __pyx_v_err = __pyx_3;
    __pyx_3 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":180 */
    __Pyx_ReRaise();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
  }
  __pyx_L12:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":182 */
  __pyx_1 = __pyx_v_default == __pyx_v_9_speedups__marker;
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":183 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_AdaptationFailure); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    Py_INCREF(__pyx_k28p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k28p);
    Py_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_obj);
    Py_INCREF(__pyx_v_protocol);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_protocol);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
    goto __pyx_L17;
  }
  __pyx_L17:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":185 */
  Py_INCREF(__pyx_v_default);
  __pyx_r = __pyx_v_default;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_speedups._adapt");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_meth);
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_err);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  Py_DECREF(__pyx_v_default);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_adapt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9_speedups_adapt[] = "PEP 246-alike: Adapt \'obj\' to \'protocol\', return \'default\'\n\n    If \'default\' is not supplied and no implementation is found,\n    raise \'AdaptationFailure\'.";
static PyObject *__pyx_f_9_speedups_adapt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_protocol = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"obj","protocol","default",0};
  __pyx_v_default = __pyx_k21;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_obj, &__pyx_v_protocol, &__pyx_v_default)) return 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);
  Py_INCREF(__pyx_v_default);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":194 */
  __pyx_1 = __pyx_f_9_speedups__adapt(__pyx_v_obj,__pyx_v_protocol,__pyx_v_default); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_speedups.adapt");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  Py_DECREF(__pyx_v_default);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_Protocol__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9_speedups_Protocol__call__[] = "Adapt to this protocol";
static PyObject *__pyx_f_9_speedups_Protocol__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_ob = 0;
  PyObject *__pyx_v_default = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"self","ob","default",0};
  __pyx_v_default = __pyx_k22;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_self, &__pyx_v_ob, &__pyx_v_default)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_default);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":198 */
  __pyx_1 = __pyx_f_9_speedups__adapt(__pyx_v_ob,__pyx_v_self,__pyx_v_default); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_speedups.Protocol__call__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_default);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_buildClassicMRO(PyClassObject (*__pyx_v_cls),PyListObject (*__pyx_v_list)) {
  PyTupleObject (*__pyx_v_bases);
  int __pyx_v_i;
  PyObject *__pyx_v_tmp;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  __pyx_v_tmp = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":211 */
  __pyx_1 = (PyObject *)__pyx_v_cls;
  Py_INCREF(__pyx_1);
  __pyx_2 = PyList_Append(__pyx_v_list,__pyx_1); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":212 */
  __pyx_v_bases = __pyx_v_cls->cl_bases;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":214 */
  __pyx_2 = (__pyx_v_bases != 0);
  if (__pyx_2) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":215 */
    __pyx_2 = PyTuple_GET_SIZE(__pyx_v_bases);
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":216 */
      __pyx_1 = (PyObject *)PyTuple_GET_ITEM(__pyx_v_bases,__pyx_v_i);
      Py_INCREF(__pyx_1);
      Py_DECREF(__pyx_v_tmp);
      __pyx_v_tmp = __pyx_1;
      __pyx_1 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":217 */
      __pyx_1 = __pyx_f_9_speedups_buildClassicMRO(((PyClassObject (*))__pyx_v_tmp),__pyx_v_list); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_speedups.buildClassicMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_tmp);
  return __pyx_r;
}

static PyObject *__pyx_k29p;

static char (__pyx_k29[]) = "Not a classic class";

static PyObject *__pyx_f_9_speedups_classicMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9_speedups_classicMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ob = 0;
  PyObject *__pyx_v_extendedClassic = 0;
  PyObject *__pyx_v_mro;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"ob","extendedClassic",0};
  __pyx_v_extendedClassic = __pyx_k23;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_ob, &__pyx_v_extendedClassic)) return 0;
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_extendedClassic);
  __pyx_v_mro = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":222 */
  __pyx_1 = PyClass_Check(__pyx_v_ob);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":223 */
    __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
    Py_DECREF(__pyx_v_mro);
    __pyx_v_mro = __pyx_2;
    __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":224 */
    __pyx_2 = __pyx_f_9_speedups_buildClassicMRO(((PyClassObject (*))__pyx_v_ob),((PyListObject (*))__pyx_v_mro)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":225 */
    __pyx_1 = PyObject_IsTrue(__pyx_v_extendedClassic); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":226 */
      __pyx_2 = (PyObject *)(&PyInstance_Type);
      Py_INCREF(__pyx_2);
      __pyx_1 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_2); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":227 */
      __pyx_2 = (PyObject *)(&PyBaseObject_Type);
      Py_INCREF(__pyx_2);
      __pyx_1 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_2); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":228 */
    Py_INCREF(__pyx_v_mro);
    __pyx_r = __pyx_v_mro;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":230 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_INCREF(__pyx_k29p);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k29p);
  Py_INCREF(__pyx_v_ob);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_ob);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_4, 0, 0);
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_speedups.classicMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_mro);
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_extendedClassic);
  return __pyx_r;
}

static PyObject *__pyx_n___bases__;

static PyObject *__pyx_f_9_speedups_buildECMRO(PyObject *__pyx_v_cls,PyListObject (*__pyx_v_list)) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_cls);
  __pyx_v_i = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":248 */
  __pyx_1 = PyList_Append(__pyx_v_list,__pyx_v_cls); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;}

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":249 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_cls, __pyx_n___bases__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  for (;;) {
    __pyx_2 = PyIter_Next(__pyx_3);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_2;
    __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":250 */
    __pyx_2 = __pyx_f_9_speedups_buildECMRO(__pyx_v_i,__pyx_v_list); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_speedups.buildECMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_cls);
  return __pyx_r;
}

static PyObject *__pyx_f_9_speedups_extClassMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9_speedups_extClassMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ob = 0;
  PyObject *__pyx_v_extendedClassic = 0;
  PyObject *__pyx_v_mro;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"ob","extendedClassic",0};
  __pyx_v_extendedClassic = __pyx_k24;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_ob, &__pyx_v_extendedClassic)) return 0;
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_extendedClassic);
  __pyx_v_mro = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":254 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;}
  Py_DECREF(__pyx_v_mro);
  __pyx_v_mro = __pyx_1;
  __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":255 */
  __pyx_1 = __pyx_f_9_speedups_buildECMRO(__pyx_v_ob,((PyListObject (*))__pyx_v_mro)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":256 */
  __pyx_2 = PyObject_IsTrue(__pyx_v_extendedClassic); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
  if (__pyx_2) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":257 */
    __pyx_1 = (PyObject *)(&PyInstance_Type);
    Py_INCREF(__pyx_1);
    __pyx_2 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_1); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":258 */
    __pyx_1 = (PyObject *)(&PyBaseObject_Type);
    Py_INCREF(__pyx_1);
    __pyx_2 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_1); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":259 */
  Py_INCREF(__pyx_v_mro);
  __pyx_r = __pyx_v_mro;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_speedups.extClassMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_mro);
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_extendedClassic);
  return __pyx_r;
}

static PyObject *__pyx_n___mro__;

static PyObject *__pyx_f_9_speedups_getMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9_speedups_getMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ob = 0;
  PyObject *__pyx_v_extendedClassic = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"ob","extendedClassic",0};
  __pyx_v_extendedClassic = __pyx_k25;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_ob, &__pyx_v_extendedClassic)) return 0;
  Py_INCREF(__pyx_v_ob);
  Py_INCREF(__pyx_v_extendedClassic);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":265 */
  __pyx_1 = PyClass_Check(__pyx_v_ob);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":266 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_classicMRO); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
    Py_INCREF(__pyx_v_ob);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_ob);
    Py_INCREF(__pyx_v_extendedClassic);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_extendedClassic);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = PyType_Check(__pyx_v_ob);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":269 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_ob, __pyx_n___mro__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = PyObject_TypeCheck(__pyx_v_ob,__pyx_v_9_speedups___ECType);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":272 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_extClassMRO); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
    Py_INCREF(__pyx_v_ob);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_ob);
    Py_INCREF(__pyx_v_extendedClassic);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_extendedClassic);
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":274 */
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_INCREF(__pyx_v_ob);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_ob);
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_speedups.getMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_extendedClassic);
  return __pyx_r;
}

static PyObject *__pyx_n__Protocol__adapters;
static PyObject *__pyx_n_get;

static PyObject *__pyx_f_9_speedups_Protocol__adapt__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9_speedups_Protocol__adapt__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_obj = 0;
  void (*__pyx_v_tmp);
  int __pyx_v_i;
  PyObject *__pyx_v_cls;
  PyObject *__pyx_v_err;
  PyObject *__pyx_v_mro;
  PyObject *__pyx_v_get;
  PyObject *__pyx_v_factory;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"self","obj",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_self, &__pyx_v_obj)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_obj);
  __pyx_v_cls = Py_None; Py_INCREF(Py_None);
  __pyx_v_err = Py_None; Py_INCREF(Py_None);
  __pyx_v_mro = Py_None; Py_INCREF(Py_None);
  __pyx_v_get = Py_None; Py_INCREF(Py_None);
  __pyx_v_factory = Py_None; Py_INCREF(Py_None);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":293 */
  __pyx_1 = PyInstance_Check(__pyx_v_obj);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":294 */
    __pyx_2 = (PyObject *)((PyInstanceObject (*))__pyx_v_obj)->in_class;
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_cls);
    __pyx_v_cls = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":297 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n___class); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;}
    __pyx_v_tmp = PyObject_GetAttr(__pyx_v_obj,__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":299 */
    __pyx_1 = (__pyx_v_tmp != 0);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":300 */
      __pyx_2 = (PyObject *)__pyx_v_tmp;
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":301 */
      Py_DECREF(((PyObject (*))__pyx_v_tmp));
      goto __pyx_L3;
    }
    __pyx_1 = PyErr_ExceptionMatches(PyExc_AttributeError);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":305 */
      PyErr_Clear();

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":306 */
      __pyx_2 = (PyObject *)((PyObject (*))__pyx_v_obj)->ob_type;
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":310 */
      __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
      Py_DECREF(__pyx_v_err);
      __pyx_v_err = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":311 */
      __Pyx_ReRaise();
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;}
    }
    __pyx_L3:;
  }
  __pyx_L2:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":313 */
  __pyx_v_tmp = ((void (*))0);

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":315 */
  __pyx_1 = PyType_Check(__pyx_v_cls);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":317 */
    __pyx_v_tmp = ((void (*))((PyTypeObject (*))__pyx_v_cls)->tp_mro);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":329 */
  __pyx_1 = (__pyx_v_tmp != 0);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":330 */
    __pyx_2 = (PyObject *)__pyx_v_tmp;
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_mro);
    __pyx_v_mro = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L5;
  }
  __pyx_1 = PyClass_Check(__pyx_v_cls);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":334 */
    __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}
    Py_DECREF(__pyx_v_mro);
    __pyx_v_mro = __pyx_2;
    __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":335 */
    __pyx_2 = __pyx_f_9_speedups_buildClassicMRO(((PyClassObject (*))__pyx_v_cls),((PyListObject (*))__pyx_v_mro)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":336 */
    __pyx_2 = (PyObject *)(&PyInstance_Type);
    Py_INCREF(__pyx_2);
    __pyx_1 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_2); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":337 */
    __pyx_2 = (PyObject *)(&PyBaseObject_Type);
    Py_INCREF(__pyx_2);
    __pyx_1 = PyList_Append(((PyListObject (*))__pyx_v_mro),__pyx_2); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":341 */
    __pyx_v_tmp = PyObject_GetAttr(__pyx_v_cls,__pyx_v_9_speedups___mro);

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":342 */
    __pyx_1 = (__pyx_v_tmp != 0);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":343 */
      __pyx_2 = (PyObject *)__pyx_v_tmp;
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_v_mro);
      __pyx_v_mro = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":344 */
      Py_DECREF(((PyObject (*))__pyx_v_tmp));
      goto __pyx_L6;
    }
    __pyx_1 = PyObject_TypeCheck(__pyx_v_cls,__pyx_v_9_speedups___ECType);
    if (__pyx_1) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":349 */
      PyErr_Clear();

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":350 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_extClassMRO); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
      __pyx_3 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_mro);
      __pyx_v_mro = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":355 */
      __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; goto __pyx_L1;}
      Py_DECREF(__pyx_v_err);
      __pyx_v_err = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":356 */
      __Pyx_ReRaise();
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;}
    }
    __pyx_L6:;
  }
  __pyx_L5:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":370 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n__Protocol__adapters); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_v_get);
  __pyx_v_get = __pyx_3;
  __pyx_3 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":372 */
  __pyx_1 = PyTuple_Check(__pyx_v_mro);
  if (__pyx_1) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":374 */
    __pyx_1 = PyTuple_GET_SIZE(((PyTupleObject (*))__pyx_v_mro));
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":375 */
      __pyx_2 = (PyObject *)PyTuple_GET_ITEM(((PyTupleObject (*))__pyx_v_mro),__pyx_v_i);
      Py_INCREF(__pyx_2);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":376 */
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_cls);
      __pyx_3 = PyObject_CallObject(__pyx_v_get, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_3;
      __pyx_3 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":377 */
      __pyx_5 = __pyx_v_factory != Py_None;
      if (__pyx_5) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":378 */
        __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_v_factory, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
        Py_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_obj);
        __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_r = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L0;
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
    goto __pyx_L7;
  }
  __pyx_5 = PyList_Check(__pyx_v_mro);
  if (__pyx_5) {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":382 */
    __pyx_1 = PyList_GET_SIZE(((PyListObject (*))__pyx_v_mro));
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":383 */
      __pyx_4 = (PyObject *)PyList_GET_ITEM(((PyListObject (*))__pyx_v_mro),__pyx_v_i);
      Py_INCREF(__pyx_4);
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_4;
      __pyx_4 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":384 */
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cls);
      __pyx_2 = PyObject_CallObject(__pyx_v_get, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":385 */
      __pyx_5 = __pyx_v_factory != Py_None;
      if (__pyx_5) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":386 */
        __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}
        __pyx_3 = PyObject_GetItem(__pyx_v_factory, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}
        Py_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_obj);
        __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_r = __pyx_4;
        __pyx_4 = 0;
        goto __pyx_L0;
        goto __pyx_L13;
      }
      __pyx_L13:;
    }
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":391 */
    __pyx_3 = PyObject_GetIter(__pyx_v_mro); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    for (;;) {
      __pyx_2 = PyIter_Next(__pyx_3);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":392 */
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_cls);
      __pyx_2 = PyObject_CallObject(__pyx_v_get, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_2;
      __pyx_2 = 0;

      /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":393 */
      __pyx_5 = __pyx_v_factory != Py_None;
      if (__pyx_5) {

        /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":394 */
        __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_2 = PyObject_GetItem(__pyx_v_factory, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
        Py_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_obj);
        __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_r = __pyx_6;
        __pyx_6 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        goto __pyx_L0;
        goto __pyx_L16;
      }
      __pyx_L16:;
    }
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L7:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_speedups.Protocol__adapt__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_cls);
  Py_DECREF(__pyx_v_err);
  Py_DECREF(__pyx_v_mro);
  Py_DECREF(__pyx_v_get);
  Py_DECREF(__pyx_v_factory);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_AdaptationFailure, "AdaptationFailure"},
  {&__pyx_n_AttributeError, "AttributeError"},
  {&__pyx_n_DOES_NOT_SUPPORT, "DOES_NOT_SUPPORT"},
  {&__pyx_n_ExtensionClass, "ExtensionClass"},
  {&__pyx_n_False, "False"},
  {&__pyx_n_ImportError, "ImportError"},
  {&__pyx_n_NO_ADAPTER_NEEDED, "NO_ADAPTER_NEEDED"},
  {&__pyx_n_Protocol__adapt__, "Protocol__adapt__"},
  {&__pyx_n_Protocol__call__, "Protocol__call__"},
  {&__pyx_n_TypeError, "TypeError"},
  {&__pyx_n__Protocol__adapters, "_Protocol__adapters"},
  {&__pyx_n___all__, "__all__"},
  {&__pyx_n___bases__, "__bases__"},
  {&__pyx_n___class, "__class"},
  {&__pyx_n___mro__, "__mro__"},
  {&__pyx_n_adapt, "adapt"},
  {&__pyx_n_classicMRO, "classicMRO"},
  {&__pyx_n_exc_info, "exc_info"},
  {&__pyx_n_extClassMRO, "extClassMRO"},
  {&__pyx_n_get, "get"},
  {&__pyx_n_getMRO, "getMRO"},
  {&__pyx_n_metamethod, "metamethod"},
  {&__pyx_n_object, "object"},
  {&__pyx_n_sys, "sys"},
  {&__pyx_n_tb_next, "tb_next"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)},
  {&__pyx_k27p, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_k28p, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)},
  {0, 0, 0}
};

static PyObject *__pyx_tp_new_9_speedups_metamethod(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_9_speedups_metamethod *p = (struct __pyx_obj_9_speedups_metamethod *)o;
  p->func = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_9_speedups_metamethod(PyObject *o) {
  struct __pyx_obj_9_speedups_metamethod *p = (struct __pyx_obj_9_speedups_metamethod *)o;
  Py_XDECREF(p->func);
  (*o->ob_type->tp_free)(o);
}

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

static int __pyx_tp_clear_9_speedups_metamethod(PyObject *o) {
  struct __pyx_obj_9_speedups_metamethod *p = (struct __pyx_obj_9_speedups_metamethod *)o;
  Py_XDECREF(p->func);
  p->func = Py_None; Py_INCREF(Py_None);
  return 0;
}

static PyObject *__pyx_tp_descr_get_9_speedups_metamethod(PyObject *o, PyObject *i, PyObject *c) {
  PyObject *r = 0;
  if (!i) i = Py_None;
  if (!c) c = Py_None;
  r = __pyx_f_9_speedups_10metamethod___get__(o, i, c);
  return r;
}

static int __pyx_tp_descr_set_9_speedups_metamethod(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_f_9_speedups_10metamethod___set__(o, i, v);
  }
  else {
    return __pyx_f_9_speedups_10metamethod___delete__(o, i);
  }
}

static struct PyMethodDef __pyx_methods_9_speedups_metamethod[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_metamethod = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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*/
};

static PySequenceMethods __pyx_tp_as_sequence_metamethod = {
  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_metamethod = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_metamethod = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_9_speedups_metamethod = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_speedups.metamethod", /*tp_name*/
  sizeof(struct __pyx_obj_9_speedups_metamethod), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9_speedups_metamethod, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_metamethod, /*tp_as_number*/
  &__pyx_tp_as_sequence_metamethod, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_metamethod, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_metamethod, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Wrapper for metaclass method that might be confused w/instance method", /*tp_doc*/
  __pyx_tp_traverse_9_speedups_metamethod, /*tp_traverse*/
  __pyx_tp_clear_9_speedups_metamethod, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9_speedups_metamethod, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  __pyx_tp_descr_get_9_speedups_metamethod, /*tp_descr_get*/
  __pyx_tp_descr_set_9_speedups_metamethod, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_9_speedups_10metamethod___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9_speedups_metamethod, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"NO_ADAPTER_NEEDED", (PyCFunction)__pyx_f_9_speedups_NO_ADAPTER_NEEDED, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9_speedups_NO_ADAPTER_NEEDED},
  {"DOES_NOT_SUPPORT", (PyCFunction)__pyx_f_9_speedups_DOES_NOT_SUPPORT, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9_speedups_DOES_NOT_SUPPORT},
  {"adapt", (PyCFunction)__pyx_f_9_speedups_adapt, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9_speedups_adapt},
  {"Protocol__call__", (PyCFunction)__pyx_f_9_speedups_Protocol__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9_speedups_Protocol__call__},
  {"classicMRO", (PyCFunction)__pyx_f_9_speedups_classicMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"extClassMRO", (PyCFunction)__pyx_f_9_speedups_extClassMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"getMRO", (PyCFunction)__pyx_f_9_speedups_getMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"Protocol__adapt__", (PyCFunction)__pyx_f_9_speedups_Protocol__adapt__, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_speedups(void); /*proto*/
PyMODINIT_FUNC init_speedups(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_speedups", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_v_9_speedups__marker = Py_None; Py_INCREF(Py_None);
  __pyx_v_9_speedups___conform = Py_None; Py_INCREF(Py_None);
  __pyx_v_9_speedups___adapt = Py_None; Py_INCREF(Py_None);
  __pyx_v_9_speedups___mro = Py_None; Py_INCREF(Py_None);
  __pyx_v_9_speedups___ECType = Py_None; Py_INCREF(Py_None);
  __pyx_type_9_speedups_metamethod.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_9_speedups_metamethod) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "metamethod", (PyObject *)&__pyx_type_9_speedups_metamethod) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
  __pyx_ptype_9_speedups_metamethod = &__pyx_type_9_speedups_metamethod;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":3 */
  __pyx_1 = PyList_New(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
  Py_INCREF(__pyx_n_NO_ADAPTER_NEEDED);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_NO_ADAPTER_NEEDED);
  Py_INCREF(__pyx_n_DOES_NOT_SUPPORT);
  PyList_SET_ITEM(__pyx_1, 1, __pyx_n_DOES_NOT_SUPPORT);
  Py_INCREF(__pyx_n_adapt);
  PyList_SET_ITEM(__pyx_1, 2, __pyx_n_adapt);
  Py_INCREF(__pyx_n_Protocol__adapt__);
  PyList_SET_ITEM(__pyx_1, 3, __pyx_n_Protocol__adapt__);
  Py_INCREF(__pyx_n_metamethod);
  PyList_SET_ITEM(__pyx_1, 4, __pyx_n_metamethod);
  Py_INCREF(__pyx_n_classicMRO);
  PyList_SET_ITEM(__pyx_1, 5, __pyx_n_classicMRO);
  Py_INCREF(__pyx_n_getMRO);
  PyList_SET_ITEM(__pyx_1, 6, __pyx_n_getMRO);
  Py_INCREF(__pyx_n_Protocol__call__);
  PyList_SET_ITEM(__pyx_1, 7, __pyx_n_Protocol__call__);
  if (PyObject_SetAttr(__pyx_m, __pyx_n___all__, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":64 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_INCREF(__pyx_n_exc_info);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_exc_info);
  __pyx_2 = __Pyx_Import(__pyx_n_sys, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_exc_info, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":65 */
  __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  Py_INCREF(__pyx_n_AdaptationFailure);
  PyList_SET_ITEM(__pyx_2, 0, __pyx_n_AdaptationFailure);
  __pyx_1 = __Pyx_Import(__pyx_k11p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_AdaptationFailure); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_AdaptationFailure, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":67 */
  /*try:*/ {

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":68 */
    __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L17;}
    Py_INCREF(__pyx_n_ExtensionClass);
    PyList_SET_ITEM(__pyx_1, 0, __pyx_n_ExtensionClass);
    __pyx_2 = __Pyx_Import(__pyx_n_ExtensionClass, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L17;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_ExtensionClass); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L17;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_ExtensionClass, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L17;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":69 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_ExtensionClass); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L17;}
    Py_DECREF(__pyx_v_9_speedups___ECType);
    __pyx_v_9_speedups___ECType = __pyx_2;
    __pyx_2 = 0;
  }
  goto __pyx_L18;
  __pyx_L17:;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":70 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ImportError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_3 = PyErr_ExceptionMatches(__pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_3) {
    __Pyx_AddTraceback("_speedups");
    __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":71 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_object); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
    __pyx_2 = PyObject_Type(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_9_speedups___ECType);
    __pyx_v_9_speedups___ECType = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L18;
  }
  goto __pyx_L1;
  __pyx_L18:;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":73 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_object); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_9_speedups__marker);
  __pyx_v_9_speedups__marker = __pyx_2;
  __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":74 */
  __pyx_1 = PyString_InternFromString(__pyx_k15); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9_speedups___conform);
  __pyx_v_9_speedups___conform = __pyx_1;
  __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":75 */
  __pyx_2 = PyString_InternFromString(__pyx_k16); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9_speedups___adapt);
  __pyx_v_9_speedups___adapt = __pyx_2;
  __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":76 */
  __pyx_1 = PyString_InternFromString(__pyx_k17); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n___class, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":77 */
  __pyx_2 = PyString_InternFromString(__pyx_k18); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9_speedups___mro);
  __pyx_v_9_speedups___mro = __pyx_2;
  __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":85 */
  Py_INCREF(Py_None);
  __pyx_k19 = Py_None;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":89 */
  Py_INCREF(Py_None);
  __pyx_k20 = Py_None;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":188 */
  Py_INCREF(__pyx_v_9_speedups__marker);
  __pyx_k21 = __pyx_v_9_speedups__marker;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":196 */
  Py_INCREF(__pyx_v_9_speedups__marker);
  __pyx_k22 = __pyx_v_9_speedups__marker;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":220 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  __pyx_k23 = __pyx_1;
  __pyx_1 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":253 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_k24 = __pyx_2;
  __pyx_2 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":263 */
  __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;}
  __pyx_k25 = __pyx_4;
  __pyx_4 = 0;

  /* "/home/pje/projects/PyProtocols/src/protocols/_speedups.pyx":288 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_speedups");
}

static char *__pyx_filenames[] = {
  "_speedups.pyx",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static PyObject *__Pyx_GetExcValue(void) {
    PyObject *type = 0, *value = 0, *tb = 0;
    PyObject *result = 0;
    PyThreadState *tstate = PyThreadState_Get();
    PyErr_Fetch(&type, &value, &tb);
    PyErr_NormalizeException(&type, &value, &tb);
    if (PyErr_Occurred())
        goto bad;
    if (!value) {
        value = Py_None;
        Py_INCREF(value);
    }
    Py_XDECREF(tstate->exc_type);
    Py_XDECREF(tstate->exc_value);
    Py_XDECREF(tstate->exc_traceback);
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    result = value;
    Py_XINCREF(result);
    type = 0;
    value = 0;
    tb = 0;
bad:
    Py_XDECREF(type);
    Py_XDECREF(value);
    Py_XDECREF(tb);
    return result;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    /* Next, repeatedly, replace a tuple exception with its first item */
    while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {
        PyObject *tmp = type;
        type = PyTuple_GET_ITEM(type, 0);
        Py_INCREF(type);
        Py_DECREF(tmp);
    }
    if (PyString_Check(type)) {
        if (PyErr_Warn(PyExc_DeprecationWarning,
                "raising a string exception is deprecated"))
            goto raise_error;
    }
    else if (PyType_Check(type) || PyClass_Check(type))
        ; /*PyErr_NormalizeException(&type, &value, &tb);*/
    else {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        if (PyInstance_Check(type))
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
        else
            type = (PyObject*) type->ob_type;
        Py_INCREF(type);
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static void __Pyx_ReRaise(void) {
    PyThreadState *tstate = PyThreadState_Get();
    PyObject *type = tstate->exc_type;
    PyObject *value = tstate->exc_value;
    PyObject *tb = tstate->exc_traceback;
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    PyErr_Restore(type, value, tb);
}

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
    while (t->p) {
        *t->p = PyString_InternFromString(t->s);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) 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 = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
