/* Generated by Pyrex 0.9.8.3 on Thu Jan 15 20:27:10 2009 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#ifndef WIN32
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>


typedef struct {PyObject **p; int i; 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_GetName(PyObject *dict, PyObject *name); /*proto*/

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

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

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/

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

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

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

/* Declarations from enthought.traits.protocols._speedups */


/* Declarations from implementation of enthought.traits.protocols._speedups */

struct __pyx_obj_9enthought_6traits_9protocols_9_speedups_metamethod {
  PyObject_HEAD
  PyObject *func;
};


static PyTypeObject *__pyx_ptype_9enthought_6traits_9protocols_9_speedups_metamethod = 0;
static PyObject *__pyx_v_9enthought_6traits_9protocols_9_speedups__marker;
static PyObject *__pyx_v_9enthought_6traits_9protocols_9_speedups___conform;
static PyObject *__pyx_v_9enthought_6traits_9protocols_9_speedups___adapt;
static PyObject *__pyx_v_9enthought_6traits_9protocols_9_speedups___mro;
static PyObject *__pyx_v_9enthought_6traits_9protocols_9_speedups___ECType;
static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups__adapt(PyObject *,PyObject *,PyObject *,PyObject *); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_buildClassicMRO(PyClassObject *,PyListObject *); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_buildECMRO(PyObject *,PyListObject *); /*proto*/

static char __pyx_k1[] = "AttributeError";
static char __pyx_k2[] = "Read-only attribute";
static char __pyx_k3[] = "exc_info";
static char __pyx_k4[] = "tb_next";
static char __pyx_k5[] = "exc_clear";
static char __pyx_k6[] = "warnings";
static char __pyx_k7[] = "warn";
static char __pyx_k8[] = "The 'factory' argument to 'adapt()' will be removed in 1.0";
static char __pyx_k9[] = "AdaptationFailure";
static char __pyx_k10[] = "Can't adapt";
static char __pyx_k11[] = "Not a classic class";
static char __pyx_k12[] = "__bases__";
static char __pyx_k13[] = "classicMRO";
static char __pyx_k14[] = "__mro__";
static char __pyx_k15[] = "extClassMRO";
static char __pyx_k16[] = "__class";
static char __pyx_k17[] = "_Protocol__adapters";
static char __pyx_k18[] = "get";
static char __pyx_k19[] = "NO_ADAPTER_NEEDED";
static char __pyx_k20[] = "DOES_NOT_SUPPORT";
static char __pyx_k21[] = "adapt";
static char __pyx_k22[] = "Protocol__adapt__";
static char __pyx_k23[] = "metamethod";
static char __pyx_k24[] = "getMRO";
static char __pyx_k25[] = "Protocol__call__";
static char __pyx_k26[] = "__all__";
static char __pyx_k27[] = "sys";
static char __pyx_k28[] = "adapters";
static char __pyx_k29[] = "ExtensionClass";
static char __pyx_k30[] = "object";
static char __pyx_k31[] = "__conform__";
static char __pyx_k32[] = "__adapt__";
static char __pyx_k33[] = "__class__";

static PyObject *__pyx_n_AdaptationFailure;
static PyObject *__pyx_n_AttributeError;
static PyObject *__pyx_n_DOES_NOT_SUPPORT;
static PyObject *__pyx_n_ExtensionClass;
static PyObject *__pyx_n_NO_ADAPTER_NEEDED;
static PyObject *__pyx_n_Protocol__adapt__;
static PyObject *__pyx_n_Protocol__call__;
static PyObject *__pyx_n__Protocol__adapters;
static PyObject *__pyx_n___all__;
static PyObject *__pyx_n___bases__;
static PyObject *__pyx_n___class;
static PyObject *__pyx_n___mro__;
static PyObject *__pyx_n_adapt;
static PyObject *__pyx_n_adapters;
static PyObject *__pyx_n_classicMRO;
static PyObject *__pyx_n_exc_clear;
static PyObject *__pyx_n_exc_info;
static PyObject *__pyx_n_extClassMRO;
static PyObject *__pyx_n_get;
static PyObject *__pyx_n_getMRO;
static PyObject *__pyx_n_metamethod;
static PyObject *__pyx_n_object;
static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_tb_next;
static PyObject *__pyx_n_warn;
static PyObject *__pyx_n_warnings;

static PyObject *__pyx_k2p;
static PyObject *__pyx_k8p;
static PyObject *__pyx_k10p;
static PyObject *__pyx_k11p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_AdaptationFailure, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_n_AttributeError, 1, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_n_DOES_NOT_SUPPORT, 1, __pyx_k20, sizeof(__pyx_k20)},
  {&__pyx_n_ExtensionClass, 1, __pyx_k29, sizeof(__pyx_k29)},
  {&__pyx_n_NO_ADAPTER_NEEDED, 1, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_n_Protocol__adapt__, 1, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_n_Protocol__call__, 1, __pyx_k25, sizeof(__pyx_k25)},
  {&__pyx_n__Protocol__adapters, 1, __pyx_k17, sizeof(__pyx_k17)},
  {&__pyx_n___all__, 1, __pyx_k26, sizeof(__pyx_k26)},
  {&__pyx_n___bases__, 1, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_n___class, 1, __pyx_k16, sizeof(__pyx_k16)},
  {&__pyx_n___mro__, 1, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_n_adapt, 1, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_n_adapters, 1, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_n_classicMRO, 1, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_n_exc_clear, 1, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_n_exc_info, 1, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_n_extClassMRO, 1, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_n_get, 1, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_n_getMRO, 1, __pyx_k24, sizeof(__pyx_k24)},
  {&__pyx_n_metamethod, 1, __pyx_k23, sizeof(__pyx_k23)},
  {&__pyx_n_object, 1, __pyx_k30, sizeof(__pyx_k30)},
  {&__pyx_n_sys, 1, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_n_tb_next, 1, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_n_warn, 1, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_n_warnings, 1, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k2p, 0, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k8p, 0, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_k10p, 0, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)},
  {0, 0, 0, 0}
};

static PyObject *__pyx_d1;
static PyObject *__pyx_d2;
static PyObject *__pyx_d3;
static PyObject *__pyx_d4;
static PyObject *__pyx_d5;
static PyObject *__pyx_d6;
static PyObject *__pyx_d7;
static PyObject *__pyx_d8;


/* Implementation of enthought.traits.protocols._speedups */

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_NO_ADAPTER_NEEDED(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9enthought_6traits_9protocols_9_speedups_NO_ADAPTER_NEEDED[] = "Assume \'obj\' implements \'protocol\' directly";
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_d1;
  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);
  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_9enthought_6traits_9protocols_9_speedups_DOES_NOT_SUPPORT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9enthought_6traits_9protocols_9_speedups_DOES_NOT_SUPPORT[] = "Prevent \'obj\' from supporting \'protocol\'";
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_d2;
  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);
  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_9enthought_6traits_9protocols_9_speedups_10metamethod___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_9enthought_6traits_9protocols_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);
  Py_INCREF(__pyx_v_func);
  Py_DECREF(((struct __pyx_obj_9enthought_6traits_9protocols_9_speedups_metamethod *)__pyx_v_self)->func);
  ((struct __pyx_obj_9enthought_6traits_9protocols_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_9enthought_6traits_9protocols_9_speedups_10metamethod___get__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_typ); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":103 */
  __pyx_1 = __pyx_v_ob == Py_None;
  if (__pyx_1) {
    Py_INCREF(__pyx_v_self);
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":105 */
  __pyx_2 = PyMethod_New(((struct __pyx_obj_9enthought_6traits_9protocols_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("enthought.traits.protocols._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 int __pyx_f_9enthought_6traits_9protocols_9_speedups_10metamethod___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob, PyObject *__pyx_v_value); /*proto*/
static int __pyx_f_9enthought_6traits_9protocols_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);
  __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_k2p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k2p);
  __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("enthought.traits.protocols._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 int __pyx_f_9enthought_6traits_9protocols_9_speedups_10metamethod___delete__(PyObject *__pyx_v_self, PyObject *__pyx_v_ob); /*proto*/
static int __pyx_f_9enthought_6traits_9protocols_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);
  __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_k2p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k2p);
  __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("enthought.traits.protocols._speedups.metamethod.__delete__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_ob);
  return __pyx_r;
}

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups__adapt(PyObject *__pyx_v_obj,PyObject *__pyx_v_protocol,PyObject *__pyx_v_default,PyObject *__pyx_v_factory) {
  PyObject *__pyx_v_meth;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_warn;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);
  Py_INCREF(__pyx_v_default);
  Py_INCREF(__pyx_v_factory);
  __pyx_v_meth = Py_None; Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_e = Py_None; Py_INCREF(Py_None);
  __pyx_v_warn = Py_None; Py_INCREF(Py_None);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":142 */
  __pyx_1 = PyObject_IsInstance(__pyx_v_obj,__pyx_v_protocol);
  if (__pyx_1) {
    Py_INCREF(__pyx_v_obj);
    __pyx_r = __pyx_v_obj;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":145 */
  /*try:*/ {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":146 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_obj,__pyx_v_9enthought_6traits_9protocols_9_speedups___conform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; goto __pyx_L3;}
    Py_DECREF(__pyx_v_meth);
    __pyx_v_meth = __pyx_2;
    __pyx_2 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":147 */
    /*try:*/ {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":148 */
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; goto __pyx_L5;}
      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 = 148; goto __pyx_L5;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_3;
      __pyx_3 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":149 */
      __pyx_1 = __pyx_v_result != Py_None;
      if (__pyx_1) {
        Py_INCREF(__pyx_v_result);
        __pyx_r = __pyx_v_result;
        goto __pyx_L0;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    goto __pyx_L6;
    __pyx_L5:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":151 */
    __pyx_1 = PyErr_ExceptionMatches(PyExc_TypeError);
    if (__pyx_1) {
      __Pyx_AddTraceback("enthought.traits.protocols._speedups._adapt");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L3;}
      Py_INCREF(__pyx_3);
      Py_DECREF(__pyx_v_e);
      __pyx_v_e = __pyx_3;
      __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_exc_info); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L3;}
      __pyx_6 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L3;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_5 = __Pyx_GetItemInt(__pyx_6, 2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L3;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_tb_next); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L3;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_1 = __pyx_6 != Py_None;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      if (__pyx_1) {
        __Pyx_Raise(__pyx_2, __pyx_3, __pyx_4);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; goto __pyx_L3;}
        goto __pyx_L8;
      }
      __pyx_L8:;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L6;
    }
    goto __pyx_L3;
    __pyx_L6:;
  }
  goto __pyx_L4;
  __pyx_L3:;
  Py_XDECREF(__pyx_5); __pyx_5 = 0;
  Py_XDECREF(__pyx_6); __pyx_6 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_4); __pyx_4 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":154 */
  __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_AttributeError); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; goto __pyx_L1;}
  __pyx_1 = PyErr_ExceptionMatches(__pyx_5);
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_1) {
    __Pyx_AddTraceback("enthought.traits.protocols._speedups._adapt");
    if (__Pyx_GetException(&__pyx_6, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; goto __pyx_L1;}
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_e);
    __pyx_v_e = __pyx_2;
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_exc_clear); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L4;
  }
  goto __pyx_L1;
  __pyx_L4:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":160 */
  /*try:*/ {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":161 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_protocol,__pyx_v_9enthought_6traits_9protocols_9_speedups___adapt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L9;}
    Py_DECREF(__pyx_v_meth);
    __pyx_v_meth = __pyx_4;
    __pyx_4 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":162 */
    /*try:*/ {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":163 */
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L11;}
      Py_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_obj);
      __pyx_6 = PyObject_CallObject(__pyx_v_meth, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L11;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_6;
      __pyx_6 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":164 */
      __pyx_1 = __pyx_v_result != Py_None;
      if (__pyx_1) {
        Py_INCREF(__pyx_v_result);
        __pyx_r = __pyx_v_result;
        goto __pyx_L0;
        goto __pyx_L13;
      }
      __pyx_L13:;
    }
    goto __pyx_L12;
    __pyx_L11:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;
    Py_XDECREF(__pyx_4); __pyx_4 = 0;
    Py_XDECREF(__pyx_5); __pyx_5 = 0;
    Py_XDECREF(__pyx_6); __pyx_6 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":166 */
    __pyx_1 = PyErr_ExceptionMatches(PyExc_TypeError);
    if (__pyx_1) {
      __Pyx_AddTraceback("enthought.traits.protocols._speedups._adapt");
      if (__Pyx_GetException(&__pyx_2, &__pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L9;}
      __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_exc_info); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L9;}
      __pyx_6 = PyObject_CallObject(__pyx_5, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L9;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_5 = __Pyx_GetItemInt(__pyx_6, 2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L9;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_tb_next); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L9;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_1 = __pyx_6 != Py_None;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      if (__pyx_1) {
        __Pyx_Raise(__pyx_2, __pyx_3, __pyx_4);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L9;}
        goto __pyx_L14;
      }
      __pyx_L14:;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L12;
    }
    goto __pyx_L9;
    __pyx_L12:;
  }
  goto __pyx_L10;
  __pyx_L9:;
  Py_XDECREF(__pyx_5); __pyx_5 = 0;
  Py_XDECREF(__pyx_6); __pyx_6 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_4); __pyx_4 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":169 */
  __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_AttributeError); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
  __pyx_1 = PyErr_ExceptionMatches(__pyx_5);
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__pyx_1) {
    __Pyx_AddTraceback("enthought.traits.protocols._speedups._adapt");
    if (__Pyx_GetException(&__pyx_6, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    Py_INCREF(__pyx_2);
    Py_DECREF(__pyx_v_e);
    __pyx_v_e = __pyx_2;
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_exc_clear); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L10;
  }
  goto __pyx_L1;
  __pyx_L10:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":172 */
  __pyx_1 = __pyx_v_default == __pyx_v_9enthought_6traits_9protocols_9_speedups__marker;
  if (__pyx_1) {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":173 */
    __pyx_1 = __pyx_v_factory != __pyx_v_9enthought_6traits_9protocols_9_speedups__marker;
    if (__pyx_1) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":174 */
      __pyx_4 = PyList_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_INCREF(__pyx_n_warn);
      PyList_SET_ITEM(__pyx_4, 0, __pyx_n_warn);
      __pyx_5 = __Pyx_Import(__pyx_n_warnings, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_warn); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
      Py_DECREF(__pyx_v_warn);
      __pyx_v_warn = __pyx_6;
      __pyx_6 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":175 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
      Py_INCREF(__pyx_k8p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k8p);
      Py_INCREF(PyExc_DeprecationWarning);
      PyTuple_SET_ITEM(__pyx_3, 1, PyExc_DeprecationWarning);
      PyTuple_SET_ITEM(__pyx_3, 2, __pyx_2);
      __pyx_2 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_v_warn, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":177 */
      __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
      Py_INCREF(__pyx_v_obj);
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_obj);
      Py_INCREF(__pyx_v_protocol);
      PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_protocol);
      __pyx_6 = PyObject_CallObject(__pyx_v_factory, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L0;
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":178 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_AdaptationFailure); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
    Py_INCREF(__pyx_k10p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k10p);
    Py_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_obj);
    Py_INCREF(__pyx_v_protocol);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_protocol);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; 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 = 178; goto __pyx_L1;}
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":180 */
  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);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("enthought.traits.protocols._speedups._adapt");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_meth);
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_e);
  Py_DECREF(__pyx_v_warn);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  Py_DECREF(__pyx_v_default);
  Py_DECREF(__pyx_v_factory);
  return __pyx_r;
}

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_adapt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9enthought_6traits_9protocols_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_9enthought_6traits_9protocols_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_v_factory = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"obj","protocol","default","factory",0};
  __pyx_v_default = __pyx_d3;
  __pyx_v_factory = __pyx_d4;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|OO", __pyx_argnames, &__pyx_v_obj, &__pyx_v_protocol, &__pyx_v_default, &__pyx_v_factory)) return 0;
  Py_INCREF(__pyx_v_obj);
  Py_INCREF(__pyx_v_protocol);
  Py_INCREF(__pyx_v_default);
  Py_INCREF(__pyx_v_factory);
  __pyx_1 = __pyx_f_9enthought_6traits_9protocols_9_speedups__adapt(__pyx_v_obj,__pyx_v_protocol,__pyx_v_default,__pyx_v_factory); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; 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("enthought.traits.protocols._speedups.adapt");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_protocol);
  Py_DECREF(__pyx_v_default);
  Py_DECREF(__pyx_v_factory);
  return __pyx_r;
}

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_Protocol__call__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9enthought_6traits_9protocols_9_speedups_Protocol__call__[] = "Adapt to this protocol";
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_d5;
  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);
  __pyx_1 = __pyx_f_9enthought_6traits_9protocols_9_speedups__adapt(__pyx_v_ob,__pyx_v_self,__pyx_v_default,__pyx_v_9enthought_6traits_9protocols_9_speedups__marker); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; 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("enthought.traits.protocols._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_9enthought_6traits_9protocols_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  __pyx_v_tmp = Py_None; Py_INCREF(Py_None);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":201 */
  __pyx_1 = PyList_Append(__pyx_v_list,((PyObject *)__pyx_v_cls)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; goto __pyx_L1;}

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":202 */
  __pyx_v_bases = __pyx_v_cls->cl_bases;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":204 */
  __pyx_1 = (__pyx_v_bases != 0);
  if (__pyx_1) {
    __pyx_1 = PyTuple_GET_SIZE(__pyx_v_bases);
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":206 */
      Py_INCREF(((PyObject *)PyTuple_GET_ITEM(__pyx_v_bases,__pyx_v_i)));
      Py_DECREF(__pyx_v_tmp);
      __pyx_v_tmp = ((PyObject *)PyTuple_GET_ITEM(__pyx_v_bases,__pyx_v_i));

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":207 */
      __pyx_2 = __pyx_f_9enthought_6traits_9protocols_9_speedups_buildClassicMRO(((PyClassObject *)__pyx_v_tmp),__pyx_v_list); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_classicMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_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;
  static char *__pyx_argnames[] = {"ob","extendedClassic",0};
  __pyx_v_extendedClassic = __pyx_d6;
  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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":212 */
  __pyx_1 = PyClass_Check(__pyx_v_ob);
  if (__pyx_1) {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":213 */
    __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}
    Py_DECREF(__pyx_v_mro);
    __pyx_v_mro = __pyx_2;
    __pyx_2 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":214 */
    __pyx_2 = __pyx_f_9enthought_6traits_9protocols_9_speedups_buildClassicMRO(((PyClassObject *)__pyx_v_ob),((PyListObject *)__pyx_v_mro)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":215 */
    __pyx_1 = PyObject_IsTrue(__pyx_v_extendedClassic); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;}
    if (__pyx_1) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":216 */
      __pyx_1 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyInstance_Type))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":217 */
      __pyx_1 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyBaseObject_Type))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":218 */
    Py_INCREF(__pyx_v_mro);
    __pyx_r = __pyx_v_mro;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":220 */
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  Py_INCREF(__pyx_k11p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k11p);
  Py_INCREF(__pyx_v_ob);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_ob);
  __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
  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 = 220; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("enthought.traits.protocols._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_f_9enthought_6traits_9protocols_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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":238 */
  __pyx_1 = PyList_Append(__pyx_v_list,__pyx_v_cls); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; goto __pyx_L1;}

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":239 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_cls, __pyx_n___bases__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;}
  __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; 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 = 239; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = __pyx_f_9enthought_6traits_9protocols_9_speedups_buildECMRO(__pyx_v_i,__pyx_v_list); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; 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("enthought.traits.protocols._speedups.buildECMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_cls);
  return __pyx_r;
}

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_extClassMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_d7;
  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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":244 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_v_mro);
  __pyx_v_mro = __pyx_1;
  __pyx_1 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":245 */
  __pyx_1 = __pyx_f_9enthought_6traits_9protocols_9_speedups_buildECMRO(__pyx_v_ob,((PyListObject *)__pyx_v_mro)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":246 */
  __pyx_2 = PyObject_IsTrue(__pyx_v_extendedClassic); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; goto __pyx_L1;}
  if (__pyx_2) {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":247 */
    __pyx_2 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyInstance_Type))); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":248 */
    __pyx_2 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyBaseObject_Type))); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":249 */
  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("enthought.traits.protocols._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_f_9enthought_6traits_9protocols_9_speedups_getMRO(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_d8;
  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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":255 */
  __pyx_1 = PyClass_Check(__pyx_v_ob);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_classicMRO); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; 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 = 256; 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) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_ob, __pyx_n___mro__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; 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_9enthought_6traits_9protocols_9_speedups___ECType);
  if (__pyx_1) {
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_extClassMRO); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; 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 = 262; 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:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":264 */
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; 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("enthought.traits.protocols._speedups.getMRO");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ob);
  Py_DECREF(__pyx_v_extendedClassic);
  return __pyx_r;
}

static PyObject *__pyx_f_9enthought_6traits_9protocols_9_speedups_Protocol__adapt__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9enthought_6traits_9protocols_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_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;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  int __pyx_8;
  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_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);

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":283 */
  __pyx_1 = PyInstance_Check(__pyx_v_obj);
  if (__pyx_1) {
    Py_INCREF(((PyObject *)((PyInstanceObject *)__pyx_v_obj)->in_class));
    Py_DECREF(__pyx_v_cls);
    __pyx_v_cls = ((PyObject *)((PyInstanceObject *)__pyx_v_obj)->in_class);
    goto __pyx_L2;
  }
  /*else*/ {
    /*try:*/ {
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n___class); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L3;}
      __pyx_3 = PyObject_GetAttr(__pyx_v_obj,__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L3;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_3;
      __pyx_3 = 0;
    }
    goto __pyx_L4;
    __pyx_L3:;
    Py_XDECREF(__pyx_2); __pyx_2 = 0;
    Py_XDECREF(__pyx_3); __pyx_3 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":289 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_AttributeError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
    __pyx_1 = PyErr_ExceptionMatches(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {
      __Pyx_AddTraceback("enthought.traits.protocols._speedups.Protocol__adapt__");
      if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
      Py_INCREF(((PyObject *)((PyObject *)__pyx_v_obj)->ob_type));
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = ((PyObject *)((PyObject *)__pyx_v_obj)->ob_type);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4;
    }
    goto __pyx_L1;
    __pyx_L4:;
  }
  __pyx_L2:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":293 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_mro);
  __pyx_v_mro = Py_None;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":294 */
  __pyx_1 = PyType_Check(__pyx_v_cls);
  if (__pyx_1) {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":296 */
    __pyx_v_tmp = ((PyTypeObject *)__pyx_v_cls)->tp_mro;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":297 */
    __pyx_1 = (__pyx_v_tmp != NULL);
    if (__pyx_1) {
      Py_INCREF(((PyObject *)__pyx_v_tmp));
      Py_DECREF(__pyx_v_mro);
      __pyx_v_mro = ((PyObject *)__pyx_v_tmp);
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":300 */
  __pyx_1 = __pyx_v_mro == Py_None;
  if (__pyx_1) {
    __pyx_1 = PyClass_Check(__pyx_v_cls);
    if (__pyx_1) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":303 */
      __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;}
      Py_DECREF(__pyx_v_mro);
      __pyx_v_mro = __pyx_3;
      __pyx_3 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":304 */
      __pyx_2 = __pyx_f_9enthought_6traits_9protocols_9_speedups_buildClassicMRO(((PyClassObject *)__pyx_v_cls),((PyListObject *)__pyx_v_mro)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":305 */
      __pyx_1 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyInstance_Type))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":306 */
      __pyx_1 = PyList_Append(((PyListObject *)__pyx_v_mro),((PyObject *)(&PyBaseObject_Type))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; goto __pyx_L1;}
      goto __pyx_L8;
    }
    /*else*/ {
      /*try:*/ {
        __pyx_4 = PyObject_GetAttr(__pyx_v_cls,__pyx_v_9enthought_6traits_9protocols_9_speedups___mro); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L9;}
        Py_DECREF(__pyx_v_mro);
        __pyx_v_mro = __pyx_4;
        __pyx_4 = 0;
      }
      goto __pyx_L10;
      __pyx_L9:;
      Py_XDECREF(__pyx_3); __pyx_3 = 0;
      Py_XDECREF(__pyx_2); __pyx_2 = 0;
      Py_XDECREF(__pyx_4); __pyx_4 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":312 */
      __pyx_1 = PyErr_ExceptionMatches(PyExc_Exception);
      if (__pyx_1) {
        __Pyx_AddTraceback("enthought.traits.protocols._speedups.Protocol__adapt__");
        if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
        __pyx_1 = PyObject_TypeCheck(__pyx_v_cls,__pyx_v_9enthought_6traits_9protocols_9_speedups___ECType);
        if (__pyx_1) {
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_extClassMRO); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
          __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
          __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
          Py_INCREF(__pyx_v_cls);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_cls);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
          __pyx_6 = 0;
          __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_v_mro);
          __pyx_v_mro = __pyx_6;
          __pyx_6 = 0;
          goto __pyx_L11;
        }
        /*else*/ {
          __Pyx_Raise(__pyx_3, __pyx_2, __pyx_4);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
        }
        __pyx_L11:;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        goto __pyx_L10;
      }
      goto __pyx_L1;
      __pyx_L10:;
    }
    __pyx_L8:;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":329 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n__Protocol__adapters); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;}
  __pyx_7 = PyObject_GetAttr(__pyx_5, __pyx_n_get); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_v_get);
  __pyx_v_get = __pyx_7;
  __pyx_7 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":331 */
  __pyx_1 = PyTuple_Check(__pyx_v_mro);
  if (__pyx_1) {
    __pyx_1 = PyTuple_GET_SIZE(((PyTupleObject *)__pyx_v_mro));
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":334 */
      Py_INCREF(((PyObject *)PyTuple_GET_ITEM(((PyTupleObject *)__pyx_v_mro),__pyx_v_i)));
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = ((PyObject *)PyTuple_GET_ITEM(((PyTupleObject *)__pyx_v_mro),__pyx_v_i));

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":335 */
      __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_cls);
      __pyx_3 = PyObject_CallObject(__pyx_v_get, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_3;
      __pyx_3 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":336 */
      __pyx_8 = __pyx_v_factory != Py_None;
      if (__pyx_8) {
        __pyx_2 = __Pyx_GetItemInt(__pyx_v_factory, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
        Py_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_obj);
        __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_r = __pyx_5;
        __pyx_5 = 0;
        goto __pyx_L0;
        goto __pyx_L15;
      }
      __pyx_L15:;
    }
    goto __pyx_L12;
  }
  __pyx_8 = PyList_Check(__pyx_v_mro);
  if (__pyx_8) {
    __pyx_1 = PyList_GET_SIZE(((PyListObject *)__pyx_v_mro));
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":342 */
      Py_INCREF(((PyObject *)PyList_GET_ITEM(((PyListObject *)__pyx_v_mro),__pyx_v_i)));
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = ((PyObject *)PyList_GET_ITEM(((PyListObject *)__pyx_v_mro),__pyx_v_i));

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":343 */
      __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_cls);
      __pyx_6 = PyObject_CallObject(__pyx_v_get, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_6;
      __pyx_6 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":344 */
      __pyx_8 = __pyx_v_factory != Py_None;
      if (__pyx_8) {
        __pyx_3 = __Pyx_GetItemInt(__pyx_v_factory, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; 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 = 345; 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_L18;
      }
      __pyx_L18:;
    }
    goto __pyx_L12;
  }
  /*else*/ {
    __pyx_5 = PyObject_GetIter(__pyx_v_mro); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
    for (;;) {
      __pyx_7 = PyIter_Next(__pyx_5);
      if (!__pyx_7) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_cls);
      __pyx_v_cls = __pyx_7;
      __pyx_7 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":351 */
      __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
      Py_INCREF(__pyx_v_cls);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_cls);
      __pyx_3 = PyObject_CallObject(__pyx_v_get, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_v_factory);
      __pyx_v_factory = __pyx_3;
      __pyx_3 = 0;

      /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":352 */
      __pyx_8 = __pyx_v_factory != Py_None;
      if (__pyx_8) {
        __pyx_2 = __Pyx_GetItemInt(__pyx_v_factory, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
        Py_INCREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_obj);
        __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_r = __pyx_7;
        __pyx_7 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L0;
        goto __pyx_L21;
      }
      __pyx_L21:;
    }
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  __pyx_L12:;

  __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_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("enthought.traits.protocols._speedups.Protocol__adapt__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_cls);
  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 PyObject *__pyx_tp_new_9enthought_6traits_9protocols_9_speedups_metamethod(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_9enthought_6traits_9protocols_9_speedups_metamethod *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_9enthought_6traits_9protocols_9_speedups_metamethod *)o);
  p->func = Py_None; Py_INCREF(Py_None);
  return o;
}

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

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

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

static PyObject *__pyx_tp_descr_get_9enthought_6traits_9protocols_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_9enthought_6traits_9protocols_9_speedups_10metamethod___get__(o, i, c);
  return r;
}

static int __pyx_tp_descr_set_9enthought_6traits_9protocols_9_speedups_metamethod(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_f_9enthought_6traits_9protocols_9_speedups_10metamethod___set__(o, i, v);
  }
  else {
    return __pyx_f_9enthought_6traits_9protocols_9_speedups_10metamethod___delete__(o, i);
  }
}

static struct PyMethodDef __pyx_methods_9enthought_6traits_9protocols_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*/
  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

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_9enthought_6traits_9protocols_9_speedups_metamethod = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "enthought.traits.protocols._speedups.metamethod", /*tp_name*/
  sizeof(struct __pyx_obj_9enthought_6traits_9protocols_9_speedups_metamethod), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9enthought_6traits_9protocols_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_9enthought_6traits_9protocols_9_speedups_metamethod, /*tp_traverse*/
  __pyx_tp_clear_9enthought_6traits_9protocols_9_speedups_metamethod, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_9enthought_6traits_9protocols_9_speedups_metamethod, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  __pyx_tp_descr_get_9enthought_6traits_9protocols_9_speedups_metamethod, /*tp_descr_get*/
  __pyx_tp_descr_set_9enthought_6traits_9protocols_9_speedups_metamethod, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_9enthought_6traits_9protocols_9_speedups_10metamethod___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9enthought_6traits_9protocols_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_9enthought_6traits_9protocols_9_speedups_NO_ADAPTER_NEEDED, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9enthought_6traits_9protocols_9_speedups_NO_ADAPTER_NEEDED},
  {"DOES_NOT_SUPPORT", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_DOES_NOT_SUPPORT, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9enthought_6traits_9protocols_9_speedups_DOES_NOT_SUPPORT},
  {"adapt", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_adapt, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9enthought_6traits_9protocols_9_speedups_adapt},
  {"Protocol__call__", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_Protocol__call__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9enthought_6traits_9protocols_9_speedups_Protocol__call__},
  {"classicMRO", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_classicMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"extClassMRO", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_extClassMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"getMRO", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_9_speedups_getMRO, METH_VARARGS|METH_KEYWORDS, 0},
  {"Protocol__adapt__", (PyCFunction)__pyx_f_9enthought_6traits_9protocols_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;};
  Py_INCREF(__pyx_m);
  __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_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_v_9enthought_6traits_9protocols_9_speedups__marker = Py_None; Py_INCREF(Py_None);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___conform = Py_None; Py_INCREF(Py_None);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___adapt = Py_None; Py_INCREF(Py_None);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___mro = Py_None; Py_INCREF(Py_None);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___ECType = Py_None; Py_INCREF(Py_None);
  __pyx_type_9enthought_6traits_9protocols_9_speedups_metamethod.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_9enthought_6traits_9protocols_9_speedups_metamethod) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "metamethod", (PyObject *)&__pyx_type_9enthought_6traits_9protocols_9_speedups_metamethod) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;}
  __pyx_ptype_9enthought_6traits_9protocols_9_speedups_metamethod = &__pyx_type_9enthought_6traits_9protocols_9_speedups_metamethod;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/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;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":61 */
  __pyx_1 = PyList_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_INCREF(__pyx_n_exc_info);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_exc_info);
  Py_INCREF(__pyx_n_exc_clear);
  PyList_SET_ITEM(__pyx_1, 1, __pyx_n_exc_clear);
  __pyx_2 = __Pyx_Import(__pyx_n_sys, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; 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 = 61; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_exc_info, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_clear); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_exc_clear, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":62 */
  __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_INCREF(__pyx_n_AdaptationFailure);
  PyList_SET_ITEM(__pyx_2, 0, __pyx_n_AdaptationFailure);
  __pyx_1 = __Pyx_Import(__pyx_n_adapters, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; 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 = 62; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_AdaptationFailure, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":64 */
  /*try:*/ {

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":65 */
    __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L22;}
    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 = 65; goto __pyx_L22;}
    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 = 65; goto __pyx_L22;}
    if (PyObject_SetAttr(__pyx_m, __pyx_n_ExtensionClass, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L22;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":66 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_ExtensionClass); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L22;}
    Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups___ECType);
    __pyx_v_9enthought_6traits_9protocols_9_speedups___ECType = __pyx_2;
    __pyx_2 = 0;
  }
  goto __pyx_L23;
  __pyx_L22:;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":67 */
  __pyx_3 = PyErr_ExceptionMatches(PyExc_ImportError);
  if (__pyx_3) {
    __Pyx_AddTraceback("enthought.traits.protocols._speedups");
    if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; goto __pyx_L1;}
    Py_INCREF(((PyObject *)(&PyType_Type)));
    Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups___ECType);
    __pyx_v_9enthought_6traits_9protocols_9_speedups___ECType = ((PyObject *)(&PyType_Type));
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L23;
  }
  goto __pyx_L1;
  __pyx_L23:;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":70 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_object); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups__marker);
  __pyx_v_9enthought_6traits_9protocols_9_speedups__marker = __pyx_2;
  __pyx_2 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":71 */
  __pyx_4 = PyString_InternFromString(__pyx_k31); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups___conform);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___conform = __pyx_4;
  __pyx_4 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":72 */
  __pyx_1 = PyString_InternFromString(__pyx_k32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups___adapt);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___adapt = __pyx_1;
  __pyx_1 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":73 */
  __pyx_2 = PyString_InternFromString(__pyx_k33); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n___class, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":74 */
  __pyx_4 = PyString_InternFromString(__pyx_k14); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(__pyx_v_9enthought_6traits_9protocols_9_speedups___mro);
  __pyx_v_9enthought_6traits_9protocols_9_speedups___mro = __pyx_4;
  __pyx_4 = 0;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":85 */
  Py_INCREF(Py_None);
  __pyx_d1 = Py_None;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":89 */
  Py_INCREF(Py_None);
  __pyx_d2 = Py_None;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":183 */
  Py_INCREF(__pyx_v_9enthought_6traits_9protocols_9_speedups__marker);
  __pyx_d3 = __pyx_v_9enthought_6traits_9protocols_9_speedups__marker;
  Py_INCREF(__pyx_v_9enthought_6traits_9protocols_9_speedups__marker);
  __pyx_d4 = __pyx_v_9enthought_6traits_9protocols_9_speedups__marker;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":191 */
  Py_INCREF(__pyx_v_9enthought_6traits_9protocols_9_speedups__marker);
  __pyx_d5 = __pyx_v_9enthought_6traits_9protocols_9_speedups__marker;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":210 */
  Py_INCREF(Py_False);
  __pyx_d6 = Py_False;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":243 */
  Py_INCREF(Py_False);
  __pyx_d7 = Py_False;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":253 */
  Py_INCREF(Py_False);
  __pyx_d8 = Py_False;

  /* "/Users/rkern/svn/et/Traits/enthought/traits/protocols/_speedups.pyx":278 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("enthought.traits.protocols._speedups");
}

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

/* Runtime support code */

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

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 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);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* 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 PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_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
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_Get();
    PyErr_Fetch(type, value, tb);
    PyErr_NormalizeException(type, value, tb);
    if (PyErr_Occurred())
        goto bad;
    Py_INCREF(*type);
    Py_INCREF(*value);
    Py_INCREF(*tb);
    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;
    return 0;
bad:
    Py_XDECREF(*type);
    Py_XDECREF(*value);
    Py_XDECREF(*tb);
    return -1;
}

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
    PyTypeObject *t = o->ob_type;
    PyObject *r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

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 int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++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);
}
