diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py
index bf6eef8b9083c5459492918881bb0a74bd560345..955ee2058df85cb9e5631687b78de5c3cf1c5a88 100644
--- a/Cython/Compiler/Buffer.py
+++ b/Cython/Compiler/Buffer.py
@@ -368,8 +368,12 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos,
                     code.putln("%s = %d;" % (tmp_cname, dim))
                 code.put("} else ")
             # check bounds in positive direction
+            if signed != 0:  
+                cast = ""
+            else:
+                cast = "(size_t)"
             code.putln("if (%s) %s = %d;" % (
-                code.unlikely("%s >= %s" % (cname, shape.cname)),
+                code.unlikely("%s >= %s%s" % (cname, cast, shape.cname)),
                 tmp_cname, dim))
         code.globalstate.use_utility_code(raise_indexerror_code)
         code.putln("if (%s) {" % code.unlikely("%s != -1" % tmp_cname))
diff --git a/Cython/Compiler/DebugFlags.py b/Cython/Compiler/DebugFlags.py
index f7f5a0eb20590069d9ea74584d94538cf67249d8..d6d52189437a03b80c76443274e963ec4a9fb1cb 100644
--- a/Cython/Compiler/DebugFlags.py
+++ b/Cython/Compiler/DebugFlags.py
@@ -10,7 +10,7 @@ debug_temp_code_comments = 0
 debug_trace_code_generation = 0
 
 # Do not replace exceptions with user-friendly error messages
-debug_no_exception_intercept = 1
+debug_no_exception_intercept = 0
 
 # Print a message each time a new stage in the pipeline is entered
 debug_verbose_pipeline = 0
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
index ef7e242023fa2c1c8b0ad667cb81b20f3e9fc802..c0010d77679512a1427ee6aa63d13c3e89442931 100644
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -426,6 +426,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         code.globalstate["end"].putln("#endif /* Py_PYTHON_H */")
         
         code.put("""
+#include <stddef.h> /* For offsetof */
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+
 #ifndef PY_LONG_LONG
   #define PY_LONG_LONG LONG_LONG
 #endif
@@ -903,7 +908,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                         self.generate_descr_set_function(scope, code)
                     self.generate_property_accessors(scope, code)
                     self.generate_method_table(scope, code)
-                    self.generate_member_table(scope, code)
                     self.generate_getset_table(scope, code)
                     self.generate_typeobj_definition(full_module_name, entry, code)
     
@@ -1529,34 +1533,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         code.putln(
             "};")
     
-    def generate_member_table(self, env, code):
-        #print "ModuleNode.generate_member_table: scope =", env ###
-        if env.public_attr_entries:
-            code.putln("")
-            code.putln(
-                "static struct PyMemberDef %s[] = {" %
-                    env.member_table_cname)
-            type = env.parent_type
-            if type.typedef_flag:
-                objstruct = type.objstruct_cname
-            else:
-                objstruct = "struct %s" % type.objstruct_cname
-            for entry in env.public_attr_entries:
-                type_code = entry.type.pymemberdef_typecode
-                if entry.visibility == 'readonly':
-                    flags = "READONLY"
-                else:
-                    flags = "0"
-                code.putln('{(char *)"%s", %s, %s, %s, 0},' % (
-                    entry.name,
-                    type_code,
-                    "offsetof(%s, %s)" % (objstruct, entry.cname),
-                    flags))
-            code.putln(
-                    "{0, 0, 0, 0, 0}")
-            code.putln(
-                "};")
-    
     def generate_getset_table(self, env, code):
         if env.property_entries:
             code.putln("")
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index 9408693f17aff045818e8e667531dcb063de5e72..7355fc313b503fa48903ef0300e476e96b88ec09 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -891,13 +891,13 @@ class CVarDefNode(StatNode):
     #  declarators   [CDeclaratorNode]
     #  in_pxd        boolean
     #  api           boolean
-    #  need_properties [entry]
+    #  properties    [entry]
 
     #  decorators    [cython.locals(...)] or None 
     #  directive_locals { string : NameNode } locals defined by cython.locals(...)
 
     child_attrs = ["base_type", "declarators"]
-    need_properties = ()
+    properties = ()
     
     decorators = None
     directive_locals = {}
@@ -912,15 +912,12 @@ class CVarDefNode(StatNode):
         # so do conversion ourself rather than rely on the CPython mechanism (through
         # a property; made in AnalyseDeclarationsTransform).
         if (dest_scope.is_c_class_scope
-                and self.visibility == 'public' 
-                and base_type.is_pyobject 
-                and (base_type.is_builtin_type or base_type.is_extension_type)):
-            self.need_properties = []
+            and self.visibility in ('public', 'readonly')):
+            self.properties = []
             need_property = True
-            visibility = 'private'
         else:
             need_property = False
-            visibility = self.visibility
+        visibility = self.visibility
             
         for declarator in self.declarators:
             name_declarator, type = declarator.analyse(base_type, env)
@@ -951,8 +948,7 @@ class CVarDefNode(StatNode):
                 entry = dest_scope.declare_var(name, type, declarator.pos,
                             cname = cname, visibility = visibility, is_cdef = 1)
                 if need_property:
-                    self.need_properties.append(entry)
-                    entry.needs_property = 1
+                    self.properties.append(entry)
     
 
 class CStructOrUnionDefNode(StatNode):
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index 678260cae092a8489592f9dc30983dd496310a4e..d6cbd5c5ba707a38399c5172eda3f3ad7611cceb 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -952,6 +952,11 @@ property NAME:
     def __set__(self, value):
         ATTR = value
     """, level='c_class')
+    basic_property_ro = TreeFragment(u"""
+property NAME:
+    def __get__(self):
+        return ATTR
+    """, level='c_class')
 
     def __call__(self, root):
         self.env_stack = [root.scope]
@@ -1037,12 +1042,9 @@ property NAME:
         # to ensure all CNameDeclaratorNodes are visited.
         self.visitchildren(node)
 
-        if node.need_properties:
-            # cdef public attributes may need type testing on 
-            # assignment, so we create a property accesss
-            # mechanism for them. 
+        if node.properties:
             stats = []
-            for entry in node.need_properties:
+            for entry in node.properties:
                 property = self.create_Property(entry)
                 property.analyse_declarations(node.dest_scope)
                 self.visit(property)
@@ -1052,13 +1054,34 @@ property NAME:
             return None
             
     def create_Property(self, entry):
-        template = self.basic_property
+        if entry.visibility == 'public':
+            template = self.basic_property
+        elif entry.visibility == 'readonly':
+            template = self.basic_property_ro
         property = template.substitute({
                 u"ATTR": AttributeNode(pos=entry.pos,
                                        obj=NameNode(pos=entry.pos, name="self"), 
                                        attribute=entry.name),
             }, pos=entry.pos).stats[0]
         property.name = entry.name
+        # ---------------------------------------
+        # XXX This should go to AutoDocTransforms
+        # ---------------------------------------
+        if self.current_directives['embedsignature']:
+            attr_name = entry.name
+            type_name = entry.type.declaration_code("", for_display=1)
+            default_value = ''
+            if not entry.type.is_pyobject:
+                type_name = "'%s'" % type_name
+            elif entry.type.is_extension_type:
+                type_name = entry.type.module_name + '.' + type_name
+            if entry.init is not None:
+                default_value = ' = ' + entry.init
+            elif entry.init_to_none:
+                default_value = ' = ' + repr(None)
+            docstring = attr_name + ': ' + type_name + default_value
+            property.doc = EncodedString(docstring)
+        # ---------------------------------------
         return property
 
 class AnalyseExpressionsTransform(CythonTransform):
diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py
index 80a1c081db42ec6686a9f8e1546b78eaa437b7ba..61c684863193fb6636e6b39ff782e8193bcce996 100644
--- a/Cython/Compiler/Parsing.py
+++ b/Cython/Compiler/Parsing.py
@@ -13,10 +13,10 @@ import sys
 
 try:
     from __builtin__ import set
-except ImportError:
+except (ImportError, AttributeError):
     try:
         from builtins import set
-    except ImportError:
+    except (ImportError, AttributeError):
         from sets import Set as set
 
 from Cython.Compiler.Scanning import PyrexScanner, FileSourceDescriptor
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py
index fab502caf32d511527fb8553bd7c70b595462e1a..65cb305daf7955e685f08d16995de7995887154f 100755
--- a/Cython/Compiler/PyrexTypes.py
+++ b/Cython/Compiler/PyrexTypes.py
@@ -56,7 +56,6 @@ class PyrexType(BaseType):
     #  is_buffer             boolean     Is buffer access type
     #  has_attributes        boolean     Has C dot-selectable attributes
     #  default_value         string      Initial value
-    #  pymemberdef_typecode  string      Type code for PyMemberDef struct
     #
     #  declaration_code(entity_code, 
     #      for_display = 0, dll_linkage = None, pyrex = 0)
@@ -109,7 +108,6 @@ class PyrexType(BaseType):
     is_buffer = 0
     has_attributes = 0
     default_value = ""
-    pymemberdef_typecode = None
     
     def resolve(self):
         # If a typedef, returns the base type.
@@ -198,18 +196,6 @@ class CTypedefType(BaseType):
         self.typedef_cname = cname
         self.typedef_base_type = base_type
         self.typedef_is_external = is_external
-        # Make typecodes in external typedefs use typesize-neutral macros
-        if is_external:
-            typecode = None
-            if base_type.is_int:
-                if base_type.signed == 0:
-                    typecode = "__Pyx_T_UNSIGNED_INT"
-                else:
-                    typecode = "__Pyx_T_SIGNED_INT"
-            elif base_type.is_float and not rank_to_type_name[base_type.rank] == "long double":
-                typecode = "__Pyx_T_FLOATING"
-            if typecode:
-                self.pymemberdef_typecode = "%s(%s)" % (typecode, cname)
     
     def resolve(self):
         return self.typedef_base_type.resolve()
@@ -349,7 +335,6 @@ class PyObjectType(PyrexType):
     name = "object"
     is_pyobject = 1
     default_value = "0"
-    pymemberdef_typecode = "T_OBJECT"
     buffer_defaults = None
     is_extern = False
     is_subclassed = False
@@ -626,10 +611,9 @@ class CNumericType(CType):
     
     sign_words = ("unsigned ", "", "signed ")
     
-    def __init__(self, rank, signed = 1, pymemberdef_typecode = None):
+    def __init__(self, rank, signed = 1):
         self.rank = rank
         self.signed = signed
-        self.pymemberdef_typecode = pymemberdef_typecode
     
     def sign_and_name(self):
         s = self.sign_words[self.signed]
@@ -795,8 +779,8 @@ class CIntType(CNumericType):
     from_py_function = "__Pyx_PyInt_AsInt"
     exception_value = -1
 
-    def __init__(self, rank, signed, pymemberdef_typecode = None, is_returncode = 0):
-        CNumericType.__init__(self, rank, signed, pymemberdef_typecode)
+    def __init__(self, rank, signed, is_returncode = 0):
+        CNumericType.__init__(self, rank, signed)
         self.is_returncode = is_returncode
         if self.from_py_function == "__Pyx_PyInt_AsInt":
             self.from_py_function = self.get_type_conversion()
@@ -895,8 +879,8 @@ class CFloatType(CNumericType):
 
     exception_value = -1
     
-    def __init__(self, rank, pymemberdef_typecode = None, math_h_modifier = ''):
-        CNumericType.__init__(self, rank, 1, pymemberdef_typecode)
+    def __init__(self, rank, math_h_modifier = ''):
+        CNumericType.__init__(self, rank, 1)
         self.math_h_modifier = math_h_modifier
     
     def assignable_from_resolved_type(self, src_type):
@@ -1996,7 +1980,6 @@ class CStringType(object):
 class CUTF8CharArrayType(CStringType, CArrayType):
     #  C 'char []' type.
     
-    pymemberdef_typecode = "T_STRING_INPLACE"
     is_unicode = 1
     
     to_py_function = "PyUnicode_DecodeUTF8"
@@ -2008,8 +1991,6 @@ class CUTF8CharArrayType(CStringType, CArrayType):
 class CCharArrayType(CStringType, CArrayType):
     #  C 'char []' type.
     
-    pymemberdef_typecode = "T_STRING_INPLACE"
-    
     def __init__(self, size):
         CArrayType.__init__(self, c_char_type, size)
     
@@ -2017,8 +1998,6 @@ class CCharArrayType(CStringType, CArrayType):
 class CCharPtrType(CStringType, CPtrType):
     # C 'char *' type.
     
-    pymemberdef_typecode = "T_STRING"
-    
     def __init__(self):
         CPtrType.__init__(self, c_char_type)
 
@@ -2026,8 +2005,6 @@ class CCharPtrType(CStringType, CPtrType):
 class CUCharPtrType(CStringType, CPtrType):
     # C 'unsigned char *' type.
     
-    pymemberdef_typecode = "T_STRING"
-    
     to_py_function = "__Pyx_PyBytes_FromUString"
     from_py_function = "__Pyx_PyBytes_AsUString"
 
@@ -2093,30 +2070,30 @@ c_void_type =         CVoidType()
 c_void_ptr_type =     CPtrType(c_void_type)
 c_void_ptr_ptr_type = CPtrType(c_void_ptr_type)
 
-c_uchar_type =       CIntType(0, 0, "T_UBYTE")
-c_ushort_type =      CIntType(1, 0, "T_USHORT")
-c_uint_type =        CUIntType(2, 0, "T_UINT")
-c_ulong_type =       CULongType(3, 0, "T_ULONG")
-c_ulonglong_type =   CULongLongType(6, 0, "T_ULONGLONG")
-
-c_char_type =        CIntType(0, 1, "T_CHAR")
-c_short_type =       CIntType(1, 1, "T_SHORT")
-c_int_type =         CIntType(2, 1, "T_INT")
-c_long_type =        CLongType(3, 1, "T_LONG")
-c_longlong_type =    CLongLongType(6, 1, "T_LONGLONG")
-c_bint_type =        CBIntType(2, 1, "T_INT")
-
-c_schar_type =       CIntType(0, 2, "T_CHAR")
-c_sshort_type =      CIntType(1, 2, "T_SHORT")
-c_sint_type =        CIntType(2, 2, "T_INT")
-c_slong_type =       CLongType(3, 2, "T_LONG")
-c_slonglong_type =   CLongLongType(6, 2, "T_LONGLONG")
-
-c_py_ssize_t_type =  CPySSizeTType(4, 2, "T_PYSSIZET")
-c_size_t_type =      CSizeTType(5, 0, "T_SIZET")
-
-c_float_type =       CFloatType(7, "T_FLOAT", math_h_modifier='f')
-c_double_type =      CFloatType(8, "T_DOUBLE")
+c_uchar_type =       CIntType(0, 0)
+c_ushort_type =      CIntType(1, 0)
+c_uint_type =        CUIntType(2, 0)
+c_ulong_type =       CULongType(3, 0)
+c_ulonglong_type =   CULongLongType(6, 0)
+
+c_char_type =        CIntType(0, 1)
+c_short_type =       CIntType(1, 1)
+c_int_type =         CIntType(2, 1)
+c_long_type =        CLongType(3, 1)
+c_longlong_type =    CLongLongType(6, 1)
+c_bint_type =        CBIntType(2, 1)
+
+c_schar_type =       CIntType(0, 2)
+c_sshort_type =      CIntType(1, 2)
+c_sint_type =        CIntType(2, 2)
+c_slong_type =       CLongType(3, 2)
+c_slonglong_type =   CLongLongType(6, 2)
+
+c_py_ssize_t_type =  CPySSizeTType(4, 2)
+c_size_t_type =      CSizeTType(5, 0)
+
+c_float_type =       CFloatType(7, math_h_modifier='f')
+c_double_type =      CFloatType(8)
 c_longdouble_type =  CFloatType(9, math_h_modifier='l')
 
 c_double_complex_type = CComplexType(c_double_type)
@@ -2131,7 +2108,7 @@ c_int_ptr_type =      CPtrType(c_int_type)
 c_py_ssize_t_ptr_type =  CPtrType(c_py_ssize_t_type)
 c_size_t_ptr_type =  CPtrType(c_size_t_type)
 
-c_returncode_type =   CIntType(2, 1, "T_INT", is_returncode = 1)
+c_returncode_type =   CIntType(2, 1, is_returncode = 1)
 
 c_anon_enum_type =    CAnonEnumType(-1, 1)
 
@@ -2500,68 +2477,6 @@ type_conversion_predeclarations = """
 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
 
-#if !defined(T_PYSSIZET)
-#if PY_VERSION_HEX < 0x02050000
-#define T_PYSSIZET T_INT
-#elif !defined(T_LONGLONG)
-#define T_PYSSIZET \\
-        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \\
-        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
-#else
-#define T_PYSSIZET \\
-        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \\
-        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \\
-        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
-#endif
-#endif
-
-
-#if !defined(T_ULONGLONG)
-#define __Pyx_T_UNSIGNED_INT(x) \\
-        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \\
-        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \\
-        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \\
-        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : -1))))
-#else
-#define __Pyx_T_UNSIGNED_INT(x) \\
-        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \\
-        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \\
-        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \\
-        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : \\
-        ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
-#endif
-#if !defined(T_LONGLONG)
-#define __Pyx_T_SIGNED_INT(x) \\
-        ((sizeof(x) == sizeof(char))  ? T_BYTE : \\
-        ((sizeof(x) == sizeof(short)) ? T_SHORT : \\
-        ((sizeof(x) == sizeof(int))   ? T_INT : \\
-        ((sizeof(x) == sizeof(long))  ? T_LONG : -1))))
-#else
-#define __Pyx_T_SIGNED_INT(x) \\
-        ((sizeof(x) == sizeof(char))  ? T_BYTE : \\
-        ((sizeof(x) == sizeof(short)) ? T_SHORT : \\
-        ((sizeof(x) == sizeof(int))   ? T_INT : \\
-        ((sizeof(x) == sizeof(long))  ? T_LONG : \\
-        ((sizeof(x) == sizeof(PY_LONG_LONG))   ? T_LONGLONG : -1)))))
-#endif
-
-#define __Pyx_T_FLOATING(x) \\
-        ((sizeof(x) == sizeof(float)) ? T_FLOAT : \\
-        ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
-
-#if !defined(T_SIZET)
-#if !defined(T_ULONGLONG)
-#define T_SIZET \\
-        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \\
-        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
-#else
-#define T_SIZET \\
-        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \\
-        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \\
-        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
-#endif
-#endif
-
 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py
index 9a4dd21e53d90c6e4bf2ad0696b7ee7889cdfa46..532be2fda8c40c8905083b6a2929127fa4d2407b 100644
--- a/Cython/Compiler/Symtab.py
+++ b/Cython/Compiler/Symtab.py
@@ -789,7 +789,7 @@ class ModuleScope(Scope):
         self.doc_cname = Naming.moddoc_cname
         self.utility_code_list = []
         self.module_entries = {}
-        self.python_include_files = ["Python.h", "structmember.h"]
+        self.python_include_files = ["Python.h"]
         self.include_files = []
         self.type_names = dict(outer_scope.type_names)
         self.pxd_file_loaded = 0
@@ -1319,10 +1319,8 @@ class CClassScope(ClassScope):
     #  #typeobj_cname        string or None
     #  #objstruct_cname      string
     #  method_table_cname    string
-    #  member_table_cname    string
     #  getset_table_cname    string
     #  has_pyobject_attrs    boolean  Any PyObject attributes?
-    #  public_attr_entries   boolean  public/readonly attrs
     #  property_entries      [Entry]
     #  defined               boolean  Defined in .pxd file
     #  implemented           boolean  Defined in .pyx file
@@ -1334,10 +1332,8 @@ class CClassScope(ClassScope):
         ClassScope.__init__(self, name, outer_scope)
         if visibility != 'extern':
             self.method_table_cname = outer_scope.mangle(Naming.methtab_prefix, name)
-            self.member_table_cname = outer_scope.mangle(Naming.memtab_prefix, name)
             self.getset_table_cname = outer_scope.mangle(Naming.gstab_prefix, name)
         self.has_pyobject_attrs = 0
-        self.public_attr_entries = []
         self.property_entries = []
         self.inherited_var_entries = []
         self.defined = 0
@@ -1378,16 +1374,14 @@ class CClassScope(ClassScope):
                 error(pos,
                     "Attribute of extension type cannot be declared %s" % visibility)
             if visibility in ('public', 'readonly'):
-                if type.pymemberdef_typecode:
-                    self.public_attr_entries.append(entry)
-                    if name == "__weakref__":
-                        error(pos, "Special attribute __weakref__ cannot be exposed to Python")
-                else:
-                    error(pos,
-                        "C attribute of type '%s' cannot be accessed from Python" % type)
-            if visibility == 'public' and type.is_extension_type:
-                error(pos,
-                    "Non-generic Python attribute cannot be exposed for writing from Python")
+                if name == "__weakref__":
+                    error(pos, "Special attribute __weakref__ cannot be exposed to Python")
+                if not type.is_pyobject:
+                    if (not type.create_to_py_utility_code(self) or
+                        (visibility=='public' and not
+                         type.create_from_py_utility_code(self))):
+                        error(pos,
+                              "C attribute of type '%s' cannot be accessed from Python" % type)
             return entry
         else:
             if type is unspecified_type:
diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py
index 1399fcf38782fca1cf5bb2ff72beb05bbe0d12a7..232c51d263102949e7bf0275309eb8ff5515d451 100644
--- a/Cython/Compiler/TypeSlots.py
+++ b/Cython/Compiler/TypeSlots.py
@@ -370,10 +370,7 @@ class MemberTableSlot(SlotDescriptor):
     #  Slot descriptor for the table of Python-accessible attributes.
     
     def slot_code(self, scope):
-        if scope.public_attr_entries:
-            return scope.member_table_cname
-        else:
-            return "0"
+        return "0"
 
 
 class GetSetSlot(SlotDescriptor):
diff --git a/Cython/Includes/cpython/__init__.pxd b/Cython/Includes/cpython/__init__.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..b53d09de65ec69e78f9090b3548daa330de0789d
--- /dev/null
+++ b/Cython/Includes/cpython/__init__.pxd
@@ -0,0 +1,159 @@
+#####################################################################
+#
+# These are the Cython pxd files for (most of) the Python/C API.
+#
+# REFERENCE COUNTING:
+#
+#   JUST TO SCARE YOU:
+#   If you are going to use any of the Python/C API in your Cython
+#   program, you might be responsible for doing reference counting.
+#   Read http://docs.python.org/api/refcounts.html which is so
+#   important I've copied it below.
+#
+# For all the declaration below, whenver the Py_ function returns
+# a *new reference* to a PyObject*, the return type is "object".
+# When the function returns a borrowed reference, the return
+# type is PyObject*.  When Cython sees "object" as a return type
+# it doesn't increment the reference count.  When it sees PyObject*
+# in order to use the result you must explicitly cast to <object>,
+# and when you do that Cython increments the reference count wether
+# you want it to or not, forcing you to an explicit DECREF (or leak memory).
+# To avoid this we make the above convention.  Note, you can
+# always locally override this convention by putting something like
+#
+#     cdef extern from "Python.h":
+#         PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
+#
+# in your file after any .pxi includes.  Cython will use the latest
+# declaration. 
+#
+# Cython takes care of this automatically for anything of type object.
+## More precisely, I think the correct convention for
+## using the Python/C API from Pyrex is as follows.
+##
+## (1) Declare all input arguments as type "object".  This way no explicit
+##    <PyObject*> casting is needed, and moreover Pyrex doesn't generate
+##    any funny reference counting.
+## (2) Declare output as object if a new reference is returned.
+## (3) Declare output as PyObject* if a borrowed reference is returned.
+##    
+## This way when you call objects, no cast is needed, and if the api
+## calls returns a new reference (which is about 95% of them), then
+## you can just assign to a variable of type object.  With borrowed
+## references if you do an explicit typecast to <object>, Pyrex generates an
+## INCREF and DECREF so you have to be careful.  However, you got a
+## borrowed reference in this case, so there's got to be another reference
+## to your object, so you're OK, as long as you relealize this
+## and use the result of an explicit cast to <object> as a borrowed
+## reference (and you can call Py_INCREF if you want to turn it
+## into another reference for some reason). 
+# 
+# "The reference count is important because today's computers have
+# a finite (and often severely limited) memory size; it counts how
+# many different places there are that have a reference to an
+# object. Such a place could be another object, or a global (or
+# static) C variable, or a local variable in some C function. When
+# an object's reference count becomes zero, the object is
+# deallocated. If it contains references to other objects, their
+# reference count is decremented. Those other objects may be
+# deallocated in turn, if this decrement makes their reference
+# count become zero, and so on. (There's an obvious problem with
+# objects that reference each other here; for now, the solution is
+# ``don't do that.'')
+#
+# Reference counts are always manipulated explicitly. The normal
+# way is to use the macro Py_INCREF() to increment an object's
+# reference count by one, and Py_DECREF() to decrement it by
+# one. The Py_DECREF() macro is considerably more complex than the
+# incref one, since it must check whether the reference count
+# becomes zero and then cause the object's deallocator to be
+# called. The deallocator is a function pointer contained in the
+# object's type structure. The type-specific deallocator takes
+# care of decrementing the reference counts for other objects
+# contained in the object if this is a compound object type, such
+# as a list, as well as performing any additional finalization
+# that's needed. There's no chance that the reference count can
+# overflow; at least as many bits are used to hold the reference
+# count as there are distinct memory locations in virtual memory
+# (assuming sizeof(long) >= sizeof(char*)). Thus, the reference
+# count increment is a simple operation.
+# 
+# It is not necessary to increment an object's reference count for
+# every local variable that contains a pointer to an object. In
+# theory, the object's reference count goes up by one when the
+# variable is made to point to it and it goes down by one when the
+# variable goes out of scope. However, these two cancel each other
+# out, so at the end the reference count hasn't changed. The only
+# real reason to use the reference count is to prevent the object
+# from being deallocated as long as our variable is pointing to
+# it. If we know that there is at least one other reference to the
+# object that lives at least as long as our variable, there is no
+# need to increment the reference count temporarily. An important
+# situation where this arises is in objects that are passed as
+# arguments to C functions in an extension module that are called
+# from Python; the call mechanism guarantees to hold a reference
+# to every argument for the duration of the call.
+#
+# However, a common pitfall is to extract an object from a list
+# and hold on to it for a while without incrementing its reference
+# count. Some other operation might conceivably remove the object
+# from the list, decrementing its reference count and possible
+# deallocating it. The real danger is that innocent-looking
+# operations may invoke arbitrary Python code which could do this;
+# there is a code path which allows control to flow back to the
+# user from a Py_DECREF(), so almost any operation is potentially
+# dangerous.
+#
+# A safe approach is to always use the generic operations
+# (functions whose name begins with "PyObject_", "PyNumber_",
+# "PySequence_" or "PyMapping_"). These operations always
+# increment the reference count of the object they return. This
+# leaves the caller with the responsibility to call Py_DECREF()
+# when they are done with the result; this soon becomes second
+# nature.
+#
+# Now you should read http://docs.python.org/api/refcountDetails.html
+# just to be sure you understand what is going on.
+#
+#################################################################
+
+from cpython.version cimport *
+from cpython.ref cimport *
+from cpython.exc cimport *
+from cpython.module cimport *
+from cpython.mem cimport *
+from cpython.tuple cimport *
+from cpython.list cimport *
+from cpython.object cimport *
+from cpython.sequence cimport *
+from cpython.mapping cimport *
+from cpython.iterator cimport *
+from cpython.type cimport *
+from cpython.number cimport *
+from cpython.int cimport *
+from cpython.bool cimport *
+from cpython.long cimport *
+from cpython.float cimport *
+from cpython.complex cimport *
+from cpython.string cimport *
+from cpython.unicode cimport *
+from cpython.dict cimport *
+from cpython.instance cimport *
+from cpython.function cimport *
+from cpython.method cimport *
+from cpython.weakref cimport *
+from cpython.getargs cimport *
+
+# Python <= 2.x
+from cpython.cobject cimport *
+from cpython.oldbuffer cimport *
+
+# Python >= 2.4
+from cpython.set cimport *
+
+# Python >= 2.6
+from cpython.buffer cimport *
+from cpython.bytes cimport *
+
+# Python >= 3.0
+from cpython.pycapsule cimport *
diff --git a/Cython/Includes/cpython/__init__.pyx b/Cython/Includes/cpython/__init__.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..fa81adaff68e06d8e915a6afa375f62f7e5a8fad
--- /dev/null
+++ b/Cython/Includes/cpython/__init__.pyx
@@ -0,0 +1 @@
+# empty file
diff --git a/Cython/Includes/cpython/bool.pxd b/Cython/Includes/cpython/bool.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..ebf65fe52eb5005d6b78f0b732e9cadab39de37f
--- /dev/null
+++ b/Cython/Includes/cpython/bool.pxd
@@ -0,0 +1,35 @@
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 7.2.2 Boolean Objects
+    ############################################################################
+
+    # Booleans in Python are implemented as a subclass of
+    # integers. There are only two booleans, Py_False and Py_True. As
+    # such, the normal creation and deletion functions don't apply to
+    # booleans. The following macros are available, however.
+
+    bint PyBool_Check(object o)
+    # Return true if o is of type PyBool_Type.
+
+    #PyObject* Py_False
+    # The Python False object. This object has no methods. It needs to
+    # be treated just like any other object with respect to reference
+    # counts.
+
+    #PyObject* Py_True
+    # The Python True object. This object has no methods. It needs to
+    # be treated just like any other object with respect to reference
+    # counts.
+
+    # Py_RETURN_FALSE
+    # Return Py_False from a function, properly incrementing its reference count. 
+
+    # Py_RETURN_TRUE
+    # Return Py_True from a function, properly incrementing its reference count. 
+
+    object PyBool_FromLong(long v)
+    # Return value: New reference.
+    # Return a new reference to Py_True or Py_False depending on the truth value of v. 
+
diff --git a/Cython/Includes/cpython/buffer.pxd b/Cython/Includes/cpython/buffer.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..654eb9694e30996aee90249bd7c87c441cb90b11
--- /dev/null
+++ b/Cython/Includes/cpython/buffer.pxd
@@ -0,0 +1,109 @@
+# Please see the Python header files (object.h/abstract.h) for docs
+
+cdef extern from "Python.h":
+
+    cdef enum:
+        PyBUF_SIMPLE,
+        PyBUF_WRITABLE,
+        PyBUF_WRITEABLE, # backwards compatability
+        PyBUF_FORMAT,
+        PyBUF_ND,
+        PyBUF_STRIDES,
+        PyBUF_C_CONTIGUOUS,
+        PyBUF_F_CONTIGUOUS,
+        PyBUF_ANY_CONTIGUOUS,
+        PyBUF_INDIRECT,
+        PyBUF_CONTIG,
+        PyBUF_CONTIG_RO,
+        PyBUF_STRIDED,
+        PyBUF_STRIDED_RO,
+        PyBUF_RECORDS,
+        PyBUF_RECORDS_RO,
+        PyBUF_FULL,
+        PyBUF_FULL_RO,
+        PyBUF_READ,
+        PyBUF_WRITE,
+        PyBUF_SHADOW
+
+    bint PyObject_CheckBuffer(object obj)
+    # Return 1 if obj supports the buffer interface otherwise 0.
+
+    int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) except -1
+    # Export obj into a Py_buffer, view. These arguments must never be
+    # NULL. The flags argument is a bit field indicating what kind of
+    # buffer the caller is prepared to deal with and therefore what
+    # kind of buffer the exporter is allowed to return. The buffer
+    # interface allows for complicated memory sharing possibilities,
+    # but some caller may not be able to handle all the complexity but
+    # may want to see if the exporter will let them take a simpler
+    # view to its memory.
+
+    # Some exporters may not be able to share memory in every possible
+    # way and may need to raise errors to signal to some consumers
+    # that something is just not possible. These errors should be a
+    # BufferError unless there is another error that is actually
+    # causing the problem. The exporter can use flags information to
+    # simplify how much of the Py_buffer structure is filled in with
+    # non-default values and/or raise an error if the object can’t
+    # support a simpler view of its memory.
+
+    # 0 is returned on success and -1 on error.
+
+    void PyBuffer_Release(object obj, object view)
+    # Release the buffer view over obj. This should be called when the
+    # buffer is no longer being used as it may free memory from it.
+
+    void* PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices)
+    # ??
+
+    int PyBuffer_SizeFromFormat(char *) # actually const char
+    # Return the implied ~Py_buffer.itemsize from the struct-stype
+    # ~Py_buffer.format
+
+    int PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort)
+    # ??
+
+    int PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
+    # ??
+
+    int PyObject_CopyToObject(object obj, void *buf, Py_ssize_t len, char fortran) except -1
+    # Copy len bytes of data pointed to by the contiguous chunk of
+    # memory pointed to by buf into the buffer exported by obj. The
+    # buffer must of course be writable. Return 0 on success and
+    # return -1 and raise an error on failure. If the object does not
+    # have a writable buffer, then an error is raised. If fortran is
+    # 'F', then if the object is multi-dimensional, then the data will
+    # be copied into the array in Fortran-style (first dimension
+    # varies the fastest). If fortran is 'C', then the data will be
+    # copied into the array in C-style (last dimension varies the
+    # fastest). If fortran is 'A', then it does not matter and the
+    # copy will be made in whatever way is more efficient.
+
+    int PyObject_CopyData(object dest, object src) except -1
+    # Copy the data from the src buffer to the buffer of destination
+
+    bint PyBuffer_IsContiguous(Py_buffer *view, char fort)
+    # Return 1 if the memory defined by the view is C-style (fortran
+    # is 'C') or Fortran-style (fortran is 'F') contiguous or either
+    # one (fortran is 'A'). Return 0 otherwise.
+
+    void PyBuffer_FillContiguousStrides(int ndims, 
+                                        Py_ssize_t *shape, 
+                                        Py_ssize_t *strides,
+                                        int itemsize,
+                                        char fort)
+    # Fill the strides array with byte-strides of a contiguous
+    # (Fortran-style if fort is 'F' or C-style otherwise) array of the
+    # given shape with the given number of bytes per element.
+
+    int PyBuffer_FillInfo(Py_buffer *view, void *buf,
+                          Py_ssize_t len, int readonly,
+                          int flags) except -1
+    # Fill in a buffer-info structure, view, correctly for an exporter
+    # that can only share a contiguous chunk of memory of “unsigned
+    # bytes” of the given length. Return 0 on success and -1 (with
+    # raising an error) on error.
+
+    object PyObject_Format(object obj, object format_spec)
+    # Takes an arbitrary object and returns the result of calling
+    # obj.__format__(format_spec).
diff --git a/Cython/Includes/cpython/bytes.pxd b/Cython/Includes/cpython/bytes.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..85d565b9a3b523b5e909fce784c8f7007831af52
--- /dev/null
+++ b/Cython/Includes/cpython/bytes.pxd
@@ -0,0 +1,198 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+    ctypedef struct va_list
+
+    ############################################################################
+    # 7.3.1 String Objects
+    ############################################################################
+
+    # These functions raise TypeError when expecting a string
+    # parameter and are called with a non-string parameter.
+    # PyStringObject
+    # This subtype of PyObject represents a Python bytes object. 
+    # PyTypeObject PyBytes_Type
+    # This instance of PyTypeObject represents the Python bytes type;
+    # it is the same object as bytes and types.BytesType in the Python
+    # layer. 
+
+    bint PyBytes_Check(object o)
+    # Return true if the object o is a string object or an instance of
+    # a subtype of the string type. 
+
+    bint PyBytes_CheckExact(object o)
+    # Return true if the object o is a string object, but not an instance of a subtype of the string type. 
+
+    object PyBytes_FromString(char *v)
+    # Return value: New reference.
+    # Return a new string object with the value v on success, and NULL
+    # on failure. The parameter v must not be NULL; it will not be
+    # checked.
+
+    object PyBytes_FromStringAndSize(char *v, Py_ssize_t len)
+    # Return value: New reference.
+    # Return a new string object with the value v and length len on
+    # success, and NULL on failure. If v is NULL, the contents of the
+    # string are uninitialized.
+
+    object PyBytes_FromFormat(char *format, ...)
+    # Return value: New reference.
+    # Take a C printf()-style format string and a variable number of
+    # arguments, calculate the size of the resulting Python string and
+    # return a string with the values formatted into it. The variable
+    # arguments must be C types and must correspond exactly to the
+    # format characters in the format string. The following format
+    # characters are allowed:
+    # Format Characters 	Type 	Comment
+    # %% 	n/a 	The literal % character.
+    # %c 	int 	A single character, represented as an C int.
+    # %d 	int 	Exactly equivalent to printf("%d").
+    # %u 	unsigned int 	Exactly equivalent to printf("%u").
+    # %ld 	long 	Exactly equivalent to printf("%ld").
+    # %lu 	unsigned long 	Exactly equivalent to printf("%lu").
+    # %zd 	Py_ssize_t 	Exactly equivalent to printf("%zd").
+    # %zu 	size_t 	Exactly equivalent to printf("%zu").
+    # %i 	int 	Exactly equivalent to printf("%i").
+    # %x 	int 	Exactly equivalent to printf("%x").
+    # %s 	char* 	A null-terminated C character array.
+
+    # %p 	void* 	The hex representation of a C pointer.
+    #    Mostly equivalent to printf("%p") except that it is guaranteed to
+    #    start with the literal 0x regardless of what the platform's printf
+    #    yields.
+    # An unrecognized format character causes all the rest of the
+    # format string to be copied as-is to the result string, and any
+    # extra arguments discarded.
+
+    object PyBytes_FromFormatV(char *format, va_list vargs)
+    # Return value: New reference.
+    # Identical to PyBytes_FromFormat() except that it takes exactly two arguments. 
+
+    Py_ssize_t PyBytes_Size(object string) except -1
+    # Return the length of the string in string object string. 
+
+    Py_ssize_t PyBytes_GET_SIZE(object string)
+    # Macro form of PyBytes_Size() but without error checking. 
+
+    char* PyBytes_AsString(object string) except NULL
+    # Return a NUL-terminated representation of the contents of
+    # string. The pointer refers to the internal buffer of string, not
+    # a copy. The data must not be modified in any way, unless the
+    # string was just created using PyBytes_FromStringAndSize(NULL,
+    # size). It must not be deallocated. If string is a Unicode
+    # object, this function computes the default encoding of string
+    # and operates on that. If string is not a string object at all,
+    # PyBytes_AsString() returns NULL and raises TypeError.
+
+    char* PyBytes_AS_STRING(object string)
+    # Macro form of PyBytes_AsString() but without error
+    # checking. Only string objects are supported; no Unicode objects
+    # should be passed.
+
+    int PyBytes_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
+    # Return a NULL-terminated representation of the contents of the
+    # object obj through the output variables buffer and length.
+    #
+    # The function accepts both string and Unicode objects as
+    # input. For Unicode objects it returns the default encoded
+    # version of the object. If length is NULL, the resulting buffer
+    # may not contain NUL characters; if it does, the function returns
+    # -1 and a TypeError is raised.
+    
+    # The buffer refers to an internal string buffer of obj, not a
+    # copy. The data must not be modified in any way, unless the
+    # string was just created using PyBytes_FromStringAndSize(NULL,
+    # size). It must not be deallocated. If string is a Unicode
+    # object, this function computes the default encoding of string
+    # and operates on that. If string is not a string object at all,
+    # PyBytes_AsStringAndSize() returns -1 and raises TypeError.
+
+    void PyBytes_Concat(PyObject **string, object newpart)
+    # Create a new string object in *string containing the contents of
+    # newpart appended to string; the caller will own the new
+    # reference. The reference to the old value of string will be
+    # stolen. If the new string cannot be created, the old reference
+    # to string will still be discarded and the value of *string will
+    # be set to NULL; the appropriate exception will be set.
+
+    void PyBytes_ConcatAndDel(PyObject **string, object newpart)
+    # Create a new string object in *string containing the contents of
+    # newpart appended to string. This version decrements the
+    # reference count of newpart.
+
+    int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
+    # A way to resize a string object even though it is
+    # ``immutable''. Only use this to build up a brand new string
+    # object; don't use this if the string may already be known in
+    # other parts of the code. It is an error to call this function if
+    # the refcount on the input string object is not one. Pass the
+    # address of an existing string object as an lvalue (it may be
+    # written into), and the new size desired. On success, *string
+    # holds the resized string object and 0 is returned; the address
+    # in *string may differ from its input value. If the reallocation
+    # fails, the original string object at *string is deallocated,
+    # *string is set to NULL, a memory exception is set, and -1 is
+    # returned.
+
+    object PyBytes_Format(object format, object args)
+    # Return value: New reference.  Return a new string object from
+    # format and args. Analogous to format % args. The args argument
+    # must be a tuple.
+
+    void PyBytes_InternInPlace(PyObject **string)
+    # Intern the argument *string in place. The argument must be the
+    # address of a pointer variable pointing to a Python string
+    # object. If there is an existing interned string that is the same
+    # as *string, it sets *string to it (decrementing the reference
+    # count of the old string object and incrementing the reference
+    # count of the interned string object), otherwise it leaves
+    # *string alone and interns it (incrementing its reference
+    # count). (Clarification: even though there is a lot of talk about
+    # reference counts, think of this function as
+    # reference-count-neutral; you own the object after the call if
+    # and only if you owned it before the call.)
+
+    object PyBytes_InternFromString(char *v)
+    # Return value: New reference.
+    # A combination of PyBytes_FromString() and
+    # PyBytes_InternInPlace(), returning either a new string object
+    # that has been interned, or a new (``owned'') reference to an
+    # earlier interned string object with the same value.
+
+    object PyBytes_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+    #  Return value: New reference.
+    # Create an object by decoding size bytes of the encoded buffer s
+    # using the codec registered for encoding. encoding and errors
+    # have the same meaning as the parameters of the same name in the
+    # unicode() built-in function. The codec to be used is looked up
+    # using the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+    object PyBytes_AsDecodedObject(object str, char *encoding, char *errors)
+    # Return value: New reference.
+    # Decode a string object by passing it to the codec registered for
+    # encoding and return the result as Python object. encoding and
+    # errors have the same meaning as the parameters of the same name
+    # in the string encode() method. The codec to be used is looked up
+    # using the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+    object PyBytes_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
+    # Return value: New reference.
+    # Encode the char buffer of the given size by passing it to the
+    # codec registered for encoding and return a Python
+    # object. encoding and errors have the same meaning as the
+    # parameters of the same name in the string encode() method. The
+    # codec to be used is looked up using the Python codec
+    # registry. Return NULL if an exception was raised by the codec.
+
+    object PyBytes_AsEncodedObject(object str, char *encoding, char *errors)
+    # Return value: New reference.
+    # Encode a string object using the codec registered for encoding
+    # and return the result as Python object. encoding and errors have
+    # the same meaning as the parameters of the same name in the
+    # string encode() method. The codec to be used is looked up using
+    # the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+
diff --git a/Cython/Includes/cpython/cobject.pxd b/Cython/Includes/cpython/cobject.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..62c47064f5493ac60e2cbeb6a5a12a777e777b19
--- /dev/null
+++ b/Cython/Includes/cpython/cobject.pxd
@@ -0,0 +1,37 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ###########################################################################
+    # Warning:
+    #
+    # The CObject API is deprecated as of Python 3.1. Please switch to
+    # the new Capsules API.
+    ###########################################################################
+
+    int PyCObject_Check(object p)
+    #     Return true if its argument is a PyCObject.
+
+    object PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
+    #     Return value: New reference.
+    #
+    #     Create a PyCObject from the void * cobj. The destr function will
+    #     be called when the object is reclaimed, unless it is NULL.
+
+    object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
+    #     Return value: New reference.
+    #
+    #     Create a PyCObject from the void * cobj. The destr function will
+    #     be called when the object is reclaimed. The desc argument can be
+    #     used to pass extra callback data for the destructor function.
+
+    void* PyCObject_AsVoidPtr(object self) except? NULL
+    #     Return the object void * that the PyCObject self was created with.
+
+    void* PyCObject_GetDesc(object self) except? NULL
+    #     Return the description void * that the PyCObject self was created with.
+
+    int PyCObject_SetVoidPtr(object self, void* cobj) except 0
+    #     Set the void pointer inside self to cobj. The PyCObject must not
+    #     have an associated destructor. Return true on success, false on
+    #     failure.
diff --git a/Cython/Includes/cpython/complex.pxd b/Cython/Includes/cpython/complex.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..116698d91b5818d7801f6fd33e6373bd18705fc8
--- /dev/null
+++ b/Cython/Includes/cpython/complex.pxd
@@ -0,0 +1,41 @@
+
+cdef extern from "Python.h":
+    ctypedef struct Py_complex
+
+    ############################################################################
+    # 7.2.5.2 Complex Numbers as Python Objects
+    ############################################################################
+
+    # PyComplexObject
+    # This subtype of PyObject represents a Python complex number object. 
+
+    # PyTypeObject PyComplex_Type
+    # This instance of PyTypeObject represents the Python complex
+    # number type. It is the same object as complex and
+    # types.ComplexType.
+
+    bint PyComplex_Check(object p)
+    # Return true if its argument is a PyComplexObject or a subtype of
+    # PyComplexObject.
+
+    bint PyComplex_CheckExact(object p)
+    # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
+
+    object PyComplex_FromCComplex(Py_complex v)
+    # Return value: New reference.
+    # Create a new Python complex number object from a C Py_complex value. 
+
+    object PyComplex_FromDoubles(double real, double imag)
+    # Return value: New reference.
+    # Return a new PyComplexObject object from real and imag. 
+
+    double PyComplex_RealAsDouble(object op) except? -1
+    # Return the real part of op as a C double. 
+
+    double PyComplex_ImagAsDouble(object op) except? -1
+    # Return the imaginary part of op as a C double. 
+
+    Py_complex PyComplex_AsCComplex(object op)
+    # Return the Py_complex value of the complex number op.
+    #
+    # Returns (-1+0i) in case of an error
diff --git a/Cython/Includes/cpython/dict.pxd b/Cython/Includes/cpython/dict.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..4f39cdfe5c322e6106ebb6c13377a5951c9d5ca0
--- /dev/null
+++ b/Cython/Includes/cpython/dict.pxd
@@ -0,0 +1,165 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 7.4.1 Dictionary Objects
+    ############################################################################
+
+    # PyDictObject
+    #
+    # This subtype of PyObject represents a Python dictionary object
+    # (i.e. the 'dict' type).
+    
+    # PyTypeObject PyDict_Type
+    #
+    # This instance of PyTypeObject represents the Python dictionary
+    # type. This is exposed to Python programs as dict and
+    # types.DictType.
+
+    bint PyDict_Check(object p)
+    # Return true if p is a dict object or an instance of a subtype of
+    # the dict type. 
+
+    bint PyDict_CheckExact(object p)
+    # Return true if p is a dict object, but not an instance of a
+    # subtype of the dict type.
+
+    object PyDict_New()
+    # Return value: New reference.
+    # Return a new empty dictionary, or NULL on failure. 
+
+    object PyDictProxy_New(object dict)
+    # Return value: New reference.
+    # Return a proxy object for a mapping which enforces read-only
+    # behavior. This is normally used to create a proxy to prevent
+    # modification of the dictionary for non-dynamic class types. 
+
+    void PyDict_Clear(object p)
+    # Empty an existing dictionary of all key-value pairs. 
+
+    int PyDict_Contains(object p, object key) except -1
+    # Determine if dictionary p contains key. If an item in p is
+    # matches key, return 1, otherwise return 0. On error, return
+    # -1. This is equivalent to the Python expression "key in p". 
+
+    object PyDict_Copy(object p)
+    # Return value: New reference.
+    # Return a new dictionary that contains the same key-value pairs as p.
+
+    int PyDict_SetItem(object p, object key, object val) except -1
+    # Insert value into the dictionary p with a key of key. key must
+    # be hashable; if it isn't, TypeError will be raised. Return 0 on
+    # success or -1 on failure.
+
+    int PyDict_SetItemString(object p, char *key, object val) except -1
+    # Insert value into the dictionary p using key as a key. key
+    # should be a char*. The key object is created using
+    # PyString_FromString(key). Return 0 on success or -1 on failure.
+
+    int PyDict_DelItem(object p, object key) except -1
+    # Remove the entry in dictionary p with key key. key must be
+    # hashable; if it isn't, TypeError is raised. Return 0 on success
+    # or -1 on failure.
+
+    int PyDict_DelItemString(object p, char *key) except -1
+    # Remove the entry in dictionary p which has a key specified by
+    # the string key. Return 0 on success or -1 on failure.
+
+    PyObject* PyDict_GetItem(object p, object key)
+    # Return value: Borrowed reference.
+    # Return the object from dictionary p which has a key key. Return
+    # NULL if the key key is not present, but without setting an
+    # exception.
+
+    PyObject* PyDict_GetItemString(object p, char *key)
+    # Return value: Borrowed reference.
+    # This is the same as PyDict_GetItem(), but key is specified as a
+    # char*, rather than a PyObject*.
+
+    object PyDict_Items(object p)
+    # Return value: New reference.
+    # Return a PyListObject containing all the items from the
+    # dictionary, as in the dictionary method items() (see the Python
+    # Library Reference).
+
+    object PyDict_Keys(object p)
+    # Return value: New reference.
+    # Return a PyListObject containing all the keys from the
+    # dictionary, as in the dictionary method keys() (see the Python
+    # Library Reference).
+
+    object PyDict_Values(object p)
+    # Return value: New reference.
+    # Return a PyListObject containing all the values from the
+    # dictionary p, as in the dictionary method values() (see the
+    # Python Library Reference).
+
+    Py_ssize_t PyDict_Size(object p) except -1
+    # Return the number of items in the dictionary. This is equivalent
+    # to "len(p)" on a dictionary.
+
+    int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue)
+    # Iterate over all key-value pairs in the dictionary p. The int
+    # referred to by ppos must be initialized to 0 prior to the first
+    # call to this function to start the iteration; the function
+    # returns true for each pair in the dictionary, and false once all
+    # pairs have been reported. The parameters pkey and pvalue should
+    # either point to PyObject* variables that will be filled in with
+    # each key and value, respectively, or may be NULL. Any references
+    # returned through them are borrowed. ppos should not be altered
+    # during iteration. Its value represents offsets within the
+    # internal dictionary structure, and since the structure is
+    # sparse, the offsets are not consecutive.
+    # For example:
+    #
+    #object key, *value;
+    #int pos = 0;
+    #
+    #while (PyDict_Next(self->dict, &pos, &key, &value)) {
+    #   /* do something interesting with the values... */
+    #    ...
+    #}
+    # The dictionary p should not be mutated during iteration. It is
+    # safe (since Python 2.1) to modify the values of the keys as you
+    # iterate over the dictionary, but only so long as the set of keys
+    # does not change. For example:
+    # object key, *value;
+    # int pos = 0;
+    # while (PyDict_Next(self->dict, &pos, &key, &value)) {
+    #    int i = PyInt_AS_LONG(value) + 1;
+    #    object o = PyInt_FromLong(i);
+    #    if (o == NULL)
+    #        return -1;
+    #    if (PyDict_SetItem(self->dict, key, o) < 0) {
+    #        Py_DECREF(o);
+    #        return -1;
+    #    }
+    #    Py_DECREF(o);
+    # }
+
+    int PyDict_Merge(object a, object b, int override) except -1
+    # Iterate over mapping object b adding key-value pairs to
+    # dictionary a. b may be a dictionary, or any object supporting
+    # PyMapping_Keys() and PyObject_GetItem(). If override is true,
+    # existing pairs in a will be replaced if a matching key is found
+    # in b, otherwise pairs will only be added if there is not a
+    # matching key in a. Return 0 on success or -1 if an exception was
+    # raised.
+
+    int PyDict_Update(object a, object b) except -1
+    # This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b)
+    # in Python. Return 0 on success or -1 if an exception was raised.
+
+    int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1
+    # Update or merge into dictionary a, from the key-value pairs in
+    # seq2. seq2 must be an iterable object producing iterable objects
+    # of length 2, viewed as key-value pairs. In case of duplicate
+    # keys, the last wins if override is true, else the first
+    # wins. Return 0 on success or -1 if an exception was
+    # raised. Equivalent Python (except for the return value):
+    #
+    #def PyDict_MergeFromSeq2(a, seq2, override):
+    #    for key, value in seq2:
+    #        if override or key not in a:
+    #            a[key] = value
diff --git a/Cython/Includes/cpython/exc.pxd b/Cython/Includes/cpython/exc.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..71d277db554af33971b3f1eb85a0efc3c2f876e0
--- /dev/null
+++ b/Cython/Includes/cpython/exc.pxd
@@ -0,0 +1,250 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+    
+    #####################################################################
+    # 3. Exception Handling
+    #####################################################################
+
+    # The functions described in this chapter will let you handle and
+    # raise Python exceptions. It is important to understand some of
+    # the basics of Python exception handling. It works somewhat like
+    # the Unix errno variable: there is a global indicator (per
+    # thread) of the last error that occurred. Most functions don't
+    # clear this on success, but will set it to indicate the cause of
+    # the error on failure. Most functions also return an error
+    # indicator, usually NULL if they are supposed to return a
+    # pointer, or -1 if they return an integer (exception: the
+    # PyArg_*() functions return 1 for success and 0 for failure).
+
+    # When a function must fail because some function it called
+    # failed, it generally doesn't set the error indicator; the
+    # function it called already set it. It is responsible for either
+    # handling the error and clearing the exception or returning after
+    # cleaning up any resources it holds (such as object references or
+    # memory allocations); it should not continue normally if it is
+    # not prepared to handle the error. If returning due to an error,
+    # it is important to indicate to the caller that an error has been
+    # set. If the error is not handled or carefully propagated,
+    # additional calls into the Python/C API may not behave as
+    # intended and may fail in mysterious ways.
+
+    # The error indicator consists of three Python objects
+    # corresponding to the Python variables sys.exc_type,
+    # sys.exc_value and sys.exc_traceback. API functions exist to
+    # interact with the error indicator in various ways. There is a
+    # separate error indicator for each thread.
+
+    void PyErr_Print()
+    # Print a standard traceback to sys.stderr and clear the error
+    # indicator. Call this function only when the error indicator is
+    # set. (Otherwise it will cause a fatal error!)
+
+    PyObject* PyErr_Occurred()
+    # Return value: Borrowed reference.
+    # Test whether the error indicator is set. If set, return the
+    # exception type (the first argument to the last call to one of
+    # the PyErr_Set*() functions or to PyErr_Restore()). If not set,
+    # return NULL. You do not own a reference to the return value, so
+    # you do not need to Py_DECREF() it. Note: Do not compare the
+    # return value to a specific exception; use
+    # PyErr_ExceptionMatches() instead, shown below. (The comparison
+    # could easily fail since the exception may be an instance instead
+    # of a class, in the case of a class exception, or it may the a
+    # subclass of the expected exception.)
+
+    bint PyErr_ExceptionMatches(object exc)
+    # Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(),
+    # exc)". This should only be called when an exception is actually
+    # set; a memory access violation will occur if no exception has
+    # been raised.
+
+    bint PyErr_GivenExceptionMatches(object given, object exc)
+    # Return true if the given exception matches the exception in
+    # exc. If exc is a class object, this also returns true when given
+    # is an instance of a subclass. If exc is a tuple, all exceptions
+    # in the tuple (and recursively in subtuples) are searched for a
+    # match. If given is NULL, a memory access violation will occur.
+
+    void PyErr_NormalizeException(PyObject** exc, PyObject** val, PyObject** tb)
+    # Under certain circumstances, the values returned by
+    # PyErr_Fetch() below can be ``unnormalized'', meaning that *exc
+    # is a class object but *val is not an instance of the same
+    # class. This function can be used to instantiate the class in
+    # that case. If the values are already normalized, nothing
+    # happens. The delayed normalization is implemented to improve
+    # performance.
+
+    void PyErr_Clear()
+    # Clear the error indicator. If the error indicator is not set, there is no effect. 
+
+    void PyErr_Fetch(PyObject** ptype, PyObject** pvalue, PyObject** ptraceback)
+    # Retrieve the error indicator into three variables whose
+    # addresses are passed. If the error indicator is not set, set all
+    # three variables to NULL. If it is set, it will be cleared and
+    # you own a reference to each object retrieved. The value and
+    # traceback object may be NULL even when the type object is
+    # not. Note: This function is normally only used by code that
+    # needs to handle exceptions or by code that needs to save and
+    # restore the error indicator temporarily.
+
+    void PyErr_Restore(PyObject* type, PyObject* value, PyObject* traceback)
+    # Set the error indicator from the three objects. If the error
+    # indicator is already set, it is cleared first. If the objects
+    # are NULL, the error indicator is cleared. Do not pass a NULL
+    # type and non-NULL value or traceback. The exception type should
+    # be a class. Do not pass an invalid exception type or
+    # value. (Violating these rules will cause subtle problems later.)
+    # This call takes away a reference to each object: you must own a
+    # reference to each object before the call and after the call you
+    # no longer own these references. (If you don't understand this,
+    # don't use this function. I warned you.) Note: This function is
+    # normally only used by code that needs to save and restore the
+    # error indicator temporarily; use PyErr_Fetch() to save the
+    # current exception state.
+
+    void PyErr_SetString(object type, char *message)
+    # This is the most common way to set the error indicator. The
+    # first argument specifies the exception type; it is normally one
+    # of the standard exceptions, e.g. PyExc_RuntimeError. You need
+    # not increment its reference count. The second argument is an
+    # error message; it is converted to a string object.
+
+    void PyErr_SetObject(object type, object value)
+    # This function is similar to PyErr_SetString() but lets you
+    # specify an arbitrary Python object for the ``value'' of the
+    # exception.
+
+    PyObject* PyErr_Format(object exception, char *format, ...) except NULL
+    # Return value: Always NULL.
+    # This function sets the error indicator and returns
+    # NULL. exception should be a Python exception (class, not an
+    # instance). format should be a string, containing format codes,
+    # similar to printf(). The width.precision before a format code is
+    # parsed, but the width part is ignored.
+
+    void PyErr_SetNone(object type)
+    # This is a shorthand for "PyErr_SetObject(type, Py_None)". 
+
+    int PyErr_BadArgument() except 0
+
+    # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
+    # message)", where message indicates that a built-in operation was
+    # invoked with an illegal argument. It is mostly for internal use.
+
+    PyObject* PyErr_NoMemory() except NULL
+    # Return value: Always NULL.
+    # This is a shorthand for "PyErr_SetNone(PyExc_MemoryError)"; it
+    # returns NULL so an object allocation function can write "return
+    # PyErr_NoMemory();" when it runs out of memory.
+
+    PyObject* PyErr_SetFromErrno(object type) except NULL
+    # Return value: Always NULL.
+    # This is a convenience function to raise an exception when a C
+    # library function has returned an error and set the C variable
+    # errno. It constructs a tuple object whose first item is the
+    # integer errno value and whose second item is the corresponding
+    # error message (gotten from strerror()), and then calls
+    # "PyErr_SetObject(type, object)". On Unix, when the errno value
+    # is EINTR, indicating an interrupted system call, this calls
+    # PyErr_CheckSignals(), and if that set the error indicator,
+    # leaves it set to that. The function always returns NULL, so a
+    # wrapper function around a system call can write "return
+    # PyErr_SetFromErrno(type);" when the system call returns an
+    # error.
+
+    PyObject* PyErr_SetFromErrnoWithFilename(object type, char *filename) except NULL
+    # Return value: Always NULL.  Similar to PyErr_SetFromErrno(),
+    # with the additional behavior that if filename is not NULL, it is
+    # passed to the constructor of type as a third parameter. In the
+    # case of exceptions such as IOError and OSError, this is used to
+    # define the filename attribute of the exception instance.
+
+    PyObject* PyErr_SetFromWindowsErr(int ierr) except NULL
+    # Return value: Always NULL.  This is a convenience function to
+    # raise WindowsError. If called with ierr of 0, the error code
+    # returned by a call to GetLastError() is used instead. It calls
+    # the Win32 function FormatMessage() to retrieve the Windows
+    # description of error code given by ierr or GetLastError(), then
+    # it constructs a tuple object whose first item is the ierr value
+    # and whose second item is the corresponding error message (gotten
+    # from FormatMessage()), and then calls
+    # "PyErr_SetObject(PyExc_WindowsError, object)". This function
+    # always returns NULL. Availability: Windows.
+
+    PyObject* PyErr_SetExcFromWindowsErr(object type, int ierr) except NULL
+    # Return value: Always NULL.  Similar to
+    # PyErr_SetFromWindowsErr(), with an additional parameter
+    # specifying the exception type to be raised. Availability:
+    # Windows. New in version 2.3.
+
+    PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, char *filename) except NULL
+    # Return value: Always NULL.  Similar to
+    # PyErr_SetFromWindowsErr(), with the additional behavior that if
+    # filename is not NULL, it is passed to the constructor of
+    # WindowsError as a third parameter. Availability: Windows.
+
+    PyObject* PyErr_SetExcFromWindowsErrWithFilename(object type, int ierr, char *filename) except NULL
+    # Return value: Always NULL.
+    # Similar to PyErr_SetFromWindowsErrWithFilename(), with an
+    # additional parameter specifying the exception type to be
+    # raised. Availability: Windows.
+
+    void PyErr_BadInternalCall()
+    # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
+    # message)", where message indicates that an internal operation
+    # (e.g. a Python/C API function) was invoked with an illegal
+    # argument. It is mostly for internal use.
+
+    int PyErr_WarnEx(object category, char *message, int stacklevel) except -1
+    # Issue a warning message. The category argument is a warning
+    # category (see below) or NULL; the message argument is a message
+    # string. stacklevel is a positive number giving a number of stack
+    # frames; the warning will be issued from the currently executing
+    # line of code in that stack frame. A stacklevel of 1 is the
+    # function calling PyErr_WarnEx(), 2 is the function above that,
+    # and so forth.
+
+    int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) except -1
+    # Issue a warning message with explicit control over all warning
+    # attributes. This is a straightforward wrapper around the Python
+    # function warnings.warn_explicit(), see there for more
+    # information. The module and registry arguments may be set to
+    # NULL to get the default effect described there.
+
+    int PyErr_CheckSignals() except -1
+    # This function interacts with Python's signal handling. It checks
+    # whether a signal has been sent to the processes and if so,
+    # invokes the corresponding signal handler. If the signal module
+    # is supported, this can invoke a signal handler written in
+    # Python. In all cases, the default effect for SIGINT is to raise
+    # the KeyboardInterrupt exception. If an exception is raised the
+    # error indicator is set and the function returns 1; otherwise the
+    # function returns 0. The error indicator may or may not be
+    # cleared if it was previously set.
+
+    void PyErr_SetInterrupt()
+    # This function simulates the effect of a SIGINT signal arriving
+    # -- the next time PyErr_CheckSignals() is called,
+    # KeyboardInterrupt will be raised. It may be called without
+    # holding the interpreter lock.
+
+    object PyErr_NewException(char *name, object base, object dict)
+    # Return value: New reference.
+    # This utility function creates and returns a new exception
+    # object. The name argument must be the name of the new exception,
+    # a C string of the form module.class. The base and dict arguments
+    # are normally NULL. This creates a class object derived from
+    # Exception (accessible in C as PyExc_Exception).
+
+    void PyErr_WriteUnraisable(object obj)
+    # This utility function prints a warning message to sys.stderr
+    # when an exception has been set but it is impossible for the
+    # interpreter to actually raise the exception. It is used, for
+    # example, when an exception occurs in an __del__() method.
+    #
+    # The function is called with a single argument obj that
+    # identifies the context in which the unraisable exception
+    # occurred. The repr of obj will be printed in the warning
+    # message.
+
diff --git a/Cython/Includes/cpython/float.pxd b/Cython/Includes/cpython/float.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..602cc816d59aaee69c54d631fe38aa62af07f916
--- /dev/null
+++ b/Cython/Includes/cpython/float.pxd
@@ -0,0 +1,39 @@
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 7.2.3 
+    ############################################################################
+    # PyFloatObject
+    #
+    # This subtype of PyObject represents a Python floating point object.
+    
+    # PyTypeObject PyFloat_Type
+    #
+    # This instance of PyTypeObject represents the Python floating
+    # point type. This is the same object as float and
+    # types.FloatType.
+
+    bint PyFloat_Check(object p)
+    # Return true if its argument is a PyFloatObject or a subtype of
+    # PyFloatObject.
+
+    bint PyFloat_CheckExact(object p)
+    # Return true if its argument is a PyFloatObject, but not a
+    # subtype of PyFloatObject. 
+
+    object PyFloat_FromString(object str, char **pend)
+    # Return value: New reference.
+    # Create a PyFloatObject object based on the string value in str,
+    # or NULL on failure. The pend argument is ignored. It remains
+    # only for backward compatibility.
+
+    object PyFloat_FromDouble(double v)
+    # Return value: New reference.
+    # Create a PyFloatObject object from v, or NULL on failure. 
+
+    double PyFloat_AsDouble(object pyfloat) except? -1
+    # Return a C double representation of the contents of pyfloat.
+
+    double PyFloat_AS_DOUBLE(object pyfloat) except? -1
+    # Return a C double representation of the contents of pyfloat, but
+    # without error checking.
diff --git a/Cython/Includes/cpython/function.pxd b/Cython/Includes/cpython/function.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..375c084c4232230aca1af0fb96567f9d5827e9f4
--- /dev/null
+++ b/Cython/Includes/cpython/function.pxd
@@ -0,0 +1,65 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 7.5.3 Function Objects
+    ############################################################################
+    # There are a few functions specific to Python functions.
+
+    # PyFunctionObject
+    #
+    # The C structure used for functions.
+
+    # PyTypeObject PyFunction_Type
+    #
+    # This is an instance of PyTypeObject and represents the Python
+    # function type. It is exposed to Python programmers as
+    # types.FunctionType.
+
+    bint PyFunction_Check(object o)
+    # Return true if o is a function object (has type
+    # PyFunction_Type). The parameter must not be NULL.
+
+    object PyFunction_New(object code, object globals)
+    # Return value: New reference.
+    # Return a new function object associated with the code object
+    # code. globals must be a dictionary with the global variables
+    # accessible to the function.
+    # The function's docstring, name and __module__ are retrieved from
+    # the code object, the argument defaults and closure are set to
+    # NULL.
+
+    PyObject* PyFunction_GetCode(object op) except? NULL
+    # Return value: Borrowed reference.
+    # Return the code object associated with the function object op. 
+
+    PyObject* PyFunction_GetGlobals(object op) except? NULL
+    # Return value: Borrowed reference.
+    # Return the globals dictionary associated with the function object op. 
+
+    PyObject* PyFunction_GetModule(object op) except? NULL
+    # Return value: Borrowed reference.
+    # Return the __module__ attribute of the function object op. This
+    # is normally a string containing the module name, but can be set
+    # to any other object by Python code.
+
+    PyObject* PyFunction_GetDefaults(object op) except? NULL
+    # Return value: Borrowed reference.
+    # Return the argument default values of the function object
+    # op. This can be a tuple of arguments or NULL.
+
+    int PyFunction_SetDefaults(object op, object defaults) except -1
+    # Set the argument default values for the function object
+    # op. defaults must be Py_None or a tuple.
+    # Raises SystemError and returns -1 on failure. 
+
+    PyObject* PyFunction_GetClosure(object op) except? NULL
+    # Return value: Borrowed reference.
+    # Return the closure associated with the function object op. This
+    # can be NULL or a tuple of cell objects.
+
+    int PyFunction_SetClosure(object op, object closure) except -1
+    # Set the closure associated with the function object op. closure
+    # must be Py_None or a tuple of cell objects.
+    # Raises SystemError and returns -1 on failure. 
diff --git a/Cython/Includes/cpython/getargs.pxd b/Cython/Includes/cpython/getargs.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..591aefbfdeda65dc902c679d6d3a19a1c0c1f0ed
--- /dev/null
+++ b/Cython/Includes/cpython/getargs.pxd
@@ -0,0 +1,13 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+    #####################################################################
+    # 5.5 Parsing arguments and building values
+    #####################################################################
+    ctypedef struct va_list
+    int PyArg_ParseTuple(object args, char *format, ...) except 0
+    int PyArg_VaParse(object args, char *format, va_list vargs) except 0
+    int PyArg_ParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], ...) except 0
+    int PyArg_VaParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], va_list vargs) except 0
+    int PyArg_Parse(object args, char *format, ...) except 0
+    int PyArg_UnpackTuple(object args, char *name, Py_ssize_t min, Py_ssize_t max, ...) except 0
diff --git a/Cython/Includes/cpython/instance.pxd b/Cython/Includes/cpython/instance.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..4160cbe6a0a5fb948056536ef866777d1fa77504
--- /dev/null
+++ b/Cython/Includes/cpython/instance.pxd
@@ -0,0 +1,25 @@
+cdef extern from "Python.h":
+    
+    ############################################################################
+    # 7.5.2 Instance Objects
+    ############################################################################
+
+    # PyTypeObject PyInstance_Type
+    #
+    # Type object for class instances.
+    
+    int PyInstance_Check(object obj)
+    # Return true if obj is an instance. 
+
+    object PyInstance_New(object cls, object arg, object kw)
+    # Return value: New reference.
+    # Create a new instance of a specific class. The parameters arg
+    # and kw are used as the positional and keyword parameters to the
+    # object's constructor.
+
+    object PyInstance_NewRaw(object cls, object dict)
+    # Return value: New reference.
+    # Create a new instance of a specific class without calling its
+    # constructor. class is the class of new object. The dict
+    # parameter will be used as the object's __dict__; if NULL, a new
+    # dictionary will be created for the instance.
diff --git a/Cython/Includes/cpython/int.pxd b/Cython/Includes/cpython/int.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..bc87c6032de93087d6512b7c03908f3709117e36
--- /dev/null
+++ b/Cython/Includes/cpython/int.pxd
@@ -0,0 +1,79 @@
+cdef extern from "Python.h":
+    ctypedef unsigned long long PY_LONG_LONG
+
+    ############################################################################
+    # Integer Objects
+    ############################################################################
+    # PyTypeObject PyInt_Type
+    # This instance of PyTypeObject represents the Python plain
+    # integer type. This is the same object as int and types.IntType.
+
+    bint PyInt_Check(object  o)
+    # Return true if o is of type PyInt_Type or a subtype of
+    # PyInt_Type.
+
+    bint PyInt_CheckExact(object  o)
+    # Return true if o is of type PyInt_Type, but not a subtype of
+    # PyInt_Type.
+
+    object PyInt_FromString(char *str, char **pend, int base)
+    # Return value: New reference.
+    # Return a new PyIntObject or PyLongObject based on the string
+    # value in str, which is interpreted according to the radix in
+    # base. If pend is non-NULL, *pend will point to the first
+    # character in str which follows the representation of the
+    # number. If base is 0, the radix will be determined based on the
+    # leading characters of str: if str starts with '0x' or '0X',
+    # radix 16 will be used; if str starts with '0', radix 8 will be
+    # used; otherwise radix 10 will be used. If base is not 0, it must
+    # be between 2 and 36, inclusive. Leading spaces are ignored. If
+    # there are no digits, ValueError will be raised. If the string
+    # represents a number too large to be contained within the
+    # machine's long int type and overflow warnings are being
+    # suppressed, a PyLongObject will be returned. If overflow
+    # warnings are not being suppressed, NULL will be returned in this
+    # case.
+
+    object PyInt_FromLong(long ival)
+    # Return value: New reference.
+    # Create a new integer object with a value of ival.
+    # The current implementation keeps an array of integer objects for
+    # all integers between -5 and 256, when you create an int in that
+    # range you actually just get back a reference to the existing
+    # object. So it should be possible to change the value of 1. I
+    # suspect the behaviour of Python in this case is undefined. :-)
+
+    object PyInt_FromSsize_t(Py_ssize_t ival)
+    # Return value: New reference.
+    # Create a new integer object with a value of ival. If the value
+    # exceeds LONG_MAX, a long integer object is returned.
+
+    long PyInt_AsLong(object io) except? -1
+    # Will first attempt to cast the object to a PyIntObject, if it is
+    # not already one, and then return its value. If there is an
+    # error, -1 is returned, and the caller should check
+    # PyErr_Occurred() to find out whether there was an error, or
+    # whether the value just happened to be -1.
+
+    long PyInt_AS_LONG(object io)
+    # Return the value of the object io. No error checking is performed. 
+
+    unsigned long PyInt_AsUnsignedLongMask(object io) except? -1
+    # Will first attempt to cast the object to a PyIntObject or
+    # PyLongObject, if it is not already one, and then return its
+    # value as unsigned long. This function does not check for
+    # overflow. 
+
+    PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1
+    # Will first attempt to cast the object to a PyIntObject or
+    # PyLongObject, if it is not already one, and then return its
+    # value as unsigned long long, without checking for overflow. 
+
+    Py_ssize_t PyInt_AsSsize_t(object io) except? -1
+    # Will first attempt to cast the object to a PyIntObject or
+    # PyLongObject, if it is not already one, and then return its
+    # value as Py_ssize_t.
+
+    long PyInt_GetMax()
+    # Return the system's idea of the largest integer it can handle
+    # (LONG_MAX, as defined in the system header files).
diff --git a/Cython/Includes/cpython/iterator.pxd b/Cython/Includes/cpython/iterator.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..94ae1f623d3d270710dd109bea64edb3f8547cdc
--- /dev/null
+++ b/Cython/Includes/cpython/iterator.pxd
@@ -0,0 +1,36 @@
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 6.5 Iterator Protocol
+    ############################################################################
+    bint PyIter_Check(object o)
+    # Return true if the object o supports the iterator protocol. 
+
+    object PyIter_Next(object o)
+    # Return value: New reference.
+    # Return the next value from the iteration o. If the object is an
+    # iterator, this retrieves the next value from the iteration, and
+    # returns NULL with no exception set if there are no remaining
+    # items. If the object is not an iterator, TypeError is raised, or
+    # if there is an error in retrieving the item, returns NULL and
+    # passes along the exception.
+
+    # To write a loop which iterates over an iterator, the C code should look something like this:
+    # PyObject *iterator = PyObject_GetIter(obj);
+    # PyObject *item;
+    # if (iterator == NULL) {
+    # /* propagate error */
+    # }
+    # while (item = PyIter_Next(iterator)) {
+    # /* do something with item */
+    # ...
+    # /* release reference when done */
+    # Py_DECREF(item);
+    # }
+    # Py_DECREF(iterator);
+    # if (PyErr_Occurred()) {
+    # /* propagate error */
+    # }
+    # else {
+    # /* continue doing useful work */
+    # }
diff --git a/Cython/Includes/cpython/list.pxd b/Cython/Includes/cpython/list.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..16c8076be21e88c0471a674e6270e3e39c252b12
--- /dev/null
+++ b/Cython/Includes/cpython/list.pxd
@@ -0,0 +1,92 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # Lists
+    ############################################################################
+    object PyList_New(Py_ssize_t len)
+    # Return a new list of length len on success, or NULL on failure.
+    #
+    # Note: If length is greater than zero, the returned list object's
+    # items are set to NULL. Thus you cannot use abstract API
+    # functions such as PySequence_SetItem() or expose the object to
+    # Python code before setting all items to a real object with
+    # PyList_SetItem().
+    
+    bint PyList_Check(object p)
+    # Return true if p is a list object or an instance of a subtype of
+    # the list type.
+    
+    bint PyList_CheckExact(object p)
+    # Return true if p is a list object, but not an instance of a
+    # subtype of the list type.
+
+    Py_ssize_t PyList_Size(object list) except -1
+    # Return the length of the list object in list; this is equivalent
+    # to "len(list)" on a list object.
+
+    Py_ssize_t PyList_GET_SIZE(object list)
+    # Macro form of PyList_Size() without error checking. 
+
+    PyObject* PyList_GetItem(object list, Py_ssize_t index) except NULL
+    # Return value: Borrowed reference.  
+    # Return the object at position pos in the list pointed to by
+    # p. The position must be positive, indexing from the end of the
+    # list is not supported. If pos is out of bounds, return NULL and
+    # set an IndexError exception.
+
+    PyObject* PyList_GET_ITEM(object list, Py_ssize_t i)
+    # Return value: Borrowed reference.
+    # Macro form of PyList_GetItem() without error checking. 
+
+    int PyList_SetItem(object list, Py_ssize_t index, object item) except -1
+    # Set the item at index index in list to item. Return 0 on success
+    # or -1 on failure. Note: This function ``steals'' a reference to
+    # item and discards a reference to an item already in the list at
+    # the affected position.
+
+    void PyList_SET_ITEM(object list, Py_ssize_t i, object o)
+    # Macro form of PyList_SetItem() without error checking. This is
+    # normally only used to fill in new lists where there is no
+    # previous content. Note: This function ``steals'' a reference to
+    # item, and, unlike PyList_SetItem(), does not discard a reference
+    # to any item that it being replaced; any reference in list at
+    # position i will be *leaked*.
+
+    int PyList_Insert(object list, Py_ssize_t index, object item) except -1
+    # Insert the item item into list list in front of index
+    # index. Return 0 if successful; return -1 and set an exception if
+    # unsuccessful. Analogous to list.insert(index, item).
+
+    int PyList_Append(object list, object item) except -1
+    # Append the object item at the end of list list. Return 0 if
+    # successful; return -1 and set an exception if
+    # unsuccessful. Analogous to list.append(item).
+
+    object PyList_GetSlice(object list, Py_ssize_t low, Py_ssize_t high)
+    # Return value: New reference.
+    # Return a list of the objects in list containing the objects
+    # between low and high. Return NULL and set an exception if
+    # unsuccessful. Analogous to list[low:high].
+
+    int PyList_SetSlice(object list, Py_ssize_t low, Py_ssize_t high, object itemlist) except -1
+    # Set the slice of list between low and high to the contents of
+    # itemlist. Analogous to list[low:high] = itemlist. The itemlist
+    # may be NULL, indicating the assignment of an empty list (slice
+    # deletion). Return 0 on success, -1 on failure.
+
+    int PyList_Sort(object list) except -1
+    # Sort the items of list in place. Return 0 on success, -1 on
+    # failure. This is equivalent to "list.sort()".
+
+    int PyList_Reverse(object list) except -1
+    # Reverse the items of list in place. Return 0 on success, -1 on
+    # failure. This is the equivalent of "list.reverse()".
+
+    object PyList_AsTuple(object list)
+    # Return value: New reference.
+    # Return a new tuple object containing the contents of list;
+    # equivalent to "tuple(list)".
+
+
diff --git a/Cython/Includes/cpython/long.pxd b/Cython/Includes/cpython/long.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..31134d6dd96f019456d4a4d36caec7c23bf51d24
--- /dev/null
+++ b/Cython/Includes/cpython/long.pxd
@@ -0,0 +1,115 @@
+from cpython.unicode cimport Py_UNICODE
+
+cdef extern from "Python.h":
+    ctypedef long long PY_LONG_LONG
+    ctypedef unsigned long long uPY_LONG_LONG
+
+    ############################################################################
+    # 7.2.3 Long Integer Objects
+    ############################################################################
+
+    # PyLongObject
+    #
+    # This subtype of PyObject represents a Python long integer object.
+
+    # PyTypeObject PyLong_Type
+    #
+    # This instance of PyTypeObject represents the Python long integer
+    # type. This is the same object as long and types.LongType.
+
+    bint PyLong_Check(object p)
+    # Return true if its argument is a PyLongObject or a subtype of PyLongObject. 
+
+    bint PyLong_CheckExact(object p)
+    # Return true if its argument is a PyLongObject, but not a subtype of PyLongObject.
+
+    object PyLong_FromLong(long v)
+    # Return value: New reference.
+    # Return a new PyLongObject object from v, or NULL on failure. 
+
+    object PyLong_FromUnsignedLong(unsigned long v)
+    # Return value: New reference.
+    # Return a new PyLongObject object from a C unsigned long, or NULL on failure. 
+
+    object PyLong_FromLongLong(PY_LONG_LONG v)
+    # Return value: New reference.
+    # Return a new PyLongObject object from a C long long, or NULL on failure. 
+
+    object PyLong_FromUnsignedLongLong(uPY_LONG_LONG v)
+    # Return value: New reference.
+    # Return a new PyLongObject object from a C unsigned long long, or NULL on failure. 
+
+    object PyLong_FromDouble(double v)
+    # Return value: New reference.
+    # Return a new PyLongObject object from the integer part of v, or NULL on failure. 
+
+    object PyLong_FromString(char *str, char **pend, int base)
+    # Return value: New reference.
+    # Return a new PyLongObject based on the string value in str,
+    # which is interpreted according to the radix in base. If pend is
+    # non-NULL, *pend will point to the first character in str which
+    # follows the representation of the number. If base is 0, the
+    # radix will be determined based on the leading characters of str:
+    # if str starts with '0x' or '0X', radix 16 will be used; if str
+    # starts with '0', radix 8 will be used; otherwise radix 10 will
+    # be used. If base is not 0, it must be between 2 and 36,
+    # inclusive. Leading spaces are ignored. If there are no digits,
+    # ValueError will be raised.
+
+    object PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
+    # Return value: New reference.
+    # Convert a sequence of Unicode digits to a Python long integer
+    # value. The first parameter, u, points to the first character of
+    # the Unicode string, length gives the number of characters, and
+    # base is the radix for the conversion. The radix must be in the
+    # range [2, 36]; if it is out of range, ValueError will be
+    # raised. 
+
+    object PyLong_FromVoidPtr(void *p)
+    # Return value: New reference.
+    # Create a Python integer or long integer from the pointer p. The
+    # pointer value can be retrieved from the resulting value using
+    # PyLong_AsVoidPtr().  If the integer is larger than LONG_MAX, a
+    # positive long integer is returned.
+
+    long PyLong_AsLong(object pylong) except? -1
+    # Return a C long representation of the contents of pylong. If
+    # pylong is greater than LONG_MAX, an OverflowError is raised.
+
+    unsigned long PyLong_AsUnsignedLong(object pylong) except? -1
+    # Return a C unsigned long representation of the contents of
+    # pylong. If pylong is greater than ULONG_MAX, an OverflowError is
+    # raised.
+
+    PY_LONG_LONG PyLong_AsLongLong(object pylong) except? -1
+    # Return a C long long from a Python long integer. If pylong
+    # cannot be represented as a long long, an OverflowError will be
+    # raised.
+
+    uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) except? -1
+    #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong)
+    # Return a C unsigned long long from a Python long integer. If
+    # pylong cannot be represented as an unsigned long long, an
+    # OverflowError will be raised if the value is positive, or a
+    # TypeError will be raised if the value is negative. 
+
+    unsigned long PyLong_AsUnsignedLongMask(object io) except? -1
+    # Return a C unsigned long from a Python long integer, without
+    # checking for overflow. 
+
+    uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) except? -1
+    #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io)
+    # Return a C unsigned long long from a Python long integer,
+    # without checking for overflow.
+
+    double PyLong_AsDouble(object pylong) except? -1.0
+    # Return a C double representation of the contents of pylong. If
+    # pylong cannot be approximately represented as a double, an
+    # OverflowError exception is raised and -1.0 will be returned.
+
+    void* PyLong_AsVoidPtr(object pylong) except? NULL
+    # Convert a Python integer or long integer pylong to a C void
+    # pointer. If pylong cannot be converted, an OverflowError will be
+    # raised. This is only assured to produce a usable void pointer
+    # for values created with PyLong_FromVoidPtr(). For values outside
+    # 0..LONG_MAX, both signed and unsigned integers are acccepted.
diff --git a/Cython/Includes/cpython/mapping.pxd b/Cython/Includes/cpython/mapping.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..3d235b65e20c0a774004bb0fd0938b158d515bb1
--- /dev/null
+++ b/Cython/Includes/cpython/mapping.pxd
@@ -0,0 +1,64 @@
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 6.4 Mapping Protocol
+    ############################################################################
+
+    bint PyMapping_Check(object o)
+    # Return 1 if the object provides mapping protocol, and 0
+    # otherwise. This function always succeeds.
+
+    Py_ssize_t PyMapping_Length(object o) except -1
+    # Returns the number of keys in object o on success, and -1 on
+    # failure. For objects that do not provide mapping protocol, this
+    # is equivalent to the Python expression "len(o)".
+
+    int PyMapping_DelItemString(object o, char *key) except -1
+    # Remove the mapping for object key from the object o. Return -1
+    # on failure. This is equivalent to the Python statement "del
+    # o[key]".
+
+    int PyMapping_DelItem(object o, object key) except -1
+    # Remove the mapping for object key from the object o. Return -1
+    # on failure. This is equivalent to the Python statement "del
+    # o[key]".
+
+    bint PyMapping_HasKeyString(object o, char *key)
+    # On success, return 1 if the mapping object has the key key and 0
+    # otherwise. This is equivalent to the Python expression
+    # "o.has_key(key)". This function always succeeds.
+
+    bint PyMapping_HasKey(object o, object key)
+    # Return 1 if the mapping object has the key key and 0
+    # otherwise. This is equivalent to the Python expression
+    # "o.has_key(key)". This function always succeeds.
+
+    object PyMapping_Keys(object o)
+    # Return value: New reference.
+    # On success, return a list of the keys in object o. On failure,
+    # return NULL. This is equivalent to the Python expression
+    # "o.keys()".
+
+    object PyMapping_Values(object o)
+    # Return value: New reference.
+    # On success, return a list of the values in object o. On failure,
+    # return NULL. This is equivalent to the Python expression
+    # "o.values()".
+
+    object PyMapping_Items(object o)
+    # Return value: New reference.
+    # On success, return a list of the items in object o, where each
+    # item is a tuple containing a key-value pair. On failure, return
+    # NULL. This is equivalent to the Python expression "o.items()".
+
+    object PyMapping_GetItemString(object o, char *key)
+    # Return value: New reference.
+    # Return element of o corresponding to the object key or NULL on
+    # failure. This is the equivalent of the Python expression
+    # "o[key]".
+
+    int PyMapping_SetItemString(object o, char *key, object v) except -1
+    # Map the object key to the value v in object o. Returns -1 on
+    # failure. This is the equivalent of the Python statement "o[key]
+    # = v".
+
diff --git a/Cython/Includes/cpython/mem.pxd b/Cython/Includes/cpython/mem.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..6d7b8dac180d8e0691c210a90dc190f0351916d2
--- /dev/null
+++ b/Cython/Includes/cpython/mem.pxd
@@ -0,0 +1,75 @@
+cdef extern from "Python.h":
+
+    #####################################################################
+    # 9.2 Memory Interface
+    #####################################################################
+    # You are definitely *supposed* to use these: "In most situations,
+    # however, it is recommended to allocate memory from the Python
+    # heap specifically because the latter is under control of the
+    # Python memory manager. For example, this is required when the
+    # interpreter is extended with new object types written in
+    # C. Another reason for using the Python heap is the desire to
+    # inform the Python memory manager about the memory needs of the
+    # extension module. Even when the requested memory is used
+    # exclusively for internal, highly-specific purposes, delegating
+    # all memory requests to the Python memory manager causes the
+    # interpreter to have a more accurate image of its memory
+    # footprint as a whole. Consequently, under certain circumstances,
+    # the Python memory manager may or may not trigger appropriate
+    # actions, like garbage collection, memory compaction or other
+    # preventive procedures. Note that by using the C library
+    # allocator as shown in the previous example, the allocated memory
+    # for the I/O buffer escapes completely the Python memory
+    # manager."
+
+    # The following function sets, modeled after the ANSI C standard,
+    # but specifying behavior when requesting zero bytes, are
+    # available for allocating and releasing memory from the Python
+    # heap:
+
+    void* PyMem_Malloc(size_t n)
+    # Allocates n bytes and returns a pointer of type void* to the
+    # allocated memory, or NULL if the request fails. Requesting zero
+    # bytes returns a distinct non-NULL pointer if possible, as if
+    # PyMem_Malloc(1) had been called instead. The memory will not
+    # have been initialized in any way.
+
+    void* PyMem_Realloc(void *p, size_t n)
+    # Resizes the memory block pointed to by p to n bytes. The
+    # contents will be unchanged to the minimum of the old and the new
+    # sizes. If p is NULL, the call is equivalent to PyMem_Malloc(n);
+    # else if n is equal to zero, the memory block is resized but is
+    # not freed, and the returned pointer is non-NULL. Unless p is
+    # NULL, it must have been returned by a previous call to
+    # PyMem_Malloc() or PyMem_Realloc().
+
+    void PyMem_Free(void *p)
+    # Frees the memory block pointed to by p, which must have been
+    # returned by a previous call to PyMem_Malloc() or
+    # PyMem_Realloc(). Otherwise, or if PyMem_Free(p) has been called
+    # before, undefined behavior occurs. If p is NULL, no operation is
+    # performed.
+
+    # The following type-oriented macros are provided for
+    # convenience. Note that TYPE refers to any C type.
+
+    # TYPE* PyMem_New(TYPE, size_t n)
+    # Same as PyMem_Malloc(), but allocates (n * sizeof(TYPE)) bytes
+    # of memory. Returns a pointer cast to TYPE*. The memory will not
+    # have been initialized in any way.
+
+    # TYPE* PyMem_Resize(void *p, TYPE, size_t n)
+    # Same as PyMem_Realloc(), but the memory block is resized to (n *
+    # sizeof(TYPE)) bytes. Returns a pointer cast to TYPE*.
+
+    void PyMem_Del(void *p)
+    # Same as PyMem_Free(). 
+
+    # In addition, the following macro sets are provided for calling
+    # the Python memory allocator directly, without involving the C
+    # API functions listed above. However, note that their use does
+    # not preserve binary compatibility across Python versions and is
+    # therefore deprecated in extension modules.
+
+    # PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
+    # PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().
diff --git a/Cython/Includes/cpython/method.pxd b/Cython/Includes/cpython/method.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..36e7ef450f228033323118fd3717a21c77938db4
--- /dev/null
+++ b/Cython/Includes/cpython/method.pxd
@@ -0,0 +1,48 @@
+cdef extern from "Python.h":
+    ctypedef void PyObject
+    ############################################################################
+    # 7.5.4 Method Objects
+    ############################################################################
+
+    # There are some useful functions that are useful for working with method objects.
+    # PyTypeObject PyMethod_Type
+    # This instance of PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType. 
+
+    bint PyMethod_Check(object o)
+    # Return true if o is a method object (has type
+    # PyMethod_Type). The parameter must not be NULL.
+
+    object PyMethod_New(object func, object self, object cls)
+    # Return value: New reference.
+    # Return a new method object, with func being any callable object;
+    # this is the function that will be called when the method is
+    # called. If this method should be bound to an instance, self
+    # should be the instance and class should be the class of self,
+    # otherwise self should be NULL and class should be the class
+    # which provides the unbound method..
+
+    PyObject* PyMethod_Class(object meth) except NULL
+    # Return value: Borrowed reference.
+    # Return the class object from which the method meth was created;
+    # if this was created from an instance, it will be the class of
+    # the instance.
+
+    PyObject* PyMethod_GET_CLASS(object meth)
+    # Return value: Borrowed reference.
+    # Macro version of PyMethod_Class() which avoids error checking. 
+
+    PyObject* PyMethod_Function(object meth) except NULL
+    # Return value: Borrowed reference.
+    # Return the function object associated with the method meth. 
+
+    PyObject* PyMethod_GET_FUNCTION(object meth)
+    # Return value: Borrowed reference.
+    # Macro version of PyMethod_Function() which avoids error checking. 
+
+    PyObject* PyMethod_Self(object meth) except? NULL
+    # Return value: Borrowed reference.
+    # Return the instance associated with the method meth if it is bound, otherwise return NULL. 
+
+    PyObject* PyMethod_GET_SELF(object meth)
+    # Return value: Borrowed reference.
+    # Macro version of PyMethod_Self() which avoids error checking. 
diff --git a/Cython/Includes/cpython/module.pxd b/Cython/Includes/cpython/module.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..8ff05108c028298299add717872444c22b6d0d79
--- /dev/null
+++ b/Cython/Includes/cpython/module.pxd
@@ -0,0 +1,175 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+    ctypedef struct _inittab
+
+    #####################################################################
+    # 5.3 Importing Modules
+    #####################################################################
+    object PyImport_ImportModule(char *name)
+    # Return value: New reference.
+    # This is a simplified interface to PyImport_ImportModuleEx()
+    # below, leaving the globals and locals arguments set to
+    # NULL. When the name argument contains a dot (when it specifies a
+    # submodule of a package), the fromlist argument is set to the
+    # list ['*'] so that the return value is the named module rather
+    # than the top-level package containing it as would otherwise be
+    # the case. (Unfortunately, this has an additional side effect
+    # when name in fact specifies a subpackage instead of a submodule:
+    # the submodules specified in the package's __all__ variable are
+    # loaded.) Return a new reference to the imported module, or NULL
+    # with an exception set on failure.
+
+    object PyImport_ImportModuleEx(char *name, object globals, object locals, object fromlist)
+    # Return value: New reference.
+
+    # Import a module. This is best described by referring to the
+    # built-in Python function __import__(), as the standard
+    # __import__() function calls this function directly.
+
+    # The return value is a new reference to the imported module or
+    # top-level package, or NULL with an exception set on failure
+    # (before Python 2.4, the module may still be created in this
+    # case). Like for __import__(), the return value when a submodule
+    # of a package was requested is normally the top-level package,
+    # unless a non-empty fromlist was given. Changed in version 2.4:
+    # failing imports remove incomplete module objects.
+
+    object PyImport_Import(object name)
+    # Return value: New reference.
+    # This is a higher-level interface that calls the current ``import
+    # hook function''. It invokes the __import__() function from the
+    # __builtins__ of the current globals. This means that the import
+    # is done using whatever import hooks are installed in the current
+    # environment, e.g. by rexec or ihooks.
+
+    object PyImport_ReloadModule(object m)
+    # Return value: New reference.
+    # Reload a module. This is best described by referring to the
+    # built-in Python function reload(), as the standard reload()
+    # function calls this function directly. Return a new reference to
+    # the reloaded module, or NULL with an exception set on failure
+    # (the module still exists in this case).
+
+    PyObject* PyImport_AddModule(char *name) except NULL
+    # Return value: Borrowed reference.
+    # Return the module object corresponding to a module name. The
+    # name argument may be of the form package.module. First check the
+    # modules dictionary if there's one there, and if not, create a
+    # new one and insert it in the modules dictionary. Return NULL
+    # with an exception set on failure. Note: This function does not
+    # load or import the module; if the module wasn't already loaded,
+    # you will get an empty module object. Use PyImport_ImportModule()
+    # or one of its variants to import a module. Package structures
+    # implied by a dotted name for name are not created if not already
+    # present.
+
+    object PyImport_ExecCodeModule(char *name, object co)
+    # Return value: New reference.
+    # Given a module name (possibly of the form package.module) and a
+    # code object read from a Python bytecode file or obtained from
+    # the built-in function compile(), load the module. Return a new
+    # reference to the module object, or NULL with an exception set if
+    # an error occurred. Name is removed from sys.modules in error
+    # cases, and even if name was already in sys.modules on entry to
+    # PyImport_ExecCodeModule(). Leaving incompletely initialized
+    # modules in sys.modules is dangerous, as imports of such modules
+    # have no way to know that the module object is an unknown (and
+    # probably damaged with respect to the module author's intents)
+    # state.
+    # This function will reload the module if it was already
+    # imported. See PyImport_ReloadModule() for the intended way to
+    # reload a module.
+    # If name points to a dotted name of the form package.module, any
+    # package structures not already created will still not be
+    # created.
+
+
+    long PyImport_GetMagicNumber()
+    # Return the magic number for Python bytecode files (a.k.a. .pyc
+    # and .pyo files). The magic number should be present in the first
+    # four bytes of the bytecode file, in little-endian byte order.
+
+    PyObject* PyImport_GetModuleDict() except NULL
+    # Return value: Borrowed reference.
+    # Return the dictionary used for the module administration
+    # (a.k.a. sys.modules). Note that this is a per-interpreter
+    # variable.
+
+
+    int PyImport_ImportFrozenModule(char *name) except -1
+    # Load a frozen module named name. Return 1 for success, 0 if the
+    # module is not found, and -1 with an exception set if the
+    # initialization failed. To access the imported module on a
+    # successful load, use PyImport_ImportModule(). (Note the misnomer
+    # -- this function would reload the module if it was already
+    # imported.)
+
+
+    int PyImport_ExtendInittab(_inittab *newtab) except -1
+    # Add a collection of modules to the table of built-in
+    # modules. The newtab array must end with a sentinel entry which
+    # contains NULL for the name field; failure to provide the
+    # sentinel value can result in a memory fault. Returns 0 on
+    # success or -1 if insufficient memory could be allocated to
+    # extend the internal table. In the event of failure, no modules
+    # are added to the internal table. This should be called before
+    # Py_Initialize().
+
+    #####################################################################
+    # 7.5.5 Module Objects
+    #####################################################################
+
+    # PyTypeObject PyModule_Type
+    #
+    # This instance of PyTypeObject represents the Python module
+    # type. This is exposed to Python programs as types.ModuleType.
+
+    bint PyModule_Check(object p)
+    # Return true if p is a module object, or a subtype of a module
+    # object.
+
+    bint PyModule_CheckExact(object p)
+    # Return true if p is a module object, but not a subtype of PyModule_Type. 
+
+    object PyModule_New(char *name)
+    # Return value: New reference.
+    # Return a new module object with the __name__ attribute set to
+    # name. Only the module's __doc__ and __name__ attributes are
+    # filled in; the caller is responsible for providing a __file__
+    # attribute.
+
+    PyObject* PyModule_GetDict(object module) except NULL
+    # Return value: Borrowed reference.
+    # Return the dictionary object that implements module's namespace;
+    # this object is the same as the __dict__ attribute of the module
+    # object. This function never fails. It is recommended extensions
+    # use other PyModule_*() and PyObject_*() functions rather than
+    # directly manipulate a module's __dict__.
+
+    char* PyModule_GetName(object module) except NULL
+    # Return module's __name__ value. If the module does not provide
+    # one, or if it is not a string, SystemError is raised and NULL is
+    # returned.
+
+    char* PyModule_GetFilename(object module) except NULL
+    # Return the name of the file from which module was loaded using
+    # module's __file__ attribute. If this is not defined, or if it is
+    # not a string, raise SystemError and return NULL.
+
+    int PyModule_AddObject(object module,  char *name, object value) except -1
+    # Add an object to module as name. This is a convenience function
+    # which can be used from the module's initialization
+    # function. This steals a reference to value. Return -1 on error,
+    # 0 on success. 
+
+    int PyModule_AddIntant(object module,  char *name, long value) except -1
+    # Add an integer ant to module as name. This convenience
+    # function can be used from the module's initialization
+    # function. Return -1 on error, 0 on success. 
+
+    int PyModule_AddStringant(object module,  char *name,  char *value) except -1
+    # Add a string constant to module as name. This convenience
+    # function can be used from the module's initialization
+    # function. The string value must be null-terminated. Return -1 on
+    # error, 0 on success. 
diff --git a/Cython/Includes/cpython/number.pxd b/Cython/Includes/cpython/number.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..99a94c8ed8864c3db5dc3dd6ebd497ce1c02ff06
--- /dev/null
+++ b/Cython/Includes/cpython/number.pxd
@@ -0,0 +1,251 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    #####################################################################
+    # 6.2 Number Protocol
+    #####################################################################
+
+    bint PyNumber_Check(object o)
+    # Returns 1 if the object o provides numeric protocols, and false
+    # otherwise. This function always succeeds.
+
+    object PyNumber_Add(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of adding o1 and o2, or NULL on failure. This
+    # is the equivalent of the Python expression "o1 + o2".
+
+    object PyNumber_Subtract(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of subtracting o2 from o1, or NULL on
+    # failure. This is the equivalent of the Python expression "o1 -
+    # o2".
+
+    object PyNumber_Multiply(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of multiplying o1 and o2, or NULL on
+    # failure. This is the equivalent of the Python expression "o1 *
+    # o2".
+
+    object PyNumber_Divide(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of dividing o1 by o2, or NULL on
+    # failure. This is the equivalent of the Python expression "o1 /
+    # o2".
+
+    object PyNumber_FloorDivide(object o1, object o2)
+    # Return value: New reference.
+    # Return the floor of o1 divided by o2, or NULL on failure. This
+    # is equivalent to the ``classic'' division of integers. 
+
+    object PyNumber_TrueDivide(object o1, object o2)
+    # Return value: New reference.
+    # Return a reasonable approximation for the mathematical value of
+    # o1 divided by o2, or NULL on failure. The return value is
+    # ``approximate'' because binary floating point numbers are
+    # approximate; it is not possible to represent all real numbers in
+    # base two. This function can return a floating point value when
+    # passed two integers. 
+
+    object PyNumber_Remainder(object o1, object o2)
+    # Return value: New reference.
+    # Returns the remainder of dividing o1 by o2, or NULL on
+    # failure. This is the equivalent of the Python expression "o1 %
+    # o2".
+
+    object PyNumber_Divmod(object o1, object o2)
+    # Return value: New reference.
+    # See the built-in function divmod(). Returns NULL on
+    # failure. This is the equivalent of the Python expression
+    # "divmod(o1, o2)".
+
+    object PyNumber_Power(object o1, object o2, object o3)
+    # Return value: New reference.
+    # See the built-in function pow(). Returns NULL on failure. This
+    # is the equivalent of the Python expression "pow(o1, o2, o3)",
+    # where o3 is optional. If o3 is to be ignored, pass Py_None in
+    # its place (passing NULL for o3 would cause an illegal memory
+    # access).
+
+    object PyNumber_Negative(object o)
+    # Return value: New reference.
+    # Returns the negation of o on success, or NULL on failure. This
+    # is the equivalent of the Python expression "-o".
+
+    object PyNumber_Positive(object o)
+    # Return value: New reference.
+    # Returns o on success, or NULL on failure. This is the equivalent
+    # of the Python expression "+o".
+
+    object PyNumber_Absolute(object o)
+    # Return value: New reference.
+    # Returns the absolute value of o, or NULL on failure. This is the
+    # equivalent of the Python expression "abs(o)".
+
+    object PyNumber_Invert(object o)
+    # Return value: New reference.
+    # Returns the bitwise negation of o on success, or NULL on
+    # failure. This is the equivalent of the Python expression "~o".
+
+    object PyNumber_Lshift(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of left shifting o1 by o2 on success, or NULL
+    # on failure. This is the equivalent of the Python expression "o1
+    # << o2".
+
+    object PyNumber_Rshift(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of right shifting o1 by o2 on success, or
+    # NULL on failure. This is the equivalent of the Python expression
+    # "o1 >> o2".
+
+    object PyNumber_And(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
+    # failure. This is the equivalent of the Python expression "o1 &
+    # o2".
+
+    object PyNumber_Xor(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
+    # NULL on failure. This is the equivalent of the Python expression
+    # "o1 ^ o2".
+
+    object PyNumber_Or(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on failure. This is the equivalent of the Python expression "o1 | o2". 
+
+    object PyNumber_InPlaceAdd(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of adding o1 and o2, or NULL on failure. The
+    # operation is done in-place when o1 supports it. This is the
+    # equivalent of the Python statement "o1 += o2".
+
+    object PyNumber_InPlaceSubtract(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of subtracting o2 from o1, or NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 -= o2".
+
+    object PyNumber_InPlaceMultiply(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of multiplying o1 and o2, or NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 *= o2".
+
+    object PyNumber_InPlaceDivide(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of dividing o1 by o2, or NULL on failure. The
+    # operation is done in-place when o1 supports it. This is the
+    # equivalent of the Python statement "o1 /= o2".
+
+    object PyNumber_InPlaceFloorDivide(object o1, object o2)
+    # Return value: New reference.
+    # Returns the mathematical floor of dividing o1 by o2, or NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 //=
+    # o2". 
+
+    object PyNumber_InPlaceTrueDivide(object o1, object o2)
+    # Return value: New reference.
+    # Return a reasonable approximation for the mathematical value of
+    # o1 divided by o2, or NULL on failure. The return value is
+    # ``approximate'' because binary floating point numbers are
+    # approximate; it is not possible to represent all real numbers in
+    # base two. This function can return a floating point value when
+    # passed two integers. The operation is done in-place when o1
+    # supports it. 
+
+    object PyNumber_InPlaceRemainder(object o1, object o2)
+    # Return value: New reference.
+    # Returns the remainder of dividing o1 by o2, or NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 %= o2".
+
+    object PyNumber_InPlacePower(object o1, object o2, object o3)
+    # Return value: New reference.
+    # See the built-in function pow(). Returns NULL on failure. The
+    # operation is done in-place when o1 supports it. This is the
+    # equivalent of the Python statement "o1 **= o2" when o3 is
+    # Py_None, or an in-place variant of "pow(o1, o2, o3)"
+    # otherwise. If o3 is to be ignored, pass Py_None in its place
+    # (passing NULL for o3 would cause an illegal memory access).
+
+    object PyNumber_InPlaceLshift(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of left shifting o1 by o2 on success, or NULL
+    # on failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 <<= o2".
+
+    object PyNumber_InPlaceRshift(object o1, object o2)
+    # Return value: New reference.
+    # Returns the result of right shifting o1 by o2 on success, or
+    # NULL on failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 >>= o2".
+
+    object PyNumber_InPlaceAnd(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 &= o2".
+
+    object PyNumber_InPlaceXor(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
+    # NULL on failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 ^= o2".
+
+    object PyNumber_InPlaceOr(object o1, object o2)
+    # Return value: New reference.
+    # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python statement "o1 |= o2".
+
+    int PyNumber_Coerce(PyObject **p1, PyObject **p2) except -1
+    # This function takes the addresses of two variables of type
+    # PyObject*. If the objects pointed to by *p1 and *p2 have the
+    # same type, increment their reference count and return 0
+    # (success). If the objects can be converted to a common numeric
+    # type, replace *p1 and *p2 by their converted value (with 'new'
+    # reference counts), and return 0. If no conversion is possible,
+    # or if some other error occurs, return -1 (failure) and don't
+    # increment the reference counts. The call PyNumber_Coerce(&o1,
+    # &o2) is equivalent to the Python statement "o1, o2 = coerce(o1,
+    # o2)".
+
+    object PyNumber_Int(object o)
+    # Return value: New reference.
+    # Returns the o converted to an integer object on success, or NULL
+    # on failure. If the argument is outside the integer range a long
+    # object will be returned instead. This is the equivalent of the
+    # Python expression "int(o)".
+
+    object PyNumber_Long(object o)
+    # Return value: New reference.
+    # Returns the o converted to a long integer object on success, or
+    # NULL on failure. This is the equivalent of the Python expression
+    # "long(o)".
+
+    object PyNumber_Float(object o)
+    # Return value: New reference.
+    # Returns the o converted to a float object on success, or NULL on
+    # failure. This is the equivalent of the Python expression
+    # "float(o)".
+
+    object PyNumber_Index(object o)
+    # Returns the o converted to a Python int or long on success or
+    # NULL with a TypeError exception raised on failure.
+
+    Py_ssize_t PyNumber_AsSsize_t(object o, object exc) except? -1
+    # Returns o converted to a Py_ssize_t value if o can be
+    # interpreted as an integer. If o can be converted to a Python int
+    # or long but the attempt to convert to a Py_ssize_t value would
+    # raise an OverflowError, then the exc argument is the type of
+    # exception that will be raised (usually IndexError or
+    # OverflowError). If exc is NULL, then the exception is cleared
+    # and the value is clipped to PY_SSIZE_T_MIN for a negative
+    # integer or PY_SSIZE_T_MAX for a positive integer. 
+
+    bint PyIndex_Check(object o)
+    # Returns True if o is an index integer (has the nb_index slot of
+    # the tp_as_number structure filled in).
diff --git a/Cython/Includes/cpython/object.pxd b/Cython/Includes/cpython/object.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..5d434d900d7241d3b277b1bb4b60435dab1685b0
--- /dev/null
+++ b/Cython/Includes/cpython/object.pxd
@@ -0,0 +1,284 @@
+from cpython.ref cimport PyObject, PyTypeObject
+from stdio cimport FILE
+
+cdef extern from "Python.h":
+    
+    #####################################################################
+    # 6.1 Object Protocol
+    #####################################################################
+    int PyObject_Print(object o, FILE *fp, int flags) except -1
+    # Print an object o, on file fp. Returns -1 on error. The flags
+    # argument is used to enable certain printing options. The only
+    # option currently supported is Py_PRINT_RAW; if given, the str()
+    # of the object is written instead of the repr().
+
+    bint PyObject_HasAttrString(object o, char *attr_name)
+    # Returns 1 if o has the attribute attr_name, and 0
+    # otherwise. This is equivalent to the Python expression
+    # "hasattr(o, attr_name)". This function always succeeds.
+
+    object PyObject_GetAttrString(object o, char *attr_name)
+    # Return value: New reference.  Retrieve an attribute named
+    # attr_name from object o. Returns the attribute value on success,
+    # or NULL on failure. This is the equivalent of the Python
+    # expression "o.attr_name".
+
+    bint PyObject_HasAttr(object o, object attr_name)
+    # Returns 1 if o has the attribute attr_name, and 0
+    # otherwise. This is equivalent to the Python expression
+    # "hasattr(o, attr_name)". This function always succeeds.
+
+    object PyObject_GetAttr(object o, object attr_name)
+    # Return value: New reference.  Retrieve an attribute named
+    # attr_name from object o. Returns the attribute value on success,
+    # or NULL on failure. This is the equivalent of the Python
+    # expression "o.attr_name".
+
+    int PyObject_SetAttrString(object o, char *attr_name, object v) except -1
+    # Set the value of the attribute named attr_name, for object o, to
+    # the value v. Returns -1 on failure. This is the equivalent of
+    # the Python statement "o.attr_name = v".
+
+    int PyObject_SetAttr(object o, object attr_name, object v) except -1
+    # Set the value of the attribute named attr_name, for object o, to
+    # the value v. Returns -1 on failure. This is the equivalent of
+    # the Python statement "o.attr_name = v".
+
+    int PyObject_DelAttrString(object o, char *attr_name) except -1
+    # Delete attribute named attr_name, for object o. Returns -1 on
+    # failure. This is the equivalent of the Python statement: "del
+    # o.attr_name".
+
+    int PyObject_DelAttr(object o, object attr_name) except -1
+    # Delete attribute named attr_name, for object o. Returns -1 on
+    # failure. This is the equivalent of the Python statement "del
+    # o.attr_name".
+
+    object PyObject_RichCompare(object o1, object o2, int opid)
+    # Return value: New reference.
+    # Compare the values of o1 and o2 using the operation specified by
+    # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
+    # Py_GE, corresponding to <, <=, ==, !=, >, or >=
+    # respectively. This is the equivalent of the Python expression
+    # "o1 op o2", where op is the operator corresponding to
+    # opid. Returns the value of the comparison on success, or NULL on
+    # failure.
+
+    bint PyObject_RichCompareBool(object o1, object o2, int opid) except -1
+    # Compare the values of o1 and o2 using the operation specified by
+    # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
+    # Py_GE, corresponding to <, <=, ==, !=, >, or >=
+    # respectively. Returns -1 on error, 0 if the result is false, 1
+    # otherwise. This is the equivalent of the Python expression "o1
+    # op o2", where op is the operator corresponding to opid.
+
+    int PyObject_Cmp(object o1, object o2, int *result) except -1
+    # Compare the values of o1 and o2 using a routine provided by o1,
+    # if one exists, otherwise with a routine provided by o2. The
+    # result of the comparison is returned in result. Returns -1 on
+    # failure. This is the equivalent of the Python statement "result
+    # = cmp(o1, o2)".
+
+    int PyObject_Compare(object o1, object o2) except *
+    # Compare the values of o1 and o2 using a routine provided by o1,
+    # if one exists, otherwise with a routine provided by o2. Returns
+    # the result of the comparison on success. On error, the value
+    # returned is undefined; use PyErr_Occurred() to detect an
+    # error. This is equivalent to the Python expression "cmp(o1,
+    # o2)".
+
+    object PyObject_Repr(object o)
+    # Return value: New reference.
+    # Compute a string representation of object o. Returns the string
+    # representation on success, NULL on failure. This is the
+    # equivalent of the Python expression "repr(o)". Called by the
+    # repr() built-in function and by reverse quotes.
+
+    object PyObject_Str(object o)
+    # Return value: New reference.
+    # Compute a string representation of object o. Returns the string
+    # representation on success, NULL on failure. This is the
+    # equivalent of the Python expression "str(o)". Called by the
+    # str() built-in function and by the print statement.
+
+    object PyObject_Unicode(object o)
+    # Return value: New reference.
+    # Compute a Unicode string representation of object o. Returns the
+    # Unicode string representation on success, NULL on failure. This
+    # is the equivalent of the Python expression "unicode(o)". Called
+    # by the unicode() built-in function.
+
+    bint PyObject_IsInstance(object inst, object cls) except -1
+    # Returns 1 if inst is an instance of the class cls or a subclass
+    # of cls, or 0 if not. On error, returns -1 and sets an
+    # exception. If cls is a type object rather than a class object,
+    # PyObject_IsInstance() returns 1 if inst is of type cls. If cls
+    # is a tuple, the check will be done against every entry in
+    # cls. The result will be 1 when at least one of the checks
+    # returns 1, otherwise it will be 0. If inst is not a class
+    # instance and cls is neither a type object, nor a class object,
+    # nor a tuple, inst must have a __class__ attribute -- the class
+    # relationship of the value of that attribute with cls will be
+    # used to determine the result of this function. 
+
+    # Subclass determination is done in a fairly straightforward way,
+    # but includes a wrinkle that implementors of extensions to the
+    # class system may want to be aware of. If A and B are class
+    # objects, B is a subclass of A if it inherits from A either
+    # directly or indirectly. If either is not a class object, a more
+    # general mechanism is used to determine the class relationship of
+    # the two objects. When testing if B is a subclass of A, if A is
+    # B, PyObject_IsSubclass() returns true. If A and B are different
+    # objects, B's __bases__ attribute is searched in a depth-first
+    # fashion for A -- the presence of the __bases__ attribute is
+    # considered sufficient for this determination.
+
+    bint PyObject_IsSubclass(object derived, object cls) except -1
+    # Returns 1 if the class derived is identical to or derived from
+    # the class cls, otherwise returns 0. In case of an error, returns
+    # -1. If cls is a tuple, the check will be done against every
+    # entry in cls. The result will be 1 when at least one of the
+    # checks returns 1, otherwise it will be 0. If either derived or
+    # cls is not an actual class object (or tuple), this function uses
+    # the generic algorithm described above. New in version
+    # 2.1. Changed in version 2.3: Older versions of Python did not
+    # support a tuple as the second argument.
+
+    bint PyCallable_Check(object o)
+    # Determine if the object o is callable. Return 1 if the object is
+    # callable and 0 otherwise. This function always succeeds.
+
+    object PyObject_Call(object callable_object, object args, object kw)
+    # Return value: New reference.
+    # Call a callable Python object callable_object, with arguments
+    # given by the tuple args, and named arguments given by the
+    # dictionary kw. If no named arguments are needed, kw may be
+    # NULL. args must not be NULL, use an empty tuple if no arguments
+    # are needed. Returns the result of the call on success, or NULL
+    # on failure. This is the equivalent of the Python expression
+    # "apply(callable_object, args, kw)" or "callable_object(*args,
+    # **kw)".
+
+    object PyObject_CallObject(object callable_object, object args)
+    # Return value: New reference.
+    # Call a callable Python object callable_object, with arguments
+    # given by the tuple args. If no arguments are needed, then args
+    # may be NULL. Returns the result of the call on success, or NULL
+    # on failure. This is the equivalent of the Python expression
+    # "apply(callable_object, args)" or "callable_object(*args)".
+
+    object PyObject_CallFunction(object callable, char *format, ...)
+    # Return value: New reference.
+    # Call a callable Python object callable, with a variable number
+    # of C arguments. The C arguments are described using a
+    # Py_BuildValue() style format string. The format may be NULL,
+    # indicating that no arguments are provided. Returns the result of
+    # the call on success, or NULL on failure. This is the equivalent
+    # of the Python expression "apply(callable, args)" or
+    # "callable(*args)". Note that if you only pass object  args,
+    # PyObject_CallFunctionObjArgs is a faster alternative.
+
+    object PyObject_CallMethod(object o, char *method, char *format, ...)
+    # Return value: New reference.
+    # Call the method named method of object o with a variable number
+    # of C arguments. The C arguments are described by a
+    # Py_BuildValue() format string that should produce a tuple. The
+    # format may be NULL, indicating that no arguments are
+    # provided. Returns the result of the call on success, or NULL on
+    # failure. This is the equivalent of the Python expression
+    # "o.method(args)". Note that if you only pass object  args,
+    # PyObject_CallMethodObjArgs is a faster alternative.
+
+    #object PyObject_CallFunctionObjArgs(object callable, ..., NULL)
+    object PyObject_CallFunctionObjArgs(object callable, ...)
+    # Return value: New reference.
+    # Call a callable Python object callable, with a variable number
+    # of PyObject* arguments. The arguments are provided as a variable
+    # number of parameters followed by NULL. Returns the result of the
+    # call on success, or NULL on failure. 
+
+    #PyObject* PyObject_CallMethodObjArgs(object o, object name, ..., NULL)
+    object PyObject_CallMethodObjArgs(object o, object name, ...)
+    # Return value: New reference.
+    # Calls a method of the object o, where the name of the method is
+    # given as a Python string object in name. It is called with a
+    # variable number of PyObject* arguments. The arguments are
+    # provided as a variable number of parameters followed by
+    # NULL. Returns the result of the call on success, or NULL on
+    # failure.
+
+    long PyObject_Hash(object o) except? -1
+    # Compute and return the hash value of an object o. On failure,
+    # return -1. This is the equivalent of the Python expression
+    # "hash(o)".
+
+    bint PyObject_IsTrue(object o) except -1
+    # Returns 1 if the object o is considered to be true, and 0
+    # otherwise. This is equivalent to the Python expression "not not
+    # o". On failure, return -1.
+
+    bint PyObject_Not(object o) except -1
+    # Returns 0 if the object o is considered to be true, and 1
+    # otherwise. This is equivalent to the Python expression "not
+    # o". On failure, return -1.
+
+    object PyObject_Type(object o)
+    # Return value: New reference.
+    # When o is non-NULL, returns a type object corresponding to the
+    # object type of object o. On failure, raises SystemError and
+    # returns NULL. This is equivalent to the Python expression
+    # type(o). This function increments the reference count of the
+    # return value. There's really no reason to use this function
+    # instead of the common expression o->ob_type, which returns a
+    # pointer of type PyTypeObject*, except when the incremented
+    # reference count is needed.
+
+    bint PyObject_TypeCheck(object o, PyTypeObject *type)
+    # Return true if the object o is of type type or a subtype of
+    # type. Both parameters must be non-NULL.
+
+    Py_ssize_t PyObject_Length(object o) except -1
+    Py_ssize_t PyObject_Size(object o) except -1
+    # Return the length of object o. If the object o provides either
+    # the sequence and mapping protocols, the sequence length is
+    # returned. On error, -1 is returned. This is the equivalent to
+    # the Python expression "len(o)".
+
+    object PyObject_GetItem(object o, object key)
+    # Return value: New reference.
+    # Return element of o corresponding to the object key or NULL on
+    # failure. This is the equivalent of the Python expression
+    # "o[key]".
+
+    int PyObject_SetItem(object o, object key, object v) except -1
+    # Map the object key to the value v. Returns -1 on failure. This
+    # is the equivalent of the Python statement "o[key] = v".
+
+    int PyObject_DelItem(object o, object key) except -1
+    # Delete the mapping for key from o. Returns -1 on failure. This
+    # is the equivalent of the Python statement "del o[key]".
+
+    int PyObject_AsFileDescriptor(object o) except -1
+    # Derives a file-descriptor from a Python object. If the object is
+    # an integer or long integer, its value is returned. If not, the
+    # object's fileno() method is called if it exists; the method must
+    # return an integer or long integer, which is returned as the file
+    # descriptor value. Returns -1 on failure.
+
+    object PyObject_Dir(object o)
+    # Return value: New reference.
+    # This is equivalent to the Python expression "dir(o)", returning
+    # a (possibly empty) list of strings appropriate for the object
+    # argument, or NULL if there was an error. If the argument is
+    # NULL, this is like the Python "dir()", returning the names of
+    # the current locals; in this case, if no execution frame is
+    # active then NULL is returned but PyErr_Occurred() will return
+    # false.
+
+    object PyObject_GetIter(object o)
+    # Return value: New reference.
+    # This is equivalent to the Python expression "iter(o)". It
+    # returns a new iterator for the object argument, or the object
+    # itself if the object is already an iterator. Raises TypeError
+    # and returns NULL if the object cannot be iterated.
+
diff --git a/Cython/Includes/cpython/oldbuffer.pxd b/Cython/Includes/cpython/oldbuffer.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..0222428ed48e1cb84cde849f83b36e3079089245
--- /dev/null
+++ b/Cython/Includes/cpython/oldbuffer.pxd
@@ -0,0 +1,63 @@
+# Legacy Python 2 buffer interface.
+#
+# These functions are no longer available in Python 3, use the new
+# buffer interface instead.
+
+cdef extern from "Python.h":
+    cdef enum _:
+        Py_END_OF_BUFFER
+    #    This constant may be passed as the size parameter to
+    #    PyBuffer_FromObject() or PyBuffer_FromReadWriteObject(). It
+    #    indicates that the new PyBufferObject should refer to base object
+    #    from the specified offset to the end of its exported
+    #    buffer. Using this enables the caller to avoid querying the base
+    #    object for its length.
+
+    bint PyBuffer_Check(object p)
+    #    Return true if the argument has type PyBuffer_Type.
+
+    object PyBuffer_FromObject(object base, Py_ssize_t offset, Py_ssize_t size)
+    #    Return value: New reference.
+    #
+    #    Return a new read-only buffer object. This raises TypeError if
+    #    base doesn't support the read-only buffer protocol or doesn't
+    #    provide exactly one buffer segment, or it raises ValueError if
+    #    offset is less than zero. The buffer will hold a reference to the
+    #    base object, and the buffer's contents will refer to the base
+    #    object's buffer interface, starting as position offset and
+    #    extending for size bytes. If size is Py_END_OF_BUFFER, then the
+    #    new buffer's contents extend to the length of the base object's
+    #    exported buffer data.
+
+    object PyBuffer_FromReadWriteObject(object base, Py_ssize_t offset, Py_ssize_t size)
+    #    Return value: New reference.
+    #
+    #    Return a new writable buffer object. Parameters and exceptions
+    #    are similar to those for PyBuffer_FromObject(). If the base
+    #    object does not export the writeable buffer protocol, then
+    #    TypeError is raised.
+
+    object PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
+    #    Return value: New reference.
+    #
+    #    Return a new read-only buffer object that reads from a specified
+    #    location in memory, with a specified size. The caller is
+    #    responsible for ensuring that the memory buffer, passed in as
+    #    ptr, is not deallocated while the returned buffer object
+    #    exists. Raises ValueError if size is less than zero. Note that
+    #    Py_END_OF_BUFFER may not be passed for the size parameter;
+    #    ValueError will be raised in that case.
+
+    object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
+    #    Return value: New reference.
+    #
+    #    Similar to PyBuffer_FromMemory(), but the returned buffer is
+    #    writable.
+
+    object PyBuffer_New(Py_ssize_t size)
+    #    Return value: New reference.
+    #
+    #    Return a new writable buffer object that maintains its own memory
+    #    buffer of size bytes. ValueError is returned if size is not zero
+    #    or positive. Note that the memory buffer (as returned by
+    #    PyObject_AsWriteBuffer()) is not specifically aligned.
diff --git a/Cython/Includes/cpython/pycapsule.pxd b/Cython/Includes/cpython/pycapsule.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..aceed7cc5257e714e62b30e387a8096631e50f48
--- /dev/null
+++ b/Cython/Includes/cpython/pycapsule.pxd
@@ -0,0 +1,146 @@
+from cpython.ref cimport PyObject
+
+# available since Python 3.1!
+
+# note all char* in the below functions are actually const char*
+
+cdef extern from "Python.h":
+
+    ctypedef struct PyCapsule_Type
+    # This subtype of PyObject represents an opaque value, useful for
+    # C extension modules who need to pass an opaque value (as a void*
+    # pointer) through Python code to other C code. It is often used
+    # to make a C function pointer defined in one module available to
+    # other modules, so the regular import mechanism can be used to
+    # access C APIs defined in dynamically loaded modules.
+
+
+    ctypedef void (*PyCapsule_Destructor)(object o)
+    # The type of a destructor callback for a capsule.
+    #
+    # See PyCapsule_New() for the semantics of PyCapsule_Destructor
+    # callbacks.
+
+
+    bint PyCapsule_CheckExact(object o)
+    # Return true if its argument is a PyCapsule.
+
+
+    object PyCapsule_New(void *pointer, char *name,
+                         PyCapsule_Destructor destructor)
+    # Return value: New reference.
+    #
+    # Create a PyCapsule encapsulating the pointer. The pointer
+    # argument may not be NULL.
+    #
+    # On failure, set an exception and return NULL.
+    #
+    # The name string may either be NULL or a pointer to a valid C
+    # string. If non-NULL, this string must outlive the
+    # capsule. (Though it is permitted to free it inside the
+    # destructor.)
+    #
+    # If the destructor argument is not NULL, it will be called with
+    # the capsule as its argument when it is destroyed.
+    #
+    # If this capsule will be stored as an attribute of a module, the
+    # name should be specified as modulename.attributename. This will
+    # enable other modules to import the capsule using
+    # PyCapsule_Import().
+
+
+    void* PyCapsule_GetPointer(object capsule, char *name) except? NULL
+    # Retrieve the pointer stored in the capsule. On failure, set an
+    # exception and return NULL.
+    #
+    # The name parameter must compare exactly to the name stored in
+    # the capsule. If the name stored in the capsule is NULL, the name
+    # passed in must also be NULL. Python uses the C function strcmp()
+    # to compare capsule names.
+
+
+    PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) except? NULL
+    # Return the current destructor stored in the capsule. On failure,
+    # set an exception and return NULL.
+    #
+    # It is legal for a capsule to have a NULL destructor. This makes
+    # a NULL return code somewhat ambiguous; use PyCapsule_IsValid()
+    # or PyErr_Occurred() to disambiguate.
+
+
+    char* PyCapsule_GetName(object capsule) except? NULL
+    # Return the current name stored in the capsule. On failure, set
+    # an exception and return NULL.
+    #
+    # It is legal for a capsule to have a NULL name. This makes a NULL
+    # return code somewhat ambiguous; use PyCapsule_IsValid() or
+    # PyErr_Occurred() to disambiguate.
+
+
+    void* PyCapsule_GetContext(object capsule) except? NULL
+    # Return the current context stored in the capsule. On failure,
+    # set an exception and return NULL.
+    #
+    # It is legal for a capsule to have a NULL context. This makes a
+    # NULL return code somewhat ambiguous; use PyCapsule_IsValid() or
+    # PyErr_Occurred() to disambiguate.
+
+
+    bint PyCapsule_IsValid(object capsule, char *name)
+    # Determines whether or not capsule is a valid capsule. A valid
+    # capsule is non-NULL, passes PyCapsule_CheckExact(), has a
+    # non-NULL pointer stored in it, and its internal name matches the
+    # name parameter. (See PyCapsule_GetPointer() for information on
+    # how capsule names are compared.)
+    #
+    # In other words, if PyCapsule_IsValid() returns a true value,
+    # calls to any of the accessors (any function starting with
+    # PyCapsule_Get()) are guaranteed to succeed.
+    # 
+    # Return a nonzero value if the object is valid and matches the
+    # name passed in. Return 0 otherwise. This function will not fail.
+
+
+    int PyCapsule_SetPointer(object capsule, void *pointer) except -1
+    # Set the void pointer inside capsule to pointer. The pointer may
+    # not be NULL.
+    #
+    # Return 0 on success. Return nonzero and set an exception on
+    # failure.
+
+
+    int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) except -1
+    # Set the destructor inside capsule to destructor.
+    #
+    # Return 0 on success. Return nonzero and set an exception on
+    # failure.
+
+
+    int PyCapsule_SetName(object capsule, char *name) except -1
+    # Set the name inside capsule to name. If non-NULL, the name must
+    # outlive the capsule. If the previous name stored in the capsule
+    # was not NULL, no attempt is made to free it.
+    #
+    # Return 0 on success. Return nonzero and set an exception on
+    # failure.
+
+
+    int PyCapsule_SetContext(object capsule, void *context) except -1
+    # Set the context pointer inside capsule to context.  Return 0 on
+    # success. Return nonzero and set an exception on failure.
+
+
+    void* PyCapsule_Import(char *name, int no_block) except? NULL
+    # Import a pointer to a C object from a capsule attribute in a
+    # module. The name parameter should specify the full name to the
+    # attribute, as in module.attribute. The name stored in the
+    # capsule must match this string exactly. If no_block is true,
+    # import the module without blocking (using
+    # PyImport_ImportModuleNoBlock()). If no_block is false, import
+    # the module conventionally (using PyImport_ImportModule()).
+    #
+    # Return the capsule’s internal pointer on success. On failure,
+    # set an exception and return NULL. However, if PyCapsule_Import()
+    # failed to import the module, and no_block was true, no exception
+    # is set.
+
diff --git a/Cython/Includes/cpython/ref.pxd b/Cython/Includes/cpython/ref.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..0bb49a3b70156a6ff0cc796bc53fa8255d1c4e4c
--- /dev/null
+++ b/Cython/Includes/cpython/ref.pxd
@@ -0,0 +1,55 @@
+cdef extern from "Python.h":
+    ctypedef struct PyTypeObject
+    ctypedef struct PyObject:
+        Py_ssize_t ob_refcnt
+        PyTypeObject *ob_type
+
+
+    #####################################################################
+    # 3. Reference Counts
+    #####################################################################
+    # The macros in this section are used for managing reference counts of Python objects.
+    void Py_INCREF(object o)
+    # Increment the reference count for object o. The object must not
+    # be NULL; if you aren't sure that it isn't NULL, use
+    # Py_XINCREF().
+
+    void Py_XINCREF(PyObject* o)
+    # Increment the reference count for object o. The object may be NULL, in which case the macro has no effect. 
+
+    void Py_DECREF(object o)
+    # Decrement the reference count for object o. The object must not
+    # be NULL; if you aren't sure that it isn't NULL, use
+    # Py_XDECREF(). If the reference count reaches zero, the object's
+    # type's deallocation function (which must not be NULL) is
+    # invoked.
+
+    # Warning: The deallocation function can cause arbitrary Python
+    # code to be invoked (e.g. when a class instance with a __del__()
+    # method is deallocated). While exceptions in such code are not
+    # propagated, the executed code has free access to all Python
+    # global variables. This means that any object that is reachable
+    # from a global variable should be in a consistent state before
+    # Py_DECREF() is invoked. For example, code to delete an object
+    # from a list should copy a reference to the deleted object in a
+    # temporary variable, update the list data structure, and then
+    # call Py_DECREF() for the temporary variable.
+
+    void Py_XDECREF(PyObject* o)
+    # Decrement the reference count for object o. The object may be
+    # NULL, in which case the macro has no effect; otherwise the
+    # effect is the same as for Py_DECREF(), and the same warning
+    # applies.
+
+    void Py_CLEAR(PyObject* o)
+    # Decrement the reference count for object o. The object may be
+    # NULL, in which case the macro has no effect; otherwise the
+    # effect is the same as for Py_DECREF(), except that the argument
+    # is also set to NULL. The warning for Py_DECREF() does not apply
+    # with respect to the object passed because the macro carefully
+    # uses a temporary variable and sets the argument to NULL before
+    # decrementing its reference count.
+    # It is a good idea to use this macro whenever decrementing the
+    # value of a variable that might be traversed during garbage
+    # collection.
+
diff --git a/Cython/Includes/cpython/sequence.pxd b/Cython/Includes/cpython/sequence.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..f3298213384e7810c9d697293d0dd669b1e72abd
--- /dev/null
+++ b/Cython/Includes/cpython/sequence.pxd
@@ -0,0 +1,136 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 6.3 Sequence Protocol
+    ############################################################################
+
+    bint PySequence_Check(object o)
+    # Return 1 if the object provides sequence protocol, and 0
+    # otherwise. This function always succeeds.
+
+    Py_ssize_t PySequence_Size(object o) except -1
+    # Returns the number of objects in sequence o on success, and -1
+    # on failure. For objects that do not provide sequence protocol,
+    # this is equivalent to the Python expression "len(o)".
+
+    Py_ssize_t PySequence_Length(object o) except -1
+    # Alternate name for PySequence_Size(). 
+
+    object PySequence_Concat(object o1, object o2)
+    # Return value: New reference.
+    # Return the concatenation of o1 and o2 on success, and NULL on
+    # failure. This is the equivalent of the Python expression "o1 +
+    # o2".
+
+    object PySequence_Repeat(object o, Py_ssize_t count)
+    # Return value: New reference.
+    # Return the result of repeating sequence object o count times, or
+    # NULL on failure. This is the equivalent of the Python expression
+    # "o * count".
+
+    object PySequence_InPlaceConcat(object o1, object o2)
+    # Return value: New reference.
+    # Return the concatenation of o1 and o2 on success, and NULL on
+    # failure. The operation is done in-place when o1 supports
+    # it. This is the equivalent of the Python expression "o1 += o2".
+
+    object PySequence_InPlaceRepeat(object o, Py_ssize_t count)
+    # Return value: New reference.
+    # Return the result of repeating sequence object o count times, or
+    # NULL on failure. The operation is done in-place when o supports
+    # it. This is the equivalent of the Python expression "o *=
+    # count".
+
+    object PySequence_GetItem(object o, Py_ssize_t i)
+    # Return value: New reference.
+    # Return the ith element of o, or NULL on failure. This is the
+    # equivalent of the Python expression "o[i]".
+
+    object PySequence_GetSlice(object o, Py_ssize_t i1, Py_ssize_t i2)
+    # Return value: New reference.
+    # Return the slice of sequence object o between i1 and i2, or NULL
+    # on failure. This is the equivalent of the Python expression
+    # "o[i1:i2]".
+
+    int PySequence_SetItem(object o, Py_ssize_t i, object v) except -1
+    # Assign object v to the ith element of o. Returns -1 on
+    # failure. This is the equivalent of the Python statement "o[i] =
+    # v". This function does not steal a reference to v.
+
+    int PySequence_DelItem(object o, Py_ssize_t i) except -1
+    # Delete the ith element of object o. Returns -1 on failure. This
+    # is the equivalent of the Python statement "del o[i]".
+
+    int PySequence_SetSlice(object o, Py_ssize_t i1, Py_ssize_t i2, object v) except -1
+    # Assign the sequence object v to the slice in sequence object o
+    # from i1 to i2. This is the equivalent of the Python statement
+    # "o[i1:i2] = v".
+
+    int PySequence_DelSlice(object o, Py_ssize_t i1, Py_ssize_t i2) except -1
+    # Delete the slice in sequence object o from i1 to i2. Returns -1
+    # on failure. This is the equivalent of the Python statement "del
+    # o[i1:i2]".
+
+    int PySequence_Count(object o, object value) except -1
+    # Return the number of occurrences of value in o, that is, return
+    # the number of keys for which o[key] == value. On failure, return
+    # -1. This is equivalent to the Python expression
+    # "o.count(value)".
+
+    int PySequence_Contains(object o, object value) except -1
+    # Determine if o contains value. If an item in o is equal to
+    # value, return 1, otherwise return 0. On error, return -1. This
+    # is equivalent to the Python expression "value in o".
+
+    int PySequence_Index(object o, object value) except -1
+    # Return the first index i for which o[i] == value. On error,
+    # return -1. This is equivalent to the Python expression
+    # "o.index(value)".
+
+    object PySequence_List(object o)
+    # Return value: New reference.
+    # Return a list object with the same contents as the arbitrary
+    # sequence o. The returned list is guaranteed to be new.
+
+    object PySequence_Tuple(object o)
+    # Return value: New reference.
+    # Return a tuple object with the same contents as the arbitrary
+    # sequence o or NULL on failure. If o is a tuple, a new reference
+    # will be returned, otherwise a tuple will be constructed with the
+    # appropriate contents. This is equivalent to the Python
+    # expression "tuple(o)".
+
+    object PySequence_Fast(object o, char *m)
+    # Return value: New reference.
+    # Returns the sequence o as a tuple, unless it is already a tuple
+    # or list, in which case o is returned. Use
+    # PySequence_Fast_GET_ITEM() to access the members of the
+    # result. Returns NULL on failure. If the object is not a
+    # sequence, raises TypeError with m as the message text.
+
+    PyObject* PySequence_Fast_GET_ITEM(object o, Py_ssize_t i)
+    # Return value: Borrowed reference.
+    # Return the ith element of o, assuming that o was returned by
+    # PySequence_Fast(), o is not NULL, and that i is within bounds.
+
+    PyObject** PySequence_Fast_ITEMS(object o)
+    # Return the underlying array of PyObject pointers. Assumes that o
+    # was returned by PySequence_Fast() and o is not NULL. 
+
+    object PySequence_ITEM(object o, Py_ssize_t i)
+    # Return value: New reference.
+    # Return the ith element of o or NULL on failure. Macro form of
+    # PySequence_GetItem() but without checking that
+    # PySequence_Check(o) is true and without adjustment for negative
+    # indices.
+
+    int PySequence_Fast_GET_SIZE(object o)
+    # Returns the length of o, assuming that o was returned by
+    # PySequence_Fast() and that o is not NULL. The size can also be
+    # gotten by calling PySequence_Size() on o, but
+    # PySequence_Fast_GET_SIZE() is faster because it can assume o is
+    # a list or tuple.
+
+
diff --git a/Cython/Includes/cpython/set.pxd b/Cython/Includes/cpython/set.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..3cedcb5bd52a46874d5bcf25069dd06ed65b85f1
--- /dev/null
+++ b/Cython/Includes/cpython/set.pxd
@@ -0,0 +1,113 @@
+cdef extern from "Python.h":
+
+    ############################################################################
+    # 7.5.14 Set Objects
+    ############################################################################
+
+    # This section details the public API for set and frozenset
+    # objects. Any functionality not listed below is best accessed
+    # using the either the abstract object protocol (including
+    # PyObject_CallMethod(), PyObject_RichCompareBool(),
+    # PyObject_Hash(), PyObject_Repr(), PyObject_IsTrue(),
+    # PyObject_Print(), and PyObject_GetIter()) or the abstract number
+    # protocol (including PyNumber_Add(), PyNumber_Subtract(),
+    # PyNumber_Or(), PyNumber_Xor(), PyNumber_InPlaceAdd(),
+    # PyNumber_InPlaceSubtract(), PyNumber_InPlaceOr(), and
+    # PyNumber_InPlaceXor()).
+
+    # PySetObject
+    # This subtype of PyObject is used to hold the internal data for
+    # both set and frozenset objects. It is like a PyDictObject in
+    # that it is a fixed size for small sets (much like tuple storage)
+    # and will point to a separate, variable sized block of memory for
+    # medium and large sized sets (much like list storage). None of
+    # the fields of this structure should be considered public and are
+    # subject to change. All access should be done through the
+    # documented API rather than by manipulating the values in the
+    # structure.
+
+    # PyTypeObject PySet_Type
+    # This is an instance of PyTypeObject representing the Python set type. 
+
+    # PyTypeObject PyFrozenSet_Type
+    # This is an instance of PyTypeObject representing the Python frozenset type. 
+
+    # The following type check macros work on pointers to any Python
+    # object. Likewise, the constructor functions work with any
+    # iterable Python object.
+
+    bint PyAnySet_Check(object p)
+    # Return true if p is a set object, a frozenset object, or an
+    # instance of a subtype.
+
+    bint PyAnySet_CheckExact(object p)
+    # Return true if p is a set object or a frozenset object but not
+    # an instance of a subtype.
+
+    bint PyFrozenSet_CheckExact(object p)
+    # Return true if p is a frozenset object but not an instance of a subtype. 
+
+    object PySet_New(object iterable)
+    # Return value: New reference.
+    # Return a new set containing objects returned by the
+    # iterable. The iterable may be NULL to create a new empty
+    # set. Return the new set on success or NULL on failure. Raise
+    # TypeError if iterable is not actually iterable. The constructor
+    # is also useful for copying a set (c=set(s)).
+
+    object PyFrozenSet_New(object iterable)
+    # Return value: New reference.
+    # Return a new frozenset containing objects returned by the
+    # iterable. The iterable may be NULL to create a new empty
+    # frozenset. Return the new set on success or NULL on
+    # failure. Raise TypeError if iterable is not actually iterable.
+
+
+    # The following functions and macros are available for instances
+    # of set or frozenset or instances of their subtypes.
+
+    int PySet_Size(object anyset) except -1
+    # Return the length of a set or frozenset object. Equivalent to
+    # "len(anyset)". Raises a PyExc_SystemError if anyset is not a
+    # set, frozenset, or an instance of a subtype.
+
+    int PySet_GET_SIZE(object anyset)
+    # Macro form of PySet_Size() without error checking. 
+
+    bint PySet_Contains(object anyset, object key) except -1
+    # Return 1 if found, 0 if not found, and -1 if an error is
+    # encountered. Unlike the Python __contains__() method, this
+    # function does not automatically convert unhashable sets into
+    # temporary frozensets. Raise a TypeError if the key is
+    # unhashable. Raise PyExc_SystemError if anyset is not a set,
+    # frozenset, or an instance of a subtype.
+
+
+    # The following functions are available for instances of set or
+    # its subtypes but not for instances of frozenset or its subtypes.
+
+    int PySet_Add(object set, object key) except -1
+    # Add key to a set instance. Does not apply to frozenset
+    # instances. Return 0 on success or -1 on failure. Raise a
+    # TypeError if the key is unhashable. Raise a MemoryError if there
+    # is no room to grow. Raise a SystemError if set is an not an
+    # instance of set or its subtype.
+
+    bint PySet_Discard(object set, object key) except -1
+    # Return 1 if found and removed, 0 if not found (no action taken),
+    # and -1 if an error is encountered. Does not raise KeyError for
+    # missing keys. Raise a TypeError if the key is unhashable. Unlike
+    # the Python discard() method, this function does not
+    # automatically convert unhashable sets into temporary
+    # frozensets. Raise PyExc_SystemError if set is an not an instance
+    # of set or its subtype.
+
+    object PySet_Pop(object set)
+    # Return value: New reference.
+    # Return a new reference to an arbitrary object in the set, and
+    # removes the object from the set. Return NULL on failure. Raise
+    # KeyError if the set is empty. Raise a SystemError if set is an
+    # not an instance of set or its subtype.
+
+    int PySet_Clear(object set)
+    # Empty an existing set of all elements. 
diff --git a/Cython/Includes/cpython/string.pxd b/Cython/Includes/cpython/string.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..fc2fd33bb06319633b9b4da720e23e29001b4411
--- /dev/null
+++ b/Cython/Includes/cpython/string.pxd
@@ -0,0 +1,198 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+    ctypedef struct va_list
+
+    ############################################################################
+    # 7.3.1 String Objects
+    ############################################################################
+
+    # These functions raise TypeError when expecting a string
+    # parameter and are called with a non-string parameter.
+    # PyStringObject
+    # This subtype of PyObject represents a Python string object. 
+    # PyTypeObject PyString_Type
+    # This instance of PyTypeObject represents the Python string type;
+    # it is the same object as str and types.StringType in the Python
+    # layer. 
+
+    bint PyString_Check(object o)
+    # Return true if the object o is a string object or an instance of
+    # a subtype of the string type. 
+
+    bint PyString_CheckExact(object o)
+    # Return true if the object o is a string object, but not an instance of a subtype of the string type. 
+
+    object PyString_FromString(char *v)
+    # Return value: New reference.
+    # Return a new string object with the value v on success, and NULL
+    # on failure. The parameter v must not be NULL; it will not be
+    # checked.
+
+    object PyString_FromStringAndSize(char *v, Py_ssize_t len)
+    # Return value: New reference.
+    # Return a new string object with the value v and length len on
+    # success, and NULL on failure. If v is NULL, the contents of the
+    # string are uninitialized.
+
+    object PyString_FromFormat(char *format, ...)
+    # Return value: New reference.
+    # Take a C printf()-style format string and a variable number of
+    # arguments, calculate the size of the resulting Python string and
+    # return a string with the values formatted into it. The variable
+    # arguments must be C types and must correspond exactly to the
+    # format characters in the format string. The following format
+    # characters are allowed:
+    # Format Characters 	Type 	Comment
+    # %% 	n/a 	The literal % character.
+    # %c 	int 	A single character, represented as an C int.
+    # %d 	int 	Exactly equivalent to printf("%d").
+    # %u 	unsigned int 	Exactly equivalent to printf("%u").
+    # %ld 	long 	Exactly equivalent to printf("%ld").
+    # %lu 	unsigned long 	Exactly equivalent to printf("%lu").
+    # %zd 	Py_ssize_t 	Exactly equivalent to printf("%zd").
+    # %zu 	size_t 	Exactly equivalent to printf("%zu").
+    # %i 	int 	Exactly equivalent to printf("%i").
+    # %x 	int 	Exactly equivalent to printf("%x").
+    # %s 	char* 	A null-terminated C character array.
+
+    # %p 	void* 	The hex representation of a C pointer.
+    #    Mostly equivalent to printf("%p") except that it is guaranteed to
+    #    start with the literal 0x regardless of what the platform's printf
+    #    yields.
+    # An unrecognized format character causes all the rest of the
+    # format string to be copied as-is to the result string, and any
+    # extra arguments discarded.
+
+    object PyString_FromFormatV(char *format, va_list vargs)
+    # Return value: New reference.
+    # Identical to PyString_FromFormat() except that it takes exactly two arguments. 
+
+    Py_ssize_t PyString_Size(object string) except -1
+    # Return the length of the string in string object string. 
+
+    Py_ssize_t PyString_GET_SIZE(object string)
+    # Macro form of PyString_Size() but without error checking. 
+
+    char* PyString_AsString(object string) except NULL
+    # Return a NUL-terminated representation of the contents of
+    # string. The pointer refers to the internal buffer of string, not
+    # a copy. The data must not be modified in any way, unless the
+    # string was just created using PyString_FromStringAndSize(NULL,
+    # size). It must not be deallocated. If string is a Unicode
+    # object, this function computes the default encoding of string
+    # and operates on that. If string is not a string object at all,
+    # PyString_AsString() returns NULL and raises TypeError.
+
+    char* PyString_AS_STRING(object string)
+    # Macro form of PyString_AsString() but without error
+    # checking. Only string objects are supported; no Unicode objects
+    # should be passed.
+
+    int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
+    # Return a NULL-terminated representation of the contents of the
+    # object obj through the output variables buffer and length.
+    #
+    # The function accepts both string and Unicode objects as
+    # input. For Unicode objects it returns the default encoded
+    # version of the object. If length is NULL, the resulting buffer
+    # may not contain NUL characters; if it does, the function returns
+    # -1 and a TypeError is raised.
+    
+    # The buffer refers to an internal string buffer of obj, not a
+    # copy. The data must not be modified in any way, unless the
+    # string was just created using PyString_FromStringAndSize(NULL,
+    # size). It must not be deallocated. If string is a Unicode
+    # object, this function computes the default encoding of string
+    # and operates on that. If string is not a string object at all,
+    # PyString_AsStringAndSize() returns -1 and raises TypeError.
+
+    void PyString_Concat(PyObject **string, object newpart)
+    # Create a new string object in *string containing the contents of
+    # newpart appended to string; the caller will own the new
+    # reference. The reference to the old value of string will be
+    # stolen. If the new string cannot be created, the old reference
+    # to string will still be discarded and the value of *string will
+    # be set to NULL; the appropriate exception will be set.
+
+    void PyString_ConcatAndDel(PyObject **string, object newpart)
+    # Create a new string object in *string containing the contents of
+    # newpart appended to string. This version decrements the
+    # reference count of newpart.
+
+    int _PyString_Resize(PyObject **string, Py_ssize_t newsize) except -1
+    # A way to resize a string object even though it is
+    # ``immutable''. Only use this to build up a brand new string
+    # object; don't use this if the string may already be known in
+    # other parts of the code. It is an error to call this function if
+    # the refcount on the input string object is not one. Pass the
+    # address of an existing string object as an lvalue (it may be
+    # written into), and the new size desired. On success, *string
+    # holds the resized string object and 0 is returned; the address
+    # in *string may differ from its input value. If the reallocation
+    # fails, the original string object at *string is deallocated,
+    # *string is set to NULL, a memory exception is set, and -1 is
+    # returned.
+
+    object PyString_Format(object format, object args)
+    # Return value: New reference.  Return a new string object from
+    # format and args. Analogous to format % args. The args argument
+    # must be a tuple.
+
+    void PyString_InternInPlace(PyObject **string)
+    # Intern the argument *string in place. The argument must be the
+    # address of a pointer variable pointing to a Python string
+    # object. If there is an existing interned string that is the same
+    # as *string, it sets *string to it (decrementing the reference
+    # count of the old string object and incrementing the reference
+    # count of the interned string object), otherwise it leaves
+    # *string alone and interns it (incrementing its reference
+    # count). (Clarification: even though there is a lot of talk about
+    # reference counts, think of this function as
+    # reference-count-neutral; you own the object after the call if
+    # and only if you owned it before the call.)
+
+    object PyString_InternFromString(char *v)
+    # Return value: New reference.
+    # A combination of PyString_FromString() and
+    # PyString_InternInPlace(), returning either a new string object
+    # that has been interned, or a new (``owned'') reference to an
+    # earlier interned string object with the same value.
+
+    object PyString_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+    #  Return value: New reference.
+    # Create an object by decoding size bytes of the encoded buffer s
+    # using the codec registered for encoding. encoding and errors
+    # have the same meaning as the parameters of the same name in the
+    # unicode() built-in function. The codec to be used is looked up
+    # using the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+    object PyString_AsDecodedObject(object str, char *encoding, char *errors)
+    # Return value: New reference.
+    # Decode a string object by passing it to the codec registered for
+    # encoding and return the result as Python object. encoding and
+    # errors have the same meaning as the parameters of the same name
+    # in the string encode() method. The codec to be used is looked up
+    # using the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+    object PyString_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
+    # Return value: New reference.
+    # Encode the char buffer of the given size by passing it to the
+    # codec registered for encoding and return a Python
+    # object. encoding and errors have the same meaning as the
+    # parameters of the same name in the string encode() method. The
+    # codec to be used is looked up using the Python codec
+    # registry. Return NULL if an exception was raised by the codec.
+
+    object PyString_AsEncodedObject(object str, char *encoding, char *errors)
+    # Return value: New reference.
+    # Encode a string object using the codec registered for encoding
+    # and return the result as Python object. encoding and errors have
+    # the same meaning as the parameters of the same name in the
+    # string encode() method. The codec to be used is looked up using
+    # the Python codec registry. Return NULL if an exception was
+    # raised by the codec.
+
+
diff --git a/Cython/Includes/cpython/tuple.pxd b/Cython/Includes/cpython/tuple.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..78ac5778d86295a0d29e81f48f94ae72c1c441b8
--- /dev/null
+++ b/Cython/Includes/cpython/tuple.pxd
@@ -0,0 +1,71 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    ############################################################################
+    # Tuples
+    ############################################################################
+
+    bint PyTuple_Check(object  p)
+    # Return true if p is a tuple object or an instance of a subtype
+    # of the tuple type.
+
+    bint PyTuple_CheckExact(object  p)
+    # Return true if p is a tuple object, but not an instance of a subtype of the tuple type.
+
+    object PyTuple_New(Py_ssize_t len)
+    # Return value: New reference.
+    # Return a new tuple object of size len, or NULL on failure. 
+
+    object PyTuple_Pack(Py_ssize_t n, ...)
+    # Return value: New reference.
+    # Return a new tuple object of size n, or NULL on failure. The
+    # tuple values are initialized to the subsequent n C arguments
+    # pointing to Python objects. "PyTuple_Pack(2, a, b)" is
+    # equivalent to "Py_BuildValue("(OO)", a, b)".
+
+    int PyTuple_Size(object  p) except -1
+    # Take a pointer to a tuple object, and return the size of that tuple. 
+
+    int PyTuple_GET_SIZE(object  p)
+    # Return the size of the tuple p, which must be non-NULL and point
+    # to a tuple; no error checking is performed.
+
+    PyObject* PyTuple_GetItem(object  p, Py_ssize_t pos) except NULL
+    # Return value: Borrowed reference.
+    # Return the object at position pos in the tuple pointed to by
+    # p. If pos is out of bounds, return NULL and sets an IndexError
+    # exception.
+
+    PyObject* PyTuple_GET_ITEM(object  p, Py_ssize_t pos)
+    # Return value: Borrowed reference.
+    # Like PyTuple_GetItem(), but does no checking of its arguments. 
+
+    object PyTuple_GetSlice(object  p, Py_ssize_t low, Py_ssize_t high)
+    # Return value: New reference.
+    # Take a slice of the tuple pointed to by p from low to high and return it as a new tuple. 
+
+    int PyTuple_SetItem(object  p, Py_ssize_t pos, object  o)
+    # Insert a reference to object o at position pos of the tuple
+    # pointed to by p. Return 0 on success. Note: This function
+    # ``steals'' a reference to o.
+
+    void PyTuple_SET_ITEM(object  p, Py_ssize_t pos, object  o)
+    # Like PyTuple_SetItem(), but does no error checking, and should
+    # only be used to fill in brand new tuples. Note: This function
+    # ``steals'' a reference to o.
+
+    int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1
+    # Can be used to resize a tuple. newsize will be the new length of
+    # the tuple. Because tuples are supposed to be immutable, this
+    # should only be used if there is only one reference to the
+    # object. Do not use this if the tuple may already be known to
+    # some other part of the code. The tuple will always grow or
+    # shrink at the end. Think of this as destroying the old tuple and
+    # creating a new one, only more efficiently. Returns 0 on
+    # success. Client code should never assume that the resulting
+    # value of *p will be the same as before calling this function. If
+    # the object referenced by *p is replaced, the original *p is
+    # destroyed. On failure, returns -1 and sets *p to NULL, and
+    # raises MemoryError or SystemError.
+
diff --git a/Cython/Includes/cpython/type.pxd b/Cython/Includes/cpython/type.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..362a0964fa4ce6853e6d6ec91be19225e7991cc5
--- /dev/null
+++ b/Cython/Includes/cpython/type.pxd
@@ -0,0 +1,45 @@
+
+cdef extern from "Python.h":
+    # The C structure of the objects used to describe built-in types. 
+
+    ############################################################################
+    # 7.1.1 Type Objects
+    ############################################################################
+
+    # PyObject* PyType_Type
+    # This is the type object for type objects; it is the same object
+    # as type and types.TypeType in the Python layer.
+
+    bint PyType_Check(object o)
+    # Return true if the object o is a type object, including
+    # instances of types derived from the standard type object. Return
+    # false in all other cases.
+
+    bint PyType_CheckExact(object o)
+    # Return true if the object o is a type object, but not a subtype
+    # of the standard type object. Return false in all other
+    # cases.
+
+    bint PyType_HasFeature(object o, int feature)
+    # Return true if the type object o sets the feature feature. Type
+    # features are denoted by single bit flags.
+
+    bint PyType_IS_GC(object o)
+    # Return true if the type object includes support for the cycle
+    # detector; this tests the type flag Py_TPFLAGS_HAVE_GC. 
+
+    bint PyType_IsSubtype(object a, object b)
+    # Return true if a is a subtype of b. 
+
+    object PyType_GenericAlloc(object type, Py_ssize_t nitems)
+    # Return value: New reference.
+
+    object PyType_GenericNew(object type, object args, object kwds)
+    # Return value: New reference.
+
+    bint PyType_Ready(object type) except -1
+    # Finalize a type object. This should be called on all type
+    # objects to finish their initialization. This function is
+    # responsible for adding inherited slots from a type's base
+    # class. Return 0 on success, or return -1 and sets an exception
+    # on error.
diff --git a/Cython/Includes/cpython/unicode.pxd b/Cython/Includes/cpython/unicode.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..2a1f14f356b31df95b992c3f4c508b1bd9705e18
--- /dev/null
+++ b/Cython/Includes/cpython/unicode.pxd
@@ -0,0 +1,385 @@
+cdef extern from *:
+    ctypedef unsigned int Py_UNICODE
+
+    # Return true if the object o is a Unicode object or an instance
+    # of a Unicode subtype. Changed in version 2.2: Allowed subtypes
+    # to be accepted.
+    bint PyUnicode_Check(object o)
+
+    # Return true if the object o is a Unicode object, but not an
+    # instance of a subtype. New in version 2.2.
+    bint PyUnicode_CheckExact(object o)
+
+    # Return the size of the object. o has to be a PyUnicodeObject
+    # (not checked).
+    Py_ssize_t PyUnicode_GET_SIZE(object o)
+
+    # Return the size of the object's internal buffer in bytes. o has
+    # to be a PyUnicodeObject (not checked).
+    Py_ssize_t PyUnicode_GET_DATA_SIZE(object o)
+
+    # Return a pointer to the internal Py_UNICODE buffer of the
+    # object. o has to be a PyUnicodeObject (not checked).
+    Py_UNICODE* PyUnicode_AS_UNICODE(object o)
+
+    # Return a pointer to the internal buffer of the object. o has to
+    # be a PyUnicodeObject (not checked).
+    char* PyUnicode_AS_DATA(object o)
+
+    # Return 1 or 0 depending on whether ch is a whitespace character.
+    bint Py_UNICODE_ISSPACE(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is a lowercase character.
+    bint Py_UNICODE_ISLOWER(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is an uppercase character.
+    bint Py_UNICODE_ISUPPER(Py_UNICODE ch)
+    
+    # Return 1 or 0 depending on whether ch is a titlecase character. 
+    bint Py_UNICODE_ISTITLE(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is a linebreak character. 
+    bint Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is a decimal character. 
+    bint Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is a digit character. 
+    bint Py_UNICODE_ISDIGIT(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is a numeric character. 
+    bint Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is an alphabetic character. 
+    bint Py_UNICODE_ISALPHA(Py_UNICODE ch)
+
+    # Return 1 or 0 depending on whether ch is an alphanumeric character. 
+    bint Py_UNICODE_ISALNUM(Py_UNICODE ch)
+
+    # Return the character ch converted to lower case. 
+    Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
+
+    # Return the character ch converted to upper case. 
+    Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
+
+    # Return the character ch converted to title case. 
+    Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
+
+    # Return the character ch converted to a decimal positive
+    # integer. Return -1 if this is not possible. This macro does not
+    # raise exceptions.
+    int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
+
+    # Return the character ch converted to a single digit
+    # integer. Return -1 if this is not possible. This macro does not
+    # raise exceptions.
+    int Py_UNICODE_TODIGIT(Py_UNICODE ch)
+
+    # Return the character ch converted to a double. Return -1.0 if
+    # this is not possible. This macro does not raise exceptions.
+    double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
+
+    # To create Unicode objects and access their basic sequence
+    # properties, use these APIs:
+
+    # Create a Unicode Object from the Py_UNICODE buffer u of the
+    # given size. u may be NULL which causes the contents to be
+    # undefined. It is the user's responsibility to fill in the needed
+    # data. The buffer is copied into the new object. If the buffer is
+    # not NULL, the return value might be a shared object. Therefore,
+    # modification of the resulting Unicode object is only allowed
+    # when u is NULL.
+    object PyUnicode_FromUnicode(Py_UNICODE *u, Py_ssize_t size)
+
+    # Return a read-only pointer to the Unicode object's internal
+    # Py_UNICODE buffer, NULL if unicode is not a Unicode object.
+    Py_UNICODE* PyUnicode_AsUnicode(object o) except NULL
+
+    # Return the length of the Unicode object. 
+    Py_ssize_t PyUnicode_GetSize(object o) except -1
+
+    # Coerce an encoded object obj to an Unicode object and return a
+    # reference with incremented refcount.
+    # String and other char buffer compatible objects are decoded
+    # according to the given encoding and using the error handling
+    # defined by errors. Both can be NULL to have the interface use
+    # the default values (see the next section for details).
+    # All other objects, including Unicode objects, cause a TypeError
+    # to be set.
+    object PyUnicode_FromEncodedObject(object o, char *encoding, char *errors)
+
+    # Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict")
+    # which is used throughout the interpreter whenever coercion to
+    # Unicode is needed.
+    object PyUnicode_FromObject(object obj)
+
+    # If the platform supports wchar_t and provides a header file
+    # wchar.h, Python can interface directly to this type using the
+    # following functions. Support is optimized if Python's own
+    # Py_UNICODE type is identical to the system's wchar_t.
+
+    #ctypedef int wchar_t
+
+    # Create a Unicode object from the wchar_t buffer w of the given
+    # size. Return NULL on failure.
+    #PyObject* PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size)
+
+    #Py_ssize_t PyUnicode_AsWideChar(object o, wchar_t *w, Py_ssize_t size)
+
+# Codecs
+
+    # Create a Unicode object by decoding size bytes of the encoded
+    # string s. encoding and errors have the same meaning as the
+    # parameters of the same name in the unicode() builtin
+    # function. The codec to be used is looked up using the Python
+    # codec registry. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size and return a
+    # Python string object. encoding and errors have the same meaning
+    # as the parameters of the same name in the Unicode encode()
+    # method. The codec to be used is looked up using the Python codec
+    # registry. Return NULL if an exception was raised by the codec.
+    object PyUnicode_Encode(Py_UNICODE *s, Py_ssize_t size,
+                            char *encoding, char *errors)
+
+    # Encode a Unicode object and return the result as Python string
+    # object. encoding and errors have the same meaning as the
+    # parameters of the same name in the Unicode encode() method. The
+    # codec to be used is looked up using the Python codec
+    # registry. Return NULL if an exception was raised by the codec.
+    object PyUnicode_AsEncodedString(object unicode, char *encoding, char *errors)
+
+# These are the UTF-8 codec APIs:
+
+    # Create a Unicode object by decoding size bytes of the UTF-8
+    # encoded string s. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_DecodeUTF8(char *s, Py_ssize_t size, char *errors)
+
+    # If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If
+    # consumed is not NULL, trailing incomplete UTF-8 byte sequences
+    # will not be treated as an error. Those bytes will not be decoded
+    # and the number of bytes that have been decoded will be stored in
+    # consumed. New in version 2.4.
+    object PyUnicode_DecodeUTF8Stateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed)
+
+    # Encode the Py_UNICODE buffer of the given size using UTF-8 and
+    # return a Python string object. Return NULL if an exception was
+    # raised by the codec.
+    object PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+    # Encode a Unicode objects using UTF-8 and return the result as Python string object. Error handling is ``strict''. Return NULL if an exception was raised by the codec. 
+    object PyUnicode_AsUTF8String(object unicode)
+
+# These are the UTF-16 codec APIs:
+
+    # Decode length bytes from a UTF-16 encoded buffer string and
+    # return the corresponding Unicode object. errors (if non-NULL)
+    # defines the error handling. It defaults to ``strict''.
+    # 
+    # If byteorder is non-NULL, the decoder starts decoding using the
+    # given byte order:
+    #
+    #   *byteorder == -1: little endian
+    #   *byteorder == 0:  native order
+    #   *byteorder == 1:  big endian
+    #
+    # and then switches if the first two bytes of the input data are a
+    # byte order mark (BOM) and the specified byte order is native
+    # order. This BOM is not copied into the resulting Unicode
+    # string. After completion, *byteorder is set to the current byte
+    # order at the.
+    #
+    # If byteorder is NULL, the codec starts in native order mode.
+    object PyUnicode_DecodeUTF16(char *s, Py_ssize_t size, char *errors, int *byteorder)
+
+    # If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If
+    # consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not
+    # treat trailing incomplete UTF-16 byte sequences (such as an odd
+    # number of bytes or a split surrogate pair) as an error. Those
+    # bytes will not be decoded and the number of bytes that have been
+    # decoded will be stored in consumed. New in version 2.4.
+    object PyUnicode_DecodeUTF16Stateful(char *s, Py_ssize_t size, char *errors, int *byteorder, Py_ssize_t *consumed)
+
+    # Return a Python string object holding the UTF-16 encoded value
+    # of the Unicode data in s. If byteorder is not 0, output is
+    # written according to the following byte order:
+    #
+    #   byteorder == -1: little endian
+    #   byteorder == 0:  native byte order (writes a BOM mark)
+    #   byteorder == 1:  big endian
+    #
+    # If byteorder is 0, the output string will always start with the
+    # Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark
+    # is prepended.
+    #
+    # If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get
+    # represented as a surrogate pair. If it is not defined, each
+    # Py_UNICODE values is interpreted as an UCS-2 character.
+    object PyUnicode_EncodeUTF16(Py_UNICODE *s, Py_ssize_t size, char *errors, int byteorder)
+
+    # Return a Python string using the UTF-16 encoding in native byte
+    # order. The string always starts with a BOM mark. Error handling
+    # is ``strict''. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_AsUTF16String(object unicode)
+
+# These are the ``Unicode Escape'' codec APIs:
+
+    # Create a Unicode object by decoding size bytes of the
+    # Unicode-Escape encoded string s. Return NULL if an exception was
+    # raised by the codec.
+    object PyUnicode_DecodeUnicodeEscape(char *s, Py_ssize_t size, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size using
+    # Unicode-Escape and return a Python string object. Return NULL if
+    # an exception was raised by the codec.
+    object PyUnicode_EncodeUnicodeEscape(Py_UNICODE *s, Py_ssize_t size)
+
+    # Encode a Unicode objects using Unicode-Escape and return the
+    # result as Python string object. Error handling is
+    # ``strict''. Return NULL if an exception was raised by the codec.
+    object PyUnicode_AsUnicodeEscapeString(object unicode)
+
+# These are the ``Raw Unicode Escape'' codec APIs:
+
+    # Create a Unicode object by decoding size bytes of the
+    # Raw-Unicode-Escape encoded string s. Return NULL if an exception
+    # was raised by the codec.
+    object PyUnicode_DecodeRawUnicodeEscape(char *s, Py_ssize_t size, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size using
+    # Raw-Unicode-Escape and return a Python string object. Return
+    # NULL if an exception was raised by the codec.
+    object PyUnicode_EncodeRawUnicodeEscape(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+    # Encode a Unicode objects using Raw-Unicode-Escape and return the
+    # result as Python string object. Error handling is
+    # ``strict''. Return NULL if an exception was raised by the codec.
+    object PyUnicode_AsRawUnicodeEscapeString(object unicode)
+
+# These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 Unicode ordinals and only these are accepted by the codecs during encoding.
+
+    # Create a Unicode object by decoding size bytes of the Latin-1
+    # encoded string s. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_DecodeLatin1(char *s, Py_ssize_t size, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size using Latin-1 and
+    # return a Python string object. Return NULL if an exception was
+    # raised by the codec.
+    object PyUnicode_EncodeLatin1(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+    # Encode a Unicode objects using Latin-1 and return the result as
+    # Python string object. Error handling is ``strict''. Return NULL
+    # if an exception was raised by the codec.
+    object PyUnicode_AsLatin1String(object unicode)
+
+# These are the ASCII codec APIs. Only 7-bit ASCII data is
+# accepted. All other codes generate errors.
+
+    # Create a Unicode object by decoding size bytes of the ASCII
+    # encoded string s. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_DecodeASCII(char *s, Py_ssize_t size, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size using ASCII and
+    # return a Python string object. Return NULL if an exception was
+    # raised by the codec.
+    object PyUnicode_EncodeASCII(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+    # Encode a Unicode objects using ASCII and return the result as
+    # Python string object. Error handling is ``strict''. Return NULL
+    # if an exception was raised by the codec.
+    object PyUnicode_AsASCIIString(object o)
+
+# These are the mapping codec APIs:
+#
+# This codec is special in that it can be used to implement many
+# different codecs (and this is in fact what was done to obtain most
+# of the standard codecs included in the encodings package). The codec
+# uses mapping to encode and decode characters.
+#
+# Decoding mappings must map single string characters to single
+# Unicode characters, integers (which are then interpreted as Unicode
+# ordinals) or None (meaning "undefined mapping" and causing an
+# error).
+#
+# Encoding mappings must map single Unicode characters to single
+# string characters, integers (which are then interpreted as Latin-1
+# ordinals) or None (meaning "undefined mapping" and causing an
+# error).
+#
+# The mapping objects provided must only support the __getitem__
+# mapping interface.
+#
+# If a character lookup fails with a LookupError, the character is
+# copied as-is meaning that its ordinal value will be interpreted as
+# Unicode or Latin-1 ordinal resp. Because of this, mappings only need
+# to contain those mappings which map characters to different code
+# points.
+
+    # Create a Unicode object by decoding size bytes of the encoded
+    # string s using the given mapping object. Return NULL if an
+    # exception was raised by the codec. If mapping is NULL latin-1
+    # decoding will be done. Else it can be a dictionary mapping byte
+    # or a unicode string, which is treated as a lookup table. Byte
+    # values greater that the length of the string and U+FFFE
+    # "characters" are treated as "undefined mapping". Changed in
+    # version 2.4: Allowed unicode string as mapping argument.
+    object PyUnicode_DecodeCharmap(char *s, Py_ssize_t size, object mapping, char *errors)
+
+    # Encode the Py_UNICODE buffer of the given size using the given
+    # mapping object and return a Python string object. Return NULL if
+    # an exception was raised by the codec.
+    object PyUnicode_EncodeCharmap(Py_UNICODE *s, Py_ssize_t size, object mapping, char *errors)
+
+    # Encode a Unicode objects using the given mapping object and
+    # return the result as Python string object. Error handling is
+    # ``strict''. Return NULL if an exception was raised by the codec.
+    object PyUnicode_AsCharmapString(object o, object mapping)
+
+# The following codec API is special in that maps Unicode to Unicode.
+
+    # Translate a Py_UNICODE buffer of the given length by applying a
+    # character mapping table to it and return the resulting Unicode
+    # object. Return NULL when an exception was raised by the codec.
+    #
+    # The mapping table must map Unicode ordinal integers to Unicode
+    # ordinal integers or None (causing deletion of the character).
+    #
+    # Mapping tables need only provide the __getitem__() interface;
+    # dictionaries and sequences work well. Unmapped character
+    # ordinals (ones which cause a LookupError) are left untouched and
+    # are copied as-is.
+    object PyUnicode_TranslateCharmap(Py_UNICODE *s, Py_ssize_t size,
+                                      object table, char *errors)
+
+# These are the MBCS codec APIs. They are currently only available on
+# Windows and use the Win32 MBCS converters to implement the
+# conversions. Note that MBCS (or DBCS) is a class of encodings, not
+# just one. The target encoding is defined by the user settings on the
+# machine running the codec.
+
+    # Create a Unicode object by decoding size bytes of the MBCS
+    # encoded string s. Return NULL if an exception was raised by the
+    # codec.
+    object PyUnicode_DecodeMBCS(char *s, Py_ssize_t size, char *errors)
+
+    # If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If
+    # consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not
+    # decode trailing lead byte and the number of bytes that have been
+    # decoded will be stored in consumed. New in version 2.5.
+    object PyUnicode_DecodeMBCSStateful(char *s, int size, char *errors, int *consumed)
+
+    # Encode the Py_UNICODE buffer of the given size using MBCS and
+    # return a Python string object. Return NULL if an exception was
+    # raised by the codec.
+    object PyUnicode_EncodeMBCS(Py_UNICODE *s, Py_ssize_t size, char *errors)
+
+    # Encode a Unicode objects using MBCS and return the result as
+    # Python string object. Error handling is ``strict''. Return NULL
+    # if an exception was raised by the codec.
+    object PyUnicode_AsMBCSString(object o)
diff --git a/Cython/Includes/cpython/version.pxd b/Cython/Includes/cpython/version.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..e5aee0fb5e6c8c7d0acfffb459a0173fe3711f14
--- /dev/null
+++ b/Cython/Includes/cpython/version.pxd
@@ -0,0 +1,32 @@
+# Python version constants
+#
+# It's better to evaluate these at runtime (i.e. C compile time) using
+#
+#      if PY_MAJOR_VERSION >= 3:
+#           do_stuff_in_Py3_0_and_later()
+#      if PY_VERSION_HEX >= 0x02050000:
+#           do_stuff_in_Py2_5_and_later()
+#
+# than using the IF/DEF statements, which are evaluated at Cython
+# compile time.  This will keep your C code portable.
+
+
+cdef extern from *:
+    # the complete version, e.g. 0x010502B2 == 1.5.2b2
+    int PY_VERSION_HEX
+
+    # the individual sections as plain numbers
+    int PY_MAJOR_VERSION
+    int PY_MINOR_VERSION
+    int PY_MICRO_VERSION
+    int PY_RELEASE_LEVEL
+    int PY_RELEASE_SERIAL
+
+    # Note: PY_RELEASE_LEVEL is one of
+    #    0xA (alpha)
+    #    0xB (beta)
+    #    0xC (release candidate)
+    #    0xF (final)
+
+    char PY_VERSION[]
+    char PY_PATCHLEVEL_REVISION[]
diff --git a/Cython/Includes/cpython/weakref.pxd b/Cython/Includes/cpython/weakref.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..8f510526afde9e288913eca0d5c296024181dc54
--- /dev/null
+++ b/Cython/Includes/cpython/weakref.pxd
@@ -0,0 +1,42 @@
+from cpython.ref cimport PyObject
+
+cdef extern from "Python.h":
+
+    bint PyWeakref_Check(object ob)
+    # Return true if ob is either a reference or proxy object.
+
+    bint PyWeakref_CheckRef(object ob)
+    # Return true if ob is a reference object.
+
+    bint PyWeakref_CheckProxy(ob)
+    # Return true if *ob* is a proxy object.
+
+    object PyWeakref_NewRef(object ob, object callback)
+    # Return a weak reference object for the object ob.  This will
+    # always return a new reference, but is not guaranteed to create a
+    # new object; an existing reference object may be returned.  The
+    # second parameter, callback, can be a callable object that
+    # receives notification when ob is garbage collected; it should
+    # accept a single parameter, which will be the weak reference
+    # object itself. callback may also be None or NULL.  If ob is not
+    # a weakly-referencable object, or if callback is not callable,
+    # None, or NULL, this will return NULL and raise TypeError.
+
+    object PyWeakref_NewProxy(object ob, object callback)
+    # Return a weak reference proxy object for the object ob.  This
+    # will always return a new reference, but is not guaranteed to
+    # create a new object; an existing proxy object may be returned.
+    # The second parameter, callback, can be a callable object that
+    # receives notification when ob is garbage collected; it should
+    # accept a single parameter, which will be the weak reference
+    # object itself. callback may also be None or NULL.  If ob is not
+    # a weakly-referencable object, or if callback is not callable,
+    # None, or NULL, this will return NULL and raise TypeError.
+
+    PyObject* PyWeakref_GetObject(object ref)
+    # Return the referenced object from a weak reference, ref.  If the
+    # referent is no longer live, returns None.
+
+    PyObject* PyWeakref_GET_OBJECT(object ref)
+    # Similar to PyWeakref_GetObject, but implemented as a macro that
+    # does no error checking.
diff --git a/Cython/Includes/libc/__init__.pyx b/Cython/Includes/libc/__init__.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..fa81adaff68e06d8e915a6afa375f62f7e5a8fad
--- /dev/null
+++ b/Cython/Includes/libc/__init__.pyx
@@ -0,0 +1 @@
+# empty file
diff --git a/Cython/Includes/libc/stdio.pxd b/Cython/Includes/libc/stdio.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..cc574105f40fbacd47824afe947a6e6adfa4563a
--- /dev/null
+++ b/Cython/Includes/libc/stdio.pxd
@@ -0,0 +1,9 @@
+cdef extern from "stdio.h" nogil:
+    ctypedef struct FILE
+    int printf(char *format, ...)
+    int fprintf(FILE *stream, char *format, ...)
+    int sprintf(char *str, char *format, ...)
+    FILE *fopen(char *path, char *mode)
+    int fclose(FILE *strea)
+    cdef FILE *stdout
+    int scanf(char *format, ...)
diff --git a/Cython/Includes/libc/stdlib.pxd b/Cython/Includes/libc/stdlib.pxd
new file mode 100644
index 0000000000000000000000000000000000000000..40192d1352a7f26341ca7cd08aee0c77fb1f3834
--- /dev/null
+++ b/Cython/Includes/libc/stdlib.pxd
@@ -0,0 +1,7 @@
+
+cdef extern from "stdlib.h" nogil:
+    void free(void *ptr)
+    void *malloc(size_t size)
+    void *realloc(void *ptr, size_t size)
+    size_t strlen(char *s)
+    char *strcpy(char *dest, char *src)
diff --git a/Cython/Includes/python.pxd b/Cython/Includes/python.pxd
index d7a6ebc0a9568a011d18965775a593a0fccef3df..ee1419e92affa069cc623d624e46e7dbfff088dd 100644
--- a/Cython/Includes/python.pxd
+++ b/Cython/Includes/python.pxd
@@ -1,159 +1,2 @@
-#####################################################################
-#
-# These are the Cython pxd files for (most of) the Python/C API.
-#
-# REFERENCE COUNTING:
-#
-#   JUST TO SCARE YOU:
-#   If you are going to use any of the Python/C API in your Cython
-#   program, you might be responsible for doing reference counting.
-#   Read http://docs.python.org/api/refcounts.html which is so
-#   important I've copied it below.
-#
-# For all the declaration below, whenver the Py_ function returns
-# a *new reference* to a PyObject*, the return type is "object".
-# When the function returns a borrowed reference, the return
-# type is PyObject*.  When Cython sees "object" as a return type
-# it doesn't increment the reference count.  When it sees PyObject*
-# in order to use the result you must explicitly cast to <object>,
-# and when you do that Cython increments the reference count wether
-# you want it to or not, forcing you to an explicit DECREF (or leak memory).
-# To avoid this we make the above convention.  Note, you can
-# always locally override this convention by putting something like
-#
-#     cdef extern from "Python.h":
-#         PyObject* PyNumber_Add(PyObject *o1, PyObject *o2)
-#
-# in your file after any .pxi includes.  Cython will use the latest
-# declaration. 
-#
-# Cython takes care of this automatically for anything of type object.
-## More precisely, I think the correct convention for
-## using the Python/C API from Pyrex is as follows.
-##
-## (1) Declare all input arguments as type "object".  This way no explicit
-##    <PyObject*> casting is needed, and moreover Pyrex doesn't generate
-##    any funny reference counting.
-## (2) Declare output as object if a new reference is returned.
-## (3) Declare output as PyObject* if a borrowed reference is returned.
-##    
-## This way when you call objects, no cast is needed, and if the api
-## calls returns a new reference (which is about 95% of them), then
-## you can just assign to a variable of type object.  With borrowed
-## references if you do an explicit typecast to <object>, Pyrex generates an
-## INCREF and DECREF so you have to be careful.  However, you got a
-## borrowed reference in this case, so there's got to be another reference
-## to your object, so you're OK, as long as you relealize this
-## and use the result of an explicit cast to <object> as a borrowed
-## reference (and you can call Py_INCREF if you want to turn it
-## into another reference for some reason). 
-# 
-# "The reference count is important because today's computers have
-# a finite (and often severely limited) memory size; it counts how
-# many different places there are that have a reference to an
-# object. Such a place could be another object, or a global (or
-# static) C variable, or a local variable in some C function. When
-# an object's reference count becomes zero, the object is
-# deallocated. If it contains references to other objects, their
-# reference count is decremented. Those other objects may be
-# deallocated in turn, if this decrement makes their reference
-# count become zero, and so on. (There's an obvious problem with
-# objects that reference each other here; for now, the solution is
-# ``don't do that.'')
-#
-# Reference counts are always manipulated explicitly. The normal
-# way is to use the macro Py_INCREF() to increment an object's
-# reference count by one, and Py_DECREF() to decrement it by
-# one. The Py_DECREF() macro is considerably more complex than the
-# incref one, since it must check whether the reference count
-# becomes zero and then cause the object's deallocator to be
-# called. The deallocator is a function pointer contained in the
-# object's type structure. The type-specific deallocator takes
-# care of decrementing the reference counts for other objects
-# contained in the object if this is a compound object type, such
-# as a list, as well as performing any additional finalization
-# that's needed. There's no chance that the reference count can
-# overflow; at least as many bits are used to hold the reference
-# count as there are distinct memory locations in virtual memory
-# (assuming sizeof(long) >= sizeof(char*)). Thus, the reference
-# count increment is a simple operation.
-# 
-# It is not necessary to increment an object's reference count for
-# every local variable that contains a pointer to an object. In
-# theory, the object's reference count goes up by one when the
-# variable is made to point to it and it goes down by one when the
-# variable goes out of scope. However, these two cancel each other
-# out, so at the end the reference count hasn't changed. The only
-# real reason to use the reference count is to prevent the object
-# from being deallocated as long as our variable is pointing to
-# it. If we know that there is at least one other reference to the
-# object that lives at least as long as our variable, there is no
-# need to increment the reference count temporarily. An important
-# situation where this arises is in objects that are passed as
-# arguments to C functions in an extension module that are called
-# from Python; the call mechanism guarantees to hold a reference
-# to every argument for the duration of the call.
-#
-# However, a common pitfall is to extract an object from a list
-# and hold on to it for a while without incrementing its reference
-# count. Some other operation might conceivably remove the object
-# from the list, decrementing its reference count and possible
-# deallocating it. The real danger is that innocent-looking
-# operations may invoke arbitrary Python code which could do this;
-# there is a code path which allows control to flow back to the
-# user from a Py_DECREF(), so almost any operation is potentially
-# dangerous.
-#
-# A safe approach is to always use the generic operations
-# (functions whose name begins with "PyObject_", "PyNumber_",
-# "PySequence_" or "PyMapping_"). These operations always
-# increment the reference count of the object they return. This
-# leaves the caller with the responsibility to call Py_DECREF()
-# when they are done with the result; this soon becomes second
-# nature.
-#
-# Now you should read http://docs.python.org/api/refcountDetails.html
-# just to be sure you understand what is going on.
-#
-#################################################################
-
-from python_version cimport *
-from python_ref cimport *
-from python_exc cimport *
-from python_module cimport *
-from python_mem cimport *
-from python_tuple cimport *
-from python_list cimport *
-from python_object cimport *
-from python_sequence cimport *
-from python_mapping cimport *
-from python_iterator cimport *
-from python_type cimport *
-from python_number cimport *
-from python_int cimport *
-from python_bool cimport *
-from python_long cimport *
-from python_float cimport *
-from python_complex cimport *
-from python_string cimport *
-from python_unicode cimport *
-from python_dict cimport *
-from python_instance cimport *
-from python_function cimport *
-from python_method cimport *
-from python_weakref cimport *
-from python_getargs cimport *
-
-# Python <= 2.x
-from python_cobject cimport *
-from python_oldbuffer cimport *
-
-# Python >= 2.4
-from python_set cimport *
-
-# Python >= 2.6
-from python_buffer cimport *
-from python_bytes cimport *
-
-# Python >= 3.0
-from python_pycapsule cimport *
+# Present for backwards compatability
+from cpython cimport *
diff --git a/Cython/Includes/python_bool.pxd b/Cython/Includes/python_bool.pxd
index ebf65fe52eb5005d6b78f0b732e9cadab39de37f..2bf64ce03e88b5a6f954c4a27a451cdb97e83072 100644
--- a/Cython/Includes/python_bool.pxd
+++ b/Cython/Includes/python_bool.pxd
@@ -1,35 +1,2 @@
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 7.2.2 Boolean Objects
-    ############################################################################
-
-    # Booleans in Python are implemented as a subclass of
-    # integers. There are only two booleans, Py_False and Py_True. As
-    # such, the normal creation and deletion functions don't apply to
-    # booleans. The following macros are available, however.
-
-    bint PyBool_Check(object o)
-    # Return true if o is of type PyBool_Type.
-
-    #PyObject* Py_False
-    # The Python False object. This object has no methods. It needs to
-    # be treated just like any other object with respect to reference
-    # counts.
-
-    #PyObject* Py_True
-    # The Python True object. This object has no methods. It needs to
-    # be treated just like any other object with respect to reference
-    # counts.
-
-    # Py_RETURN_FALSE
-    # Return Py_False from a function, properly incrementing its reference count. 
-
-    # Py_RETURN_TRUE
-    # Return Py_True from a function, properly incrementing its reference count. 
-
-    object PyBool_FromLong(long v)
-    # Return value: New reference.
-    # Return a new reference to Py_True or Py_False depending on the truth value of v. 
-
+# Present for backwards compatability
+from cpython.bool cimport *
diff --git a/Cython/Includes/python_buffer.pxd b/Cython/Includes/python_buffer.pxd
index 654eb9694e30996aee90249bd7c87c441cb90b11..6329e36a6202c5e151d8ce2c7310c7995d28223c 100644
--- a/Cython/Includes/python_buffer.pxd
+++ b/Cython/Includes/python_buffer.pxd
@@ -1,109 +1,2 @@
-# Please see the Python header files (object.h/abstract.h) for docs
-
-cdef extern from "Python.h":
-
-    cdef enum:
-        PyBUF_SIMPLE,
-        PyBUF_WRITABLE,
-        PyBUF_WRITEABLE, # backwards compatability
-        PyBUF_FORMAT,
-        PyBUF_ND,
-        PyBUF_STRIDES,
-        PyBUF_C_CONTIGUOUS,
-        PyBUF_F_CONTIGUOUS,
-        PyBUF_ANY_CONTIGUOUS,
-        PyBUF_INDIRECT,
-        PyBUF_CONTIG,
-        PyBUF_CONTIG_RO,
-        PyBUF_STRIDED,
-        PyBUF_STRIDED_RO,
-        PyBUF_RECORDS,
-        PyBUF_RECORDS_RO,
-        PyBUF_FULL,
-        PyBUF_FULL_RO,
-        PyBUF_READ,
-        PyBUF_WRITE,
-        PyBUF_SHADOW
-
-    bint PyObject_CheckBuffer(object obj)
-    # Return 1 if obj supports the buffer interface otherwise 0.
-
-    int PyObject_GetBuffer(object obj, Py_buffer *view, int flags) except -1
-    # Export obj into a Py_buffer, view. These arguments must never be
-    # NULL. The flags argument is a bit field indicating what kind of
-    # buffer the caller is prepared to deal with and therefore what
-    # kind of buffer the exporter is allowed to return. The buffer
-    # interface allows for complicated memory sharing possibilities,
-    # but some caller may not be able to handle all the complexity but
-    # may want to see if the exporter will let them take a simpler
-    # view to its memory.
-
-    # Some exporters may not be able to share memory in every possible
-    # way and may need to raise errors to signal to some consumers
-    # that something is just not possible. These errors should be a
-    # BufferError unless there is another error that is actually
-    # causing the problem. The exporter can use flags information to
-    # simplify how much of the Py_buffer structure is filled in with
-    # non-default values and/or raise an error if the object can’t
-    # support a simpler view of its memory.
-
-    # 0 is returned on success and -1 on error.
-
-    void PyBuffer_Release(object obj, object view)
-    # Release the buffer view over obj. This should be called when the
-    # buffer is no longer being used as it may free memory from it.
-
-    void* PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices)
-    # ??
-
-    int PyBuffer_SizeFromFormat(char *) # actually const char
-    # Return the implied ~Py_buffer.itemsize from the struct-stype
-    # ~Py_buffer.format
-
-    int PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort)
-    # ??
-
-    int PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
-    # ??
-
-    int PyObject_CopyToObject(object obj, void *buf, Py_ssize_t len, char fortran) except -1
-    # Copy len bytes of data pointed to by the contiguous chunk of
-    # memory pointed to by buf into the buffer exported by obj. The
-    # buffer must of course be writable. Return 0 on success and
-    # return -1 and raise an error on failure. If the object does not
-    # have a writable buffer, then an error is raised. If fortran is
-    # 'F', then if the object is multi-dimensional, then the data will
-    # be copied into the array in Fortran-style (first dimension
-    # varies the fastest). If fortran is 'C', then the data will be
-    # copied into the array in C-style (last dimension varies the
-    # fastest). If fortran is 'A', then it does not matter and the
-    # copy will be made in whatever way is more efficient.
-
-    int PyObject_CopyData(object dest, object src) except -1
-    # Copy the data from the src buffer to the buffer of destination
-
-    bint PyBuffer_IsContiguous(Py_buffer *view, char fort)
-    # Return 1 if the memory defined by the view is C-style (fortran
-    # is 'C') or Fortran-style (fortran is 'F') contiguous or either
-    # one (fortran is 'A'). Return 0 otherwise.
-
-    void PyBuffer_FillContiguousStrides(int ndims, 
-                                        Py_ssize_t *shape, 
-                                        Py_ssize_t *strides,
-                                        int itemsize,
-                                        char fort)
-    # Fill the strides array with byte-strides of a contiguous
-    # (Fortran-style if fort is 'F' or C-style otherwise) array of the
-    # given shape with the given number of bytes per element.
-
-    int PyBuffer_FillInfo(Py_buffer *view, void *buf,
-                          Py_ssize_t len, int readonly,
-                          int flags) except -1
-    # Fill in a buffer-info structure, view, correctly for an exporter
-    # that can only share a contiguous chunk of memory of “unsigned
-    # bytes” of the given length. Return 0 on success and -1 (with
-    # raising an error) on error.
-
-    object PyObject_Format(object obj, object format_spec)
-    # Takes an arbitrary object and returns the result of calling
-    # obj.__format__(format_spec).
+# Present for backwards compatability
+from cpython.buffer cimport *
diff --git a/Cython/Includes/python_bytes.pxd b/Cython/Includes/python_bytes.pxd
index b0c08c458c1ea14aa103da6ec381bd86371aeb4d..7cfa1c23e676b1e66d35757df9774bb2b7918368 100644
--- a/Cython/Includes/python_bytes.pxd
+++ b/Cython/Includes/python_bytes.pxd
@@ -1,198 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-    ctypedef struct va_list
-
-    ############################################################################
-    # 7.3.1 String Objects
-    ############################################################################
-
-    # These functions raise TypeError when expecting a string
-    # parameter and are called with a non-string parameter.
-    # PyStringObject
-    # This subtype of PyObject represents a Python bytes object. 
-    # PyTypeObject PyBytes_Type
-    # This instance of PyTypeObject represents the Python bytes type;
-    # it is the same object as bytes and types.BytesType in the Python
-    # layer. 
-
-    bint PyBytes_Check(object o)
-    # Return true if the object o is a string object or an instance of
-    # a subtype of the string type. 
-
-    bint PyBytes_CheckExact(object o)
-    # Return true if the object o is a string object, but not an instance of a subtype of the string type. 
-
-    object PyBytes_FromString(char *v)
-    # Return value: New reference.
-    # Return a new string object with the value v on success, and NULL
-    # on failure. The parameter v must not be NULL; it will not be
-    # checked.
-
-    object PyBytes_FromStringAndSize(char *v, Py_ssize_t len)
-    # Return value: New reference.
-    # Return a new string object with the value v and length len on
-    # success, and NULL on failure. If v is NULL, the contents of the
-    # string are uninitialized.
-
-    object PyBytes_FromFormat(char *format, ...)
-    # Return value: New reference.
-    # Take a C printf()-style format string and a variable number of
-    # arguments, calculate the size of the resulting Python string and
-    # return a string with the values formatted into it. The variable
-    # arguments must be C types and must correspond exactly to the
-    # format characters in the format string. The following format
-    # characters are allowed:
-    # Format Characters 	Type 	Comment
-    # %% 	n/a 	The literal % character.
-    # %c 	int 	A single character, represented as an C int.
-    # %d 	int 	Exactly equivalent to printf("%d").
-    # %u 	unsigned int 	Exactly equivalent to printf("%u").
-    # %ld 	long 	Exactly equivalent to printf("%ld").
-    # %lu 	unsigned long 	Exactly equivalent to printf("%lu").
-    # %zd 	Py_ssize_t 	Exactly equivalent to printf("%zd").
-    # %zu 	size_t 	Exactly equivalent to printf("%zu").
-    # %i 	int 	Exactly equivalent to printf("%i").
-    # %x 	int 	Exactly equivalent to printf("%x").
-    # %s 	char* 	A null-terminated C character array.
-
-    # %p 	void* 	The hex representation of a C pointer.
-    #    Mostly equivalent to printf("%p") except that it is guaranteed to
-    #    start with the literal 0x regardless of what the platform's printf
-    #    yields.
-    # An unrecognized format character causes all the rest of the
-    # format string to be copied as-is to the result string, and any
-    # extra arguments discarded.
-
-    object PyBytes_FromFormatV(char *format, va_list vargs)
-    # Return value: New reference.
-    # Identical to PyBytes_FromFormat() except that it takes exactly two arguments. 
-
-    Py_ssize_t PyBytes_Size(object string) except -1
-    # Return the length of the string in string object string. 
-
-    Py_ssize_t PyBytes_GET_SIZE(object string)
-    # Macro form of PyBytes_Size() but without error checking. 
-
-    char* PyBytes_AsString(object string) except NULL
-    # Return a NUL-terminated representation of the contents of
-    # string. The pointer refers to the internal buffer of string, not
-    # a copy. The data must not be modified in any way, unless the
-    # string was just created using PyBytes_FromStringAndSize(NULL,
-    # size). It must not be deallocated. If string is a Unicode
-    # object, this function computes the default encoding of string
-    # and operates on that. If string is not a string object at all,
-    # PyBytes_AsString() returns NULL and raises TypeError.
-
-    char* PyBytes_AS_STRING(object string)
-    # Macro form of PyBytes_AsString() but without error
-    # checking. Only string objects are supported; no Unicode objects
-    # should be passed.
-
-    int PyBytes_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
-    # Return a NULL-terminated representation of the contents of the
-    # object obj through the output variables buffer and length.
-    #
-    # The function accepts both string and Unicode objects as
-    # input. For Unicode objects it returns the default encoded
-    # version of the object. If length is NULL, the resulting buffer
-    # may not contain NUL characters; if it does, the function returns
-    # -1 and a TypeError is raised.
-    
-    # The buffer refers to an internal string buffer of obj, not a
-    # copy. The data must not be modified in any way, unless the
-    # string was just created using PyBytes_FromStringAndSize(NULL,
-    # size). It must not be deallocated. If string is a Unicode
-    # object, this function computes the default encoding of string
-    # and operates on that. If string is not a string object at all,
-    # PyBytes_AsStringAndSize() returns -1 and raises TypeError.
-
-    void PyBytes_Concat(PyObject **string, object newpart)
-    # Create a new string object in *string containing the contents of
-    # newpart appended to string; the caller will own the new
-    # reference. The reference to the old value of string will be
-    # stolen. If the new string cannot be created, the old reference
-    # to string will still be discarded and the value of *string will
-    # be set to NULL; the appropriate exception will be set.
-
-    void PyBytes_ConcatAndDel(PyObject **string, object newpart)
-    # Create a new string object in *string containing the contents of
-    # newpart appended to string. This version decrements the
-    # reference count of newpart.
-
-    int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
-    # A way to resize a string object even though it is
-    # ``immutable''. Only use this to build up a brand new string
-    # object; don't use this if the string may already be known in
-    # other parts of the code. It is an error to call this function if
-    # the refcount on the input string object is not one. Pass the
-    # address of an existing string object as an lvalue (it may be
-    # written into), and the new size desired. On success, *string
-    # holds the resized string object and 0 is returned; the address
-    # in *string may differ from its input value. If the reallocation
-    # fails, the original string object at *string is deallocated,
-    # *string is set to NULL, a memory exception is set, and -1 is
-    # returned.
-
-    object PyBytes_Format(object format, object args)
-    # Return value: New reference.  Return a new string object from
-    # format and args. Analogous to format % args. The args argument
-    # must be a tuple.
-
-    void PyBytes_InternInPlace(PyObject **string)
-    # Intern the argument *string in place. The argument must be the
-    # address of a pointer variable pointing to a Python string
-    # object. If there is an existing interned string that is the same
-    # as *string, it sets *string to it (decrementing the reference
-    # count of the old string object and incrementing the reference
-    # count of the interned string object), otherwise it leaves
-    # *string alone and interns it (incrementing its reference
-    # count). (Clarification: even though there is a lot of talk about
-    # reference counts, think of this function as
-    # reference-count-neutral; you own the object after the call if
-    # and only if you owned it before the call.)
-
-    object PyBytes_InternFromString(char *v)
-    # Return value: New reference.
-    # A combination of PyBytes_FromString() and
-    # PyBytes_InternInPlace(), returning either a new string object
-    # that has been interned, or a new (``owned'') reference to an
-    # earlier interned string object with the same value.
-
-    object PyBytes_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
-    #  Return value: New reference.
-    # Create an object by decoding size bytes of the encoded buffer s
-    # using the codec registered for encoding. encoding and errors
-    # have the same meaning as the parameters of the same name in the
-    # unicode() built-in function. The codec to be used is looked up
-    # using the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-    object PyBytes_AsDecodedObject(object str, char *encoding, char *errors)
-    # Return value: New reference.
-    # Decode a string object by passing it to the codec registered for
-    # encoding and return the result as Python object. encoding and
-    # errors have the same meaning as the parameters of the same name
-    # in the string encode() method. The codec to be used is looked up
-    # using the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-    object PyBytes_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
-    # Return value: New reference.
-    # Encode the char buffer of the given size by passing it to the
-    # codec registered for encoding and return a Python
-    # object. encoding and errors have the same meaning as the
-    # parameters of the same name in the string encode() method. The
-    # codec to be used is looked up using the Python codec
-    # registry. Return NULL if an exception was raised by the codec.
-
-    object PyBytes_AsEncodedObject(object str, char *encoding, char *errors)
-    # Return value: New reference.
-    # Encode a string object using the codec registered for encoding
-    # and return the result as Python object. encoding and errors have
-    # the same meaning as the parameters of the same name in the
-    # string encode() method. The codec to be used is looked up using
-    # the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-
+# Present for backwards compatability
+from cpython.bytes cimport *
diff --git a/Cython/Includes/python_cobject.pxd b/Cython/Includes/python_cobject.pxd
index 12bf9bc96aa9cfbe23fe2839e1350b52f66bf12d..537e7ca2687ebbdb54cc983a9683b680120214e0 100644
--- a/Cython/Includes/python_cobject.pxd
+++ b/Cython/Includes/python_cobject.pxd
@@ -1,37 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ###########################################################################
-    # Warning:
-    #
-    # The CObject API is deprecated as of Python 3.1. Please switch to
-    # the new Capsules API.
-    ###########################################################################
-
-    int PyCObject_Check(object p)
-    #     Return true if its argument is a PyCObject.
-
-    object PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))
-    #     Return value: New reference.
-    #
-    #     Create a PyCObject from the void * cobj. The destr function will
-    #     be called when the object is reclaimed, unless it is NULL.
-
-    object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc, void (*destr)(void *, void *))
-    #     Return value: New reference.
-    #
-    #     Create a PyCObject from the void * cobj. The destr function will
-    #     be called when the object is reclaimed. The desc argument can be
-    #     used to pass extra callback data for the destructor function.
-
-    void* PyCObject_AsVoidPtr(object self) except? NULL
-    #     Return the object void * that the PyCObject self was created with.
-
-    void* PyCObject_GetDesc(object self) except? NULL
-    #     Return the description void * that the PyCObject self was created with.
-
-    int PyCObject_SetVoidPtr(object self, void* cobj) except 0
-    #     Set the void pointer inside self to cobj. The PyCObject must not
-    #     have an associated destructor. Return true on success, false on
-    #     failure.
+# Present for backwards compatability
+from cpython.cobject cimport *
diff --git a/Cython/Includes/python_complex.pxd b/Cython/Includes/python_complex.pxd
index 116698d91b5818d7801f6fd33e6373bd18705fc8..87f99d23273e6f05c1a7717cd5660d985e09eb4d 100644
--- a/Cython/Includes/python_complex.pxd
+++ b/Cython/Includes/python_complex.pxd
@@ -1,41 +1,2 @@
-
-cdef extern from "Python.h":
-    ctypedef struct Py_complex
-
-    ############################################################################
-    # 7.2.5.2 Complex Numbers as Python Objects
-    ############################################################################
-
-    # PyComplexObject
-    # This subtype of PyObject represents a Python complex number object. 
-
-    # PyTypeObject PyComplex_Type
-    # This instance of PyTypeObject represents the Python complex
-    # number type. It is the same object as complex and
-    # types.ComplexType.
-
-    bint PyComplex_Check(object p)
-    # Return true if its argument is a PyComplexObject or a subtype of
-    # PyComplexObject.
-
-    bint PyComplex_CheckExact(object p)
-    # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
-
-    object PyComplex_FromCComplex(Py_complex v)
-    # Return value: New reference.
-    # Create a new Python complex number object from a C Py_complex value. 
-
-    object PyComplex_FromDoubles(double real, double imag)
-    # Return value: New reference.
-    # Return a new PyComplexObject object from real and imag. 
-
-    double PyComplex_RealAsDouble(object op) except? -1
-    # Return the real part of op as a C double. 
-
-    double PyComplex_ImagAsDouble(object op) except? -1
-    # Return the imaginary part of op as a C double. 
-
-    Py_complex PyComplex_AsCComplex(object op)
-    # Return the Py_complex value of the complex number op.
-    #
-    # Returns (-1+0i) in case of an error
+# Present for backwards compatability
+from cpython.complex cimport *
diff --git a/Cython/Includes/python_dict.pxd b/Cython/Includes/python_dict.pxd
index 217cdeeeadaa05d99d762b3149514ea9aaaedc7c..5ad91178c321c608ff5803b5fe744a64f3c5608e 100644
--- a/Cython/Includes/python_dict.pxd
+++ b/Cython/Includes/python_dict.pxd
@@ -1,165 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 7.4.1 Dictionary Objects
-    ############################################################################
-
-    # PyDictObject
-    #
-    # This subtype of PyObject represents a Python dictionary object
-    # (i.e. the 'dict' type).
-    
-    # PyTypeObject PyDict_Type
-    #
-    # This instance of PyTypeObject represents the Python dictionary
-    # type. This is exposed to Python programs as dict and
-    # types.DictType.
-
-    bint PyDict_Check(object p)
-    # Return true if p is a dict object or an instance of a subtype of
-    # the dict type. 
-
-    bint PyDict_CheckExact(object p)
-    # Return true if p is a dict object, but not an instance of a
-    # subtype of the dict type.
-
-    object PyDict_New()
-    # Return value: New reference.
-    # Return a new empty dictionary, or NULL on failure. 
-
-    object PyDictProxy_New(object dict)
-    # Return value: New reference.
-    # Return a proxy object for a mapping which enforces read-only
-    # behavior. This is normally used to create a proxy to prevent
-    # modification of the dictionary for non-dynamic class types. 
-
-    void PyDict_Clear(object p)
-    # Empty an existing dictionary of all key-value pairs. 
-
-    int PyDict_Contains(object p, object key) except -1
-    # Determine if dictionary p contains key. If an item in p is
-    # matches key, return 1, otherwise return 0. On error, return
-    # -1. This is equivalent to the Python expression "key in p". 
-
-    object PyDict_Copy(object p)
-    # Return value: New reference.
-    # Return a new dictionary that contains the same key-value pairs as p.
-
-    int PyDict_SetItem(object p, object key, object val) except -1
-    # Insert value into the dictionary p with a key of key. key must
-    # be hashable; if it isn't, TypeError will be raised. Return 0 on
-    # success or -1 on failure.
-
-    int PyDict_SetItemString(object p, char *key, object val) except -1
-    # Insert value into the dictionary p using key as a key. key
-    # should be a char*. The key object is created using
-    # PyString_FromString(key). Return 0 on success or -1 on failure.
-
-    int PyDict_DelItem(object p, object key) except -1
-    # Remove the entry in dictionary p with key key. key must be
-    # hashable; if it isn't, TypeError is raised. Return 0 on success
-    # or -1 on failure.
-
-    int PyDict_DelItemString(object p, char *key) except -1
-    # Remove the entry in dictionary p which has a key specified by
-    # the string key. Return 0 on success or -1 on failure.
-
-    PyObject* PyDict_GetItem(object p, object key)
-    # Return value: Borrowed reference.
-    # Return the object from dictionary p which has a key key. Return
-    # NULL if the key key is not present, but without setting an
-    # exception.
-
-    PyObject* PyDict_GetItemString(object p, char *key)
-    # Return value: Borrowed reference.
-    # This is the same as PyDict_GetItem(), but key is specified as a
-    # char*, rather than a PyObject*.
-
-    object PyDict_Items(object p)
-    # Return value: New reference.
-    # Return a PyListObject containing all the items from the
-    # dictionary, as in the dictionary method items() (see the Python
-    # Library Reference).
-
-    object PyDict_Keys(object p)
-    # Return value: New reference.
-    # Return a PyListObject containing all the keys from the
-    # dictionary, as in the dictionary method keys() (see the Python
-    # Library Reference).
-
-    object PyDict_Values(object p)
-    # Return value: New reference.
-    # Return a PyListObject containing all the values from the
-    # dictionary p, as in the dictionary method values() (see the
-    # Python Library Reference).
-
-    Py_ssize_t PyDict_Size(object p) except -1
-    # Return the number of items in the dictionary. This is equivalent
-    # to "len(p)" on a dictionary.
-
-    int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue)
-    # Iterate over all key-value pairs in the dictionary p. The int
-    # referred to by ppos must be initialized to 0 prior to the first
-    # call to this function to start the iteration; the function
-    # returns true for each pair in the dictionary, and false once all
-    # pairs have been reported. The parameters pkey and pvalue should
-    # either point to PyObject* variables that will be filled in with
-    # each key and value, respectively, or may be NULL. Any references
-    # returned through them are borrowed. ppos should not be altered
-    # during iteration. Its value represents offsets within the
-    # internal dictionary structure, and since the structure is
-    # sparse, the offsets are not consecutive.
-    # For example:
-    #
-    #object key, *value;
-    #int pos = 0;
-    #
-    #while (PyDict_Next(self->dict, &pos, &key, &value)) {
-    #   /* do something interesting with the values... */
-    #    ...
-    #}
-    # The dictionary p should not be mutated during iteration. It is
-    # safe (since Python 2.1) to modify the values of the keys as you
-    # iterate over the dictionary, but only so long as the set of keys
-    # does not change. For example:
-    # object key, *value;
-    # int pos = 0;
-    # while (PyDict_Next(self->dict, &pos, &key, &value)) {
-    #    int i = PyInt_AS_LONG(value) + 1;
-    #    object o = PyInt_FromLong(i);
-    #    if (o == NULL)
-    #        return -1;
-    #    if (PyDict_SetItem(self->dict, key, o) < 0) {
-    #        Py_DECREF(o);
-    #        return -1;
-    #    }
-    #    Py_DECREF(o);
-    # }
-
-    int PyDict_Merge(object a, object b, int override) except -1
-    # Iterate over mapping object b adding key-value pairs to
-    # dictionary a. b may be a dictionary, or any object supporting
-    # PyMapping_Keys() and PyObject_GetItem(). If override is true,
-    # existing pairs in a will be replaced if a matching key is found
-    # in b, otherwise pairs will only be added if there is not a
-    # matching key in a. Return 0 on success or -1 if an exception was
-    # raised.
-
-    int PyDict_Update(object a, object b) except -1
-    # This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b)
-    # in Python. Return 0 on success or -1 if an exception was raised.
-
-    int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1
-    # Update or merge into dictionary a, from the key-value pairs in
-    # seq2. seq2 must be an iterable object producing iterable objects
-    # of length 2, viewed as key-value pairs. In case of duplicate
-    # keys, the last wins if override is true, else the first
-    # wins. Return 0 on success or -1 if an exception was
-    # raised. Equivalent Python (except for the return value):
-    #
-    #def PyDict_MergeFromSeq2(a, seq2, override):
-    #    for key, value in seq2:
-    #        if override or key not in a:
-    #            a[key] = value
+# Present for backwards compatability
+from cpython.dict cimport *
diff --git a/Cython/Includes/python_exc.pxd b/Cython/Includes/python_exc.pxd
index a3ddedf04f027890ff5cb744567b57b2f9d17df1..883c4cfc1550ce42c14adc0c91b97184be0cdd46 100644
--- a/Cython/Includes/python_exc.pxd
+++ b/Cython/Includes/python_exc.pxd
@@ -1,250 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-    
-    #####################################################################
-    # 3. Exception Handling
-    #####################################################################
-
-    # The functions described in this chapter will let you handle and
-    # raise Python exceptions. It is important to understand some of
-    # the basics of Python exception handling. It works somewhat like
-    # the Unix errno variable: there is a global indicator (per
-    # thread) of the last error that occurred. Most functions don't
-    # clear this on success, but will set it to indicate the cause of
-    # the error on failure. Most functions also return an error
-    # indicator, usually NULL if they are supposed to return a
-    # pointer, or -1 if they return an integer (exception: the
-    # PyArg_*() functions return 1 for success and 0 for failure).
-
-    # When a function must fail because some function it called
-    # failed, it generally doesn't set the error indicator; the
-    # function it called already set it. It is responsible for either
-    # handling the error and clearing the exception or returning after
-    # cleaning up any resources it holds (such as object references or
-    # memory allocations); it should not continue normally if it is
-    # not prepared to handle the error. If returning due to an error,
-    # it is important to indicate to the caller that an error has been
-    # set. If the error is not handled or carefully propagated,
-    # additional calls into the Python/C API may not behave as
-    # intended and may fail in mysterious ways.
-
-    # The error indicator consists of three Python objects
-    # corresponding to the Python variables sys.exc_type,
-    # sys.exc_value and sys.exc_traceback. API functions exist to
-    # interact with the error indicator in various ways. There is a
-    # separate error indicator for each thread.
-
-    void PyErr_Print()
-    # Print a standard traceback to sys.stderr and clear the error
-    # indicator. Call this function only when the error indicator is
-    # set. (Otherwise it will cause a fatal error!)
-
-    PyObject* PyErr_Occurred()
-    # Return value: Borrowed reference.
-    # Test whether the error indicator is set. If set, return the
-    # exception type (the first argument to the last call to one of
-    # the PyErr_Set*() functions or to PyErr_Restore()). If not set,
-    # return NULL. You do not own a reference to the return value, so
-    # you do not need to Py_DECREF() it. Note: Do not compare the
-    # return value to a specific exception; use
-    # PyErr_ExceptionMatches() instead, shown below. (The comparison
-    # could easily fail since the exception may be an instance instead
-    # of a class, in the case of a class exception, or it may the a
-    # subclass of the expected exception.)
-
-    bint PyErr_ExceptionMatches(object exc)
-    # Equivalent to "PyErr_GivenExceptionMatches(PyErr_Occurred(),
-    # exc)". This should only be called when an exception is actually
-    # set; a memory access violation will occur if no exception has
-    # been raised.
-
-    bint PyErr_GivenExceptionMatches(object given, object exc)
-    # Return true if the given exception matches the exception in
-    # exc. If exc is a class object, this also returns true when given
-    # is an instance of a subclass. If exc is a tuple, all exceptions
-    # in the tuple (and recursively in subtuples) are searched for a
-    # match. If given is NULL, a memory access violation will occur.
-
-    void PyErr_NormalizeException(PyObject** exc, PyObject** val, PyObject** tb)
-    # Under certain circumstances, the values returned by
-    # PyErr_Fetch() below can be ``unnormalized'', meaning that *exc
-    # is a class object but *val is not an instance of the same
-    # class. This function can be used to instantiate the class in
-    # that case. If the values are already normalized, nothing
-    # happens. The delayed normalization is implemented to improve
-    # performance.
-
-    void PyErr_Clear()
-    # Clear the error indicator. If the error indicator is not set, there is no effect. 
-
-    void PyErr_Fetch(PyObject** ptype, PyObject** pvalue, PyObject** ptraceback)
-    # Retrieve the error indicator into three variables whose
-    # addresses are passed. If the error indicator is not set, set all
-    # three variables to NULL. If it is set, it will be cleared and
-    # you own a reference to each object retrieved. The value and
-    # traceback object may be NULL even when the type object is
-    # not. Note: This function is normally only used by code that
-    # needs to handle exceptions or by code that needs to save and
-    # restore the error indicator temporarily.
-
-    void PyErr_Restore(PyObject* type, PyObject* value, PyObject* traceback)
-    # Set the error indicator from the three objects. If the error
-    # indicator is already set, it is cleared first. If the objects
-    # are NULL, the error indicator is cleared. Do not pass a NULL
-    # type and non-NULL value or traceback. The exception type should
-    # be a class. Do not pass an invalid exception type or
-    # value. (Violating these rules will cause subtle problems later.)
-    # This call takes away a reference to each object: you must own a
-    # reference to each object before the call and after the call you
-    # no longer own these references. (If you don't understand this,
-    # don't use this function. I warned you.) Note: This function is
-    # normally only used by code that needs to save and restore the
-    # error indicator temporarily; use PyErr_Fetch() to save the
-    # current exception state.
-
-    void PyErr_SetString(object type, char *message)
-    # This is the most common way to set the error indicator. The
-    # first argument specifies the exception type; it is normally one
-    # of the standard exceptions, e.g. PyExc_RuntimeError. You need
-    # not increment its reference count. The second argument is an
-    # error message; it is converted to a string object.
-
-    void PyErr_SetObject(object type, object value)
-    # This function is similar to PyErr_SetString() but lets you
-    # specify an arbitrary Python object for the ``value'' of the
-    # exception.
-
-    PyObject* PyErr_Format(object exception, char *format, ...) except NULL
-    # Return value: Always NULL.
-    # This function sets the error indicator and returns
-    # NULL. exception should be a Python exception (class, not an
-    # instance). format should be a string, containing format codes,
-    # similar to printf(). The width.precision before a format code is
-    # parsed, but the width part is ignored.
-
-    void PyErr_SetNone(object type)
-    # This is a shorthand for "PyErr_SetObject(type, Py_None)". 
-
-    int PyErr_BadArgument() except 0
-
-    # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
-    # message)", where message indicates that a built-in operation was
-    # invoked with an illegal argument. It is mostly for internal use.
-
-    PyObject* PyErr_NoMemory() except NULL
-    # Return value: Always NULL.
-    # This is a shorthand for "PyErr_SetNone(PyExc_MemoryError)"; it
-    # returns NULL so an object allocation function can write "return
-    # PyErr_NoMemory();" when it runs out of memory.
-
-    PyObject* PyErr_SetFromErrno(object type) except NULL
-    # Return value: Always NULL.
-    # This is a convenience function to raise an exception when a C
-    # library function has returned an error and set the C variable
-    # errno. It constructs a tuple object whose first item is the
-    # integer errno value and whose second item is the corresponding
-    # error message (gotten from strerror()), and then calls
-    # "PyErr_SetObject(type, object)". On Unix, when the errno value
-    # is EINTR, indicating an interrupted system call, this calls
-    # PyErr_CheckSignals(), and if that set the error indicator,
-    # leaves it set to that. The function always returns NULL, so a
-    # wrapper function around a system call can write "return
-    # PyErr_SetFromErrno(type);" when the system call returns an
-    # error.
-
-    PyObject* PyErr_SetFromErrnoWithFilename(object type, char *filename) except NULL
-    # Return value: Always NULL.  Similar to PyErr_SetFromErrno(),
-    # with the additional behavior that if filename is not NULL, it is
-    # passed to the constructor of type as a third parameter. In the
-    # case of exceptions such as IOError and OSError, this is used to
-    # define the filename attribute of the exception instance.
-
-    PyObject* PyErr_SetFromWindowsErr(int ierr) except NULL
-    # Return value: Always NULL.  This is a convenience function to
-    # raise WindowsError. If called with ierr of 0, the error code
-    # returned by a call to GetLastError() is used instead. It calls
-    # the Win32 function FormatMessage() to retrieve the Windows
-    # description of error code given by ierr or GetLastError(), then
-    # it constructs a tuple object whose first item is the ierr value
-    # and whose second item is the corresponding error message (gotten
-    # from FormatMessage()), and then calls
-    # "PyErr_SetObject(PyExc_WindowsError, object)". This function
-    # always returns NULL. Availability: Windows.
-
-    PyObject* PyErr_SetExcFromWindowsErr(object type, int ierr) except NULL
-    # Return value: Always NULL.  Similar to
-    # PyErr_SetFromWindowsErr(), with an additional parameter
-    # specifying the exception type to be raised. Availability:
-    # Windows. New in version 2.3.
-
-    PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, char *filename) except NULL
-    # Return value: Always NULL.  Similar to
-    # PyErr_SetFromWindowsErr(), with the additional behavior that if
-    # filename is not NULL, it is passed to the constructor of
-    # WindowsError as a third parameter. Availability: Windows.
-
-    PyObject* PyErr_SetExcFromWindowsErrWithFilename(object type, int ierr, char *filename) except NULL
-    # Return value: Always NULL.
-    # Similar to PyErr_SetFromWindowsErrWithFilename(), with an
-    # additional parameter specifying the exception type to be
-    # raised. Availability: Windows.
-
-    void PyErr_BadInternalCall()
-    # This is a shorthand for "PyErr_SetString(PyExc_TypeError,
-    # message)", where message indicates that an internal operation
-    # (e.g. a Python/C API function) was invoked with an illegal
-    # argument. It is mostly for internal use.
-
-    int PyErr_WarnEx(object category, char *message, int stacklevel) except -1
-    # Issue a warning message. The category argument is a warning
-    # category (see below) or NULL; the message argument is a message
-    # string. stacklevel is a positive number giving a number of stack
-    # frames; the warning will be issued from the currently executing
-    # line of code in that stack frame. A stacklevel of 1 is the
-    # function calling PyErr_WarnEx(), 2 is the function above that,
-    # and so forth.
-
-    int PyErr_WarnExplicit(object category, char *message, char *filename, int lineno, char *module, object registry) except -1
-    # Issue a warning message with explicit control over all warning
-    # attributes. This is a straightforward wrapper around the Python
-    # function warnings.warn_explicit(), see there for more
-    # information. The module and registry arguments may be set to
-    # NULL to get the default effect described there.
-
-    int PyErr_CheckSignals() except -1
-    # This function interacts with Python's signal handling. It checks
-    # whether a signal has been sent to the processes and if so,
-    # invokes the corresponding signal handler. If the signal module
-    # is supported, this can invoke a signal handler written in
-    # Python. In all cases, the default effect for SIGINT is to raise
-    # the KeyboardInterrupt exception. If an exception is raised the
-    # error indicator is set and the function returns 1; otherwise the
-    # function returns 0. The error indicator may or may not be
-    # cleared if it was previously set.
-
-    void PyErr_SetInterrupt()
-    # This function simulates the effect of a SIGINT signal arriving
-    # -- the next time PyErr_CheckSignals() is called,
-    # KeyboardInterrupt will be raised. It may be called without
-    # holding the interpreter lock.
-
-    object PyErr_NewException(char *name, object base, object dict)
-    # Return value: New reference.
-    # This utility function creates and returns a new exception
-    # object. The name argument must be the name of the new exception,
-    # a C string of the form module.class. The base and dict arguments
-    # are normally NULL. This creates a class object derived from
-    # Exception (accessible in C as PyExc_Exception).
-
-    void PyErr_WriteUnraisable(object obj)
-    # This utility function prints a warning message to sys.stderr
-    # when an exception has been set but it is impossible for the
-    # interpreter to actually raise the exception. It is used, for
-    # example, when an exception occurs in an __del__() method.
-    #
-    # The function is called with a single argument obj that
-    # identifies the context in which the unraisable exception
-    # occurred. The repr of obj will be printed in the warning
-    # message.
-
+# Present for backwards compatability
+from cpython.exc cimport *
diff --git a/Cython/Includes/python_float.pxd b/Cython/Includes/python_float.pxd
index 602cc816d59aaee69c54d631fe38aa62af07f916..494920f7281fc8abac7aefd7efb3eecd45a84147 100644
--- a/Cython/Includes/python_float.pxd
+++ b/Cython/Includes/python_float.pxd
@@ -1,39 +1,2 @@
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 7.2.3 
-    ############################################################################
-    # PyFloatObject
-    #
-    # This subtype of PyObject represents a Python floating point object.
-    
-    # PyTypeObject PyFloat_Type
-    #
-    # This instance of PyTypeObject represents the Python floating
-    # point type. This is the same object as float and
-    # types.FloatType.
-
-    bint PyFloat_Check(object p)
-    # Return true if its argument is a PyFloatObject or a subtype of
-    # PyFloatObject.
-
-    bint PyFloat_CheckExact(object p)
-    # Return true if its argument is a PyFloatObject, but not a
-    # subtype of PyFloatObject. 
-
-    object PyFloat_FromString(object str, char **pend)
-    # Return value: New reference.
-    # Create a PyFloatObject object based on the string value in str,
-    # or NULL on failure. The pend argument is ignored. It remains
-    # only for backward compatibility.
-
-    object PyFloat_FromDouble(double v)
-    # Return value: New reference.
-    # Create a PyFloatObject object from v, or NULL on failure. 
-
-    double PyFloat_AsDouble(object pyfloat) except? -1
-    # Return a C double representation of the contents of pyfloat.
-
-    double PyFloat_AS_DOUBLE(object pyfloat) except? -1
-    # Return a C double representation of the contents of pyfloat, but
-    # without error checking.
+# Present for backwards compatability
+from cpython.float cimport *
diff --git a/Cython/Includes/python_function.pxd b/Cython/Includes/python_function.pxd
index 0c5a658c7d7de1252dbecc2ea613aee116528504..bde3fa980d5e3f9b20e16203f7408b235c16a81c 100644
--- a/Cython/Includes/python_function.pxd
+++ b/Cython/Includes/python_function.pxd
@@ -1,65 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 7.5.3 Function Objects
-    ############################################################################
-    # There are a few functions specific to Python functions.
-
-    # PyFunctionObject
-    #
-    # The C structure used for functions.
-
-    # PyTypeObject PyFunction_Type
-    #
-    # This is an instance of PyTypeObject and represents the Python
-    # function type. It is exposed to Python programmers as
-    # types.FunctionType.
-
-    bint PyFunction_Check(object o)
-    # Return true if o is a function object (has type
-    # PyFunction_Type). The parameter must not be NULL.
-
-    object PyFunction_New(object code, object globals)
-    # Return value: New reference.
-    # Return a new function object associated with the code object
-    # code. globals must be a dictionary with the global variables
-    # accessible to the function.
-    # The function's docstring, name and __module__ are retrieved from
-    # the code object, the argument defaults and closure are set to
-    # NULL.
-
-    PyObject* PyFunction_GetCode(object op) except? NULL
-    # Return value: Borrowed reference.
-    # Return the code object associated with the function object op. 
-
-    PyObject* PyFunction_GetGlobals(object op) except? NULL
-    # Return value: Borrowed reference.
-    # Return the globals dictionary associated with the function object op. 
-
-    PyObject* PyFunction_GetModule(object op) except? NULL
-    # Return value: Borrowed reference.
-    # Return the __module__ attribute of the function object op. This
-    # is normally a string containing the module name, but can be set
-    # to any other object by Python code.
-
-    PyObject* PyFunction_GetDefaults(object op) except? NULL
-    # Return value: Borrowed reference.
-    # Return the argument default values of the function object
-    # op. This can be a tuple of arguments or NULL.
-
-    int PyFunction_SetDefaults(object op, object defaults) except -1
-    # Set the argument default values for the function object
-    # op. defaults must be Py_None or a tuple.
-    # Raises SystemError and returns -1 on failure. 
-
-    PyObject* PyFunction_GetClosure(object op) except? NULL
-    # Return value: Borrowed reference.
-    # Return the closure associated with the function object op. This
-    # can be NULL or a tuple of cell objects.
-
-    int PyFunction_SetClosure(object op, object closure) except -1
-    # Set the closure associated with the function object op. closure
-    # must be Py_None or a tuple of cell objects.
-    # Raises SystemError and returns -1 on failure. 
+# Present for backwards compatability
+from cpython.function cimport *
diff --git a/Cython/Includes/python_getargs.pxd b/Cython/Includes/python_getargs.pxd
index 90d29fafe36b5888f29f4c557e66e18db2234ec4..dcf25b77e5cb162410c4b253357c64a4b6b03d87 100644
--- a/Cython/Includes/python_getargs.pxd
+++ b/Cython/Includes/python_getargs.pxd
@@ -1,13 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-    #####################################################################
-    # 5.5 Parsing arguments and building values
-    #####################################################################
-    ctypedef struct va_list
-    int PyArg_ParseTuple(object args, char *format, ...) except 0
-    int PyArg_VaParse(object args, char *format, va_list vargs) except 0
-    int PyArg_ParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], ...) except 0
-    int PyArg_VaParseTupleAndKeywords(object args, object kw, char *format, char *keywords[], va_list vargs) except 0
-    int PyArg_Parse(object args, char *format, ...) except 0
-    int PyArg_UnpackTuple(object args, char *name, Py_ssize_t min, Py_ssize_t max, ...) except 0
+# Present for backwards compatability
+from cpython.getargs cimport *
diff --git a/Cython/Includes/python_instance.pxd b/Cython/Includes/python_instance.pxd
index 4160cbe6a0a5fb948056536ef866777d1fa77504..7d574097e5b858867f94cbb65910d2b11bc87970 100644
--- a/Cython/Includes/python_instance.pxd
+++ b/Cython/Includes/python_instance.pxd
@@ -1,25 +1,2 @@
-cdef extern from "Python.h":
-    
-    ############################################################################
-    # 7.5.2 Instance Objects
-    ############################################################################
-
-    # PyTypeObject PyInstance_Type
-    #
-    # Type object for class instances.
-    
-    int PyInstance_Check(object obj)
-    # Return true if obj is an instance. 
-
-    object PyInstance_New(object cls, object arg, object kw)
-    # Return value: New reference.
-    # Create a new instance of a specific class. The parameters arg
-    # and kw are used as the positional and keyword parameters to the
-    # object's constructor.
-
-    object PyInstance_NewRaw(object cls, object dict)
-    # Return value: New reference.
-    # Create a new instance of a specific class without calling its
-    # constructor. class is the class of new object. The dict
-    # parameter will be used as the object's __dict__; if NULL, a new
-    # dictionary will be created for the instance.
+# Present for backwards compatability
+from cpython.instance cimport *
diff --git a/Cython/Includes/python_int.pxd b/Cython/Includes/python_int.pxd
index bc87c6032de93087d6512b7c03908f3709117e36..11bc26bfbf9f5fae2c35116944958965e0dbf296 100644
--- a/Cython/Includes/python_int.pxd
+++ b/Cython/Includes/python_int.pxd
@@ -1,79 +1,2 @@
-cdef extern from "Python.h":
-    ctypedef unsigned long long PY_LONG_LONG
-
-    ############################################################################
-    # Integer Objects
-    ############################################################################
-    # PyTypeObject PyInt_Type
-    # This instance of PyTypeObject represents the Python plain
-    # integer type. This is the same object as int and types.IntType.
-
-    bint PyInt_Check(object  o)
-    # Return true if o is of type PyInt_Type or a subtype of
-    # PyInt_Type.
-
-    bint PyInt_CheckExact(object  o)
-    # Return true if o is of type PyInt_Type, but not a subtype of
-    # PyInt_Type.
-
-    object PyInt_FromString(char *str, char **pend, int base)
-    # Return value: New reference.
-    # Return a new PyIntObject or PyLongObject based on the string
-    # value in str, which is interpreted according to the radix in
-    # base. If pend is non-NULL, *pend will point to the first
-    # character in str which follows the representation of the
-    # number. If base is 0, the radix will be determined based on the
-    # leading characters of str: if str starts with '0x' or '0X',
-    # radix 16 will be used; if str starts with '0', radix 8 will be
-    # used; otherwise radix 10 will be used. If base is not 0, it must
-    # be between 2 and 36, inclusive. Leading spaces are ignored. If
-    # there are no digits, ValueError will be raised. If the string
-    # represents a number too large to be contained within the
-    # machine's long int type and overflow warnings are being
-    # suppressed, a PyLongObject will be returned. If overflow
-    # warnings are not being suppressed, NULL will be returned in this
-    # case.
-
-    object PyInt_FromLong(long ival)
-    # Return value: New reference.
-    # Create a new integer object with a value of ival.
-    # The current implementation keeps an array of integer objects for
-    # all integers between -5 and 256, when you create an int in that
-    # range you actually just get back a reference to the existing
-    # object. So it should be possible to change the value of 1. I
-    # suspect the behaviour of Python in this case is undefined. :-)
-
-    object PyInt_FromSsize_t(Py_ssize_t ival)
-    # Return value: New reference.
-    # Create a new integer object with a value of ival. If the value
-    # exceeds LONG_MAX, a long integer object is returned.
-
-    long PyInt_AsLong(object io) except? -1
-    # Will first attempt to cast the object to a PyIntObject, if it is
-    # not already one, and then return its value. If there is an
-    # error, -1 is returned, and the caller should check
-    # PyErr_Occurred() to find out whether there was an error, or
-    # whether the value just happened to be -1.
-
-    long PyInt_AS_LONG(object io)
-    # Return the value of the object io. No error checking is performed. 
-
-    unsigned long PyInt_AsUnsignedLongMask(object io) except? -1
-    # Will first attempt to cast the object to a PyIntObject or
-    # PyLongObject, if it is not already one, and then return its
-    # value as unsigned long. This function does not check for
-    # overflow. 
-
-    PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1
-    # Will first attempt to cast the object to a PyIntObject or
-    # PyLongObject, if it is not already one, and then return its
-    # value as unsigned long long, without checking for overflow. 
-
-    Py_ssize_t PyInt_AsSsize_t(object io) except? -1
-    # Will first attempt to cast the object to a PyIntObject or
-    # PyLongObject, if it is not already one, and then return its
-    # value as Py_ssize_t.
-
-    long PyInt_GetMax()
-    # Return the system's idea of the largest integer it can handle
-    # (LONG_MAX, as defined in the system header files).
+# Present for backwards compatability
+from cpython.int cimport *
diff --git a/Cython/Includes/python_iterator.pxd b/Cython/Includes/python_iterator.pxd
index 94ae1f623d3d270710dd109bea64edb3f8547cdc..e7691f48ecc33ae5a33e5170ad193da1a478eac4 100644
--- a/Cython/Includes/python_iterator.pxd
+++ b/Cython/Includes/python_iterator.pxd
@@ -1,36 +1,2 @@
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 6.5 Iterator Protocol
-    ############################################################################
-    bint PyIter_Check(object o)
-    # Return true if the object o supports the iterator protocol. 
-
-    object PyIter_Next(object o)
-    # Return value: New reference.
-    # Return the next value from the iteration o. If the object is an
-    # iterator, this retrieves the next value from the iteration, and
-    # returns NULL with no exception set if there are no remaining
-    # items. If the object is not an iterator, TypeError is raised, or
-    # if there is an error in retrieving the item, returns NULL and
-    # passes along the exception.
-
-    # To write a loop which iterates over an iterator, the C code should look something like this:
-    # PyObject *iterator = PyObject_GetIter(obj);
-    # PyObject *item;
-    # if (iterator == NULL) {
-    # /* propagate error */
-    # }
-    # while (item = PyIter_Next(iterator)) {
-    # /* do something with item */
-    # ...
-    # /* release reference when done */
-    # Py_DECREF(item);
-    # }
-    # Py_DECREF(iterator);
-    # if (PyErr_Occurred()) {
-    # /* propagate error */
-    # }
-    # else {
-    # /* continue doing useful work */
-    # }
+# Present for backwards compatability
+from cpython.iterator cimport *
diff --git a/Cython/Includes/python_list.pxd b/Cython/Includes/python_list.pxd
index 86837819b6e4c903309cddfd7dc86823ed3879e6..53f594e0d24043e505c658bd74862b47baca6932 100644
--- a/Cython/Includes/python_list.pxd
+++ b/Cython/Includes/python_list.pxd
@@ -1,92 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # Lists
-    ############################################################################
-    object PyList_New(Py_ssize_t len)
-    # Return a new list of length len on success, or NULL on failure.
-    #
-    # Note: If length is greater than zero, the returned list object's
-    # items are set to NULL. Thus you cannot use abstract API
-    # functions such as PySequence_SetItem() or expose the object to
-    # Python code before setting all items to a real object with
-    # PyList_SetItem().
-    
-    bint PyList_Check(object p)
-    # Return true if p is a list object or an instance of a subtype of
-    # the list type.
-    
-    bint PyList_CheckExact(object p)
-    # Return true if p is a list object, but not an instance of a
-    # subtype of the list type.
-
-    Py_ssize_t PyList_Size(object list) except -1
-    # Return the length of the list object in list; this is equivalent
-    # to "len(list)" on a list object.
-
-    Py_ssize_t PyList_GET_SIZE(object list)
-    # Macro form of PyList_Size() without error checking. 
-
-    PyObject* PyList_GetItem(object list, Py_ssize_t index) except NULL
-    # Return value: Borrowed reference.  
-    # Return the object at position pos in the list pointed to by
-    # p. The position must be positive, indexing from the end of the
-    # list is not supported. If pos is out of bounds, return NULL and
-    # set an IndexError exception.
-
-    PyObject* PyList_GET_ITEM(object list, Py_ssize_t i)
-    # Return value: Borrowed reference.
-    # Macro form of PyList_GetItem() without error checking. 
-
-    int PyList_SetItem(object list, Py_ssize_t index, object item) except -1
-    # Set the item at index index in list to item. Return 0 on success
-    # or -1 on failure. Note: This function ``steals'' a reference to
-    # item and discards a reference to an item already in the list at
-    # the affected position.
-
-    void PyList_SET_ITEM(object list, Py_ssize_t i, object o)
-    # Macro form of PyList_SetItem() without error checking. This is
-    # normally only used to fill in new lists where there is no
-    # previous content. Note: This function ``steals'' a reference to
-    # item, and, unlike PyList_SetItem(), does not discard a reference
-    # to any item that it being replaced; any reference in list at
-    # position i will be *leaked*.
-
-    int PyList_Insert(object list, Py_ssize_t index, object item) except -1
-    # Insert the item item into list list in front of index
-    # index. Return 0 if successful; return -1 and set an exception if
-    # unsuccessful. Analogous to list.insert(index, item).
-
-    int PyList_Append(object list, object item) except -1
-    # Append the object item at the end of list list. Return 0 if
-    # successful; return -1 and set an exception if
-    # unsuccessful. Analogous to list.append(item).
-
-    object PyList_GetSlice(object list, Py_ssize_t low, Py_ssize_t high)
-    # Return value: New reference.
-    # Return a list of the objects in list containing the objects
-    # between low and high. Return NULL and set an exception if
-    # unsuccessful. Analogous to list[low:high].
-
-    int PyList_SetSlice(object list, Py_ssize_t low, Py_ssize_t high, object itemlist) except -1
-    # Set the slice of list between low and high to the contents of
-    # itemlist. Analogous to list[low:high] = itemlist. The itemlist
-    # may be NULL, indicating the assignment of an empty list (slice
-    # deletion). Return 0 on success, -1 on failure.
-
-    int PyList_Sort(object list) except -1
-    # Sort the items of list in place. Return 0 on success, -1 on
-    # failure. This is equivalent to "list.sort()".
-
-    int PyList_Reverse(object list) except -1
-    # Reverse the items of list in place. Return 0 on success, -1 on
-    # failure. This is the equivalent of "list.reverse()".
-
-    object PyList_AsTuple(object list)
-    # Return value: New reference.
-    # Return a new tuple object containing the contents of list;
-    # equivalent to "tuple(list)".
-
-
+# Present for backwards compatability
+from cpython.list cimport *
diff --git a/Cython/Includes/python_long.pxd b/Cython/Includes/python_long.pxd
index d6159a60e950a8f491c3381690252211fbd0cb1d..4bdf629e947b9205b79af992d215f5df3429c5c7 100644
--- a/Cython/Includes/python_long.pxd
+++ b/Cython/Includes/python_long.pxd
@@ -1,115 +1,2 @@
-from python_unicode cimport Py_UNICODE
-
-cdef extern from "Python.h":
-    ctypedef long long PY_LONG_LONG
-    ctypedef unsigned long long uPY_LONG_LONG
-
-    ############################################################################
-    # 7.2.3 Long Integer Objects
-    ############################################################################
-
-    # PyLongObject
-    #
-    # This subtype of PyObject represents a Python long integer object.
-
-    # PyTypeObject PyLong_Type
-    #
-    # This instance of PyTypeObject represents the Python long integer
-    # type. This is the same object as long and types.LongType.
-
-    bint PyLong_Check(object p)
-    # Return true if its argument is a PyLongObject or a subtype of PyLongObject. 
-
-    bint PyLong_CheckExact(object p)
-    # Return true if its argument is a PyLongObject, but not a subtype of PyLongObject.
-
-    object PyLong_FromLong(long v)
-    # Return value: New reference.
-    # Return a new PyLongObject object from v, or NULL on failure. 
-
-    object PyLong_FromUnsignedLong(unsigned long v)
-    # Return value: New reference.
-    # Return a new PyLongObject object from a C unsigned long, or NULL on failure. 
-
-    object PyLong_FromLongLong(PY_LONG_LONG v)
-    # Return value: New reference.
-    # Return a new PyLongObject object from a C long long, or NULL on failure. 
-
-    object PyLong_FromUnsignedLongLong(uPY_LONG_LONG v)
-    # Return value: New reference.
-    # Return a new PyLongObject object from a C unsigned long long, or NULL on failure. 
-
-    object PyLong_FromDouble(double v)
-    # Return value: New reference.
-    # Return a new PyLongObject object from the integer part of v, or NULL on failure. 
-
-    object PyLong_FromString(char *str, char **pend, int base)
-    # Return value: New reference.
-    # Return a new PyLongObject based on the string value in str,
-    # which is interpreted according to the radix in base. If pend is
-    # non-NULL, *pend will point to the first character in str which
-    # follows the representation of the number. If base is 0, the
-    # radix will be determined based on the leading characters of str:
-    # if str starts with '0x' or '0X', radix 16 will be used; if str
-    # starts with '0', radix 8 will be used; otherwise radix 10 will
-    # be used. If base is not 0, it must be between 2 and 36,
-    # inclusive. Leading spaces are ignored. If there are no digits,
-    # ValueError will be raised.
-
-    object PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
-    # Return value: New reference.
-    # Convert a sequence of Unicode digits to a Python long integer
-    # value. The first parameter, u, points to the first character of
-    # the Unicode string, length gives the number of characters, and
-    # base is the radix for the conversion. The radix must be in the
-    # range [2, 36]; if it is out of range, ValueError will be
-    # raised. 
-
-    object PyLong_FromVoidPtr(void *p)
-    # Return value: New reference.
-    # Create a Python integer or long integer from the pointer p. The
-    # pointer value can be retrieved from the resulting value using
-    # PyLong_AsVoidPtr().  If the integer is larger than LONG_MAX, a
-    # positive long integer is returned.
-
-    long PyLong_AsLong(object pylong) except? -1
-    # Return a C long representation of the contents of pylong. If
-    # pylong is greater than LONG_MAX, an OverflowError is raised.
-
-    unsigned long PyLong_AsUnsignedLong(object pylong) except? -1
-    # Return a C unsigned long representation of the contents of
-    # pylong. If pylong is greater than ULONG_MAX, an OverflowError is
-    # raised.
-
-    PY_LONG_LONG PyLong_AsLongLong(object pylong) except? -1
-    # Return a C long long from a Python long integer. If pylong
-    # cannot be represented as a long long, an OverflowError will be
-    # raised.
-
-    uPY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong) except? -1
-    #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(object pylong)
-    # Return a C unsigned long long from a Python long integer. If
-    # pylong cannot be represented as an unsigned long long, an
-    # OverflowError will be raised if the value is positive, or a
-    # TypeError will be raised if the value is negative. 
-
-    unsigned long PyLong_AsUnsignedLongMask(object io) except? -1
-    # Return a C unsigned long from a Python long integer, without
-    # checking for overflow. 
-
-    uPY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io) except? -1
-    #unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(object io)
-    # Return a C unsigned long long from a Python long integer,
-    # without checking for overflow.
-
-    double PyLong_AsDouble(object pylong) except? -1.0
-    # Return a C double representation of the contents of pylong. If
-    # pylong cannot be approximately represented as a double, an
-    # OverflowError exception is raised and -1.0 will be returned.
-
-    void* PyLong_AsVoidPtr(object pylong) except? NULL
-    # Convert a Python integer or long integer pylong to a C void
-    # pointer. If pylong cannot be converted, an OverflowError will be
-    # raised. This is only assured to produce a usable void pointer
-    # for values created with PyLong_FromVoidPtr(). For values outside
-    # 0..LONG_MAX, both signed and unsigned integers are acccepted.
+# Present for backwards compatability
+from cpython.long cimport *
diff --git a/Cython/Includes/python_mapping.pxd b/Cython/Includes/python_mapping.pxd
index 3d235b65e20c0a774004bb0fd0938b158d515bb1..6127601f49f5a5d38ae151cb0d4c26330eb2c959 100644
--- a/Cython/Includes/python_mapping.pxd
+++ b/Cython/Includes/python_mapping.pxd
@@ -1,64 +1,2 @@
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 6.4 Mapping Protocol
-    ############################################################################
-
-    bint PyMapping_Check(object o)
-    # Return 1 if the object provides mapping protocol, and 0
-    # otherwise. This function always succeeds.
-
-    Py_ssize_t PyMapping_Length(object o) except -1
-    # Returns the number of keys in object o on success, and -1 on
-    # failure. For objects that do not provide mapping protocol, this
-    # is equivalent to the Python expression "len(o)".
-
-    int PyMapping_DelItemString(object o, char *key) except -1
-    # Remove the mapping for object key from the object o. Return -1
-    # on failure. This is equivalent to the Python statement "del
-    # o[key]".
-
-    int PyMapping_DelItem(object o, object key) except -1
-    # Remove the mapping for object key from the object o. Return -1
-    # on failure. This is equivalent to the Python statement "del
-    # o[key]".
-
-    bint PyMapping_HasKeyString(object o, char *key)
-    # On success, return 1 if the mapping object has the key key and 0
-    # otherwise. This is equivalent to the Python expression
-    # "o.has_key(key)". This function always succeeds.
-
-    bint PyMapping_HasKey(object o, object key)
-    # Return 1 if the mapping object has the key key and 0
-    # otherwise. This is equivalent to the Python expression
-    # "o.has_key(key)". This function always succeeds.
-
-    object PyMapping_Keys(object o)
-    # Return value: New reference.
-    # On success, return a list of the keys in object o. On failure,
-    # return NULL. This is equivalent to the Python expression
-    # "o.keys()".
-
-    object PyMapping_Values(object o)
-    # Return value: New reference.
-    # On success, return a list of the values in object o. On failure,
-    # return NULL. This is equivalent to the Python expression
-    # "o.values()".
-
-    object PyMapping_Items(object o)
-    # Return value: New reference.
-    # On success, return a list of the items in object o, where each
-    # item is a tuple containing a key-value pair. On failure, return
-    # NULL. This is equivalent to the Python expression "o.items()".
-
-    object PyMapping_GetItemString(object o, char *key)
-    # Return value: New reference.
-    # Return element of o corresponding to the object key or NULL on
-    # failure. This is the equivalent of the Python expression
-    # "o[key]".
-
-    int PyMapping_SetItemString(object o, char *key, object v) except -1
-    # Map the object key to the value v in object o. Returns -1 on
-    # failure. This is the equivalent of the Python statement "o[key]
-    # = v".
-
+# Present for backwards compatability
+from cpython.mapping cimport *
diff --git a/Cython/Includes/python_mem.pxd b/Cython/Includes/python_mem.pxd
index 6d7b8dac180d8e0691c210a90dc190f0351916d2..9729cd8ce62af1794fcbedf4e82d135f0d7d963f 100644
--- a/Cython/Includes/python_mem.pxd
+++ b/Cython/Includes/python_mem.pxd
@@ -1,75 +1,2 @@
-cdef extern from "Python.h":
-
-    #####################################################################
-    # 9.2 Memory Interface
-    #####################################################################
-    # You are definitely *supposed* to use these: "In most situations,
-    # however, it is recommended to allocate memory from the Python
-    # heap specifically because the latter is under control of the
-    # Python memory manager. For example, this is required when the
-    # interpreter is extended with new object types written in
-    # C. Another reason for using the Python heap is the desire to
-    # inform the Python memory manager about the memory needs of the
-    # extension module. Even when the requested memory is used
-    # exclusively for internal, highly-specific purposes, delegating
-    # all memory requests to the Python memory manager causes the
-    # interpreter to have a more accurate image of its memory
-    # footprint as a whole. Consequently, under certain circumstances,
-    # the Python memory manager may or may not trigger appropriate
-    # actions, like garbage collection, memory compaction or other
-    # preventive procedures. Note that by using the C library
-    # allocator as shown in the previous example, the allocated memory
-    # for the I/O buffer escapes completely the Python memory
-    # manager."
-
-    # The following function sets, modeled after the ANSI C standard,
-    # but specifying behavior when requesting zero bytes, are
-    # available for allocating and releasing memory from the Python
-    # heap:
-
-    void* PyMem_Malloc(size_t n)
-    # Allocates n bytes and returns a pointer of type void* to the
-    # allocated memory, or NULL if the request fails. Requesting zero
-    # bytes returns a distinct non-NULL pointer if possible, as if
-    # PyMem_Malloc(1) had been called instead. The memory will not
-    # have been initialized in any way.
-
-    void* PyMem_Realloc(void *p, size_t n)
-    # Resizes the memory block pointed to by p to n bytes. The
-    # contents will be unchanged to the minimum of the old and the new
-    # sizes. If p is NULL, the call is equivalent to PyMem_Malloc(n);
-    # else if n is equal to zero, the memory block is resized but is
-    # not freed, and the returned pointer is non-NULL. Unless p is
-    # NULL, it must have been returned by a previous call to
-    # PyMem_Malloc() or PyMem_Realloc().
-
-    void PyMem_Free(void *p)
-    # Frees the memory block pointed to by p, which must have been
-    # returned by a previous call to PyMem_Malloc() or
-    # PyMem_Realloc(). Otherwise, or if PyMem_Free(p) has been called
-    # before, undefined behavior occurs. If p is NULL, no operation is
-    # performed.
-
-    # The following type-oriented macros are provided for
-    # convenience. Note that TYPE refers to any C type.
-
-    # TYPE* PyMem_New(TYPE, size_t n)
-    # Same as PyMem_Malloc(), but allocates (n * sizeof(TYPE)) bytes
-    # of memory. Returns a pointer cast to TYPE*. The memory will not
-    # have been initialized in any way.
-
-    # TYPE* PyMem_Resize(void *p, TYPE, size_t n)
-    # Same as PyMem_Realloc(), but the memory block is resized to (n *
-    # sizeof(TYPE)) bytes. Returns a pointer cast to TYPE*.
-
-    void PyMem_Del(void *p)
-    # Same as PyMem_Free(). 
-
-    # In addition, the following macro sets are provided for calling
-    # the Python memory allocator directly, without involving the C
-    # API functions listed above. However, note that their use does
-    # not preserve binary compatibility across Python versions and is
-    # therefore deprecated in extension modules.
-
-    # PyMem_MALLOC(), PyMem_REALLOC(), PyMem_FREE().
-    # PyMem_NEW(), PyMem_RESIZE(), PyMem_DEL().
+# Present for backwards compatability
+from cpython.mem cimport *
diff --git a/Cython/Includes/python_method.pxd b/Cython/Includes/python_method.pxd
index 36e7ef450f228033323118fd3717a21c77938db4..36c67e12486cc6accce1696099d1d54f456b9760 100644
--- a/Cython/Includes/python_method.pxd
+++ b/Cython/Includes/python_method.pxd
@@ -1,48 +1,2 @@
-cdef extern from "Python.h":
-    ctypedef void PyObject
-    ############################################################################
-    # 7.5.4 Method Objects
-    ############################################################################
-
-    # There are some useful functions that are useful for working with method objects.
-    # PyTypeObject PyMethod_Type
-    # This instance of PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType. 
-
-    bint PyMethod_Check(object o)
-    # Return true if o is a method object (has type
-    # PyMethod_Type). The parameter must not be NULL.
-
-    object PyMethod_New(object func, object self, object cls)
-    # Return value: New reference.
-    # Return a new method object, with func being any callable object;
-    # this is the function that will be called when the method is
-    # called. If this method should be bound to an instance, self
-    # should be the instance and class should be the class of self,
-    # otherwise self should be NULL and class should be the class
-    # which provides the unbound method..
-
-    PyObject* PyMethod_Class(object meth) except NULL
-    # Return value: Borrowed reference.
-    # Return the class object from which the method meth was created;
-    # if this was created from an instance, it will be the class of
-    # the instance.
-
-    PyObject* PyMethod_GET_CLASS(object meth)
-    # Return value: Borrowed reference.
-    # Macro version of PyMethod_Class() which avoids error checking. 
-
-    PyObject* PyMethod_Function(object meth) except NULL
-    # Return value: Borrowed reference.
-    # Return the function object associated with the method meth. 
-
-    PyObject* PyMethod_GET_FUNCTION(object meth)
-    # Return value: Borrowed reference.
-    # Macro version of PyMethod_Function() which avoids error checking. 
-
-    PyObject* PyMethod_Self(object meth) except? NULL
-    # Return value: Borrowed reference.
-    # Return the instance associated with the method meth if it is bound, otherwise return NULL. 
-
-    PyObject* PyMethod_GET_SELF(object meth)
-    # Return value: Borrowed reference.
-    # Macro version of PyMethod_Self() which avoids error checking. 
+# Present for backwards compatability
+from cpython.method cimport *
diff --git a/Cython/Includes/python_module.pxd b/Cython/Includes/python_module.pxd
index 419a982df96465871d67a3d0c1dcf31ea85daed9..5a462592565720d44674eaf020297a68be319776 100644
--- a/Cython/Includes/python_module.pxd
+++ b/Cython/Includes/python_module.pxd
@@ -1,175 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-    ctypedef struct _inittab
-
-    #####################################################################
-    # 5.3 Importing Modules
-    #####################################################################
-    object PyImport_ImportModule(char *name)
-    # Return value: New reference.
-    # This is a simplified interface to PyImport_ImportModuleEx()
-    # below, leaving the globals and locals arguments set to
-    # NULL. When the name argument contains a dot (when it specifies a
-    # submodule of a package), the fromlist argument is set to the
-    # list ['*'] so that the return value is the named module rather
-    # than the top-level package containing it as would otherwise be
-    # the case. (Unfortunately, this has an additional side effect
-    # when name in fact specifies a subpackage instead of a submodule:
-    # the submodules specified in the package's __all__ variable are
-    # loaded.) Return a new reference to the imported module, or NULL
-    # with an exception set on failure.
-
-    object PyImport_ImportModuleEx(char *name, object globals, object locals, object fromlist)
-    # Return value: New reference.
-
-    # Import a module. This is best described by referring to the
-    # built-in Python function __import__(), as the standard
-    # __import__() function calls this function directly.
-
-    # The return value is a new reference to the imported module or
-    # top-level package, or NULL with an exception set on failure
-    # (before Python 2.4, the module may still be created in this
-    # case). Like for __import__(), the return value when a submodule
-    # of a package was requested is normally the top-level package,
-    # unless a non-empty fromlist was given. Changed in version 2.4:
-    # failing imports remove incomplete module objects.
-
-    object PyImport_Import(object name)
-    # Return value: New reference.
-    # This is a higher-level interface that calls the current ``import
-    # hook function''. It invokes the __import__() function from the
-    # __builtins__ of the current globals. This means that the import
-    # is done using whatever import hooks are installed in the current
-    # environment, e.g. by rexec or ihooks.
-
-    object PyImport_ReloadModule(object m)
-    # Return value: New reference.
-    # Reload a module. This is best described by referring to the
-    # built-in Python function reload(), as the standard reload()
-    # function calls this function directly. Return a new reference to
-    # the reloaded module, or NULL with an exception set on failure
-    # (the module still exists in this case).
-
-    PyObject* PyImport_AddModule(char *name) except NULL
-    # Return value: Borrowed reference.
-    # Return the module object corresponding to a module name. The
-    # name argument may be of the form package.module. First check the
-    # modules dictionary if there's one there, and if not, create a
-    # new one and insert it in the modules dictionary. Return NULL
-    # with an exception set on failure. Note: This function does not
-    # load or import the module; if the module wasn't already loaded,
-    # you will get an empty module object. Use PyImport_ImportModule()
-    # or one of its variants to import a module. Package structures
-    # implied by a dotted name for name are not created if not already
-    # present.
-
-    object PyImport_ExecCodeModule(char *name, object co)
-    # Return value: New reference.
-    # Given a module name (possibly of the form package.module) and a
-    # code object read from a Python bytecode file or obtained from
-    # the built-in function compile(), load the module. Return a new
-    # reference to the module object, or NULL with an exception set if
-    # an error occurred. Name is removed from sys.modules in error
-    # cases, and even if name was already in sys.modules on entry to
-    # PyImport_ExecCodeModule(). Leaving incompletely initialized
-    # modules in sys.modules is dangerous, as imports of such modules
-    # have no way to know that the module object is an unknown (and
-    # probably damaged with respect to the module author's intents)
-    # state.
-    # This function will reload the module if it was already
-    # imported. See PyImport_ReloadModule() for the intended way to
-    # reload a module.
-    # If name points to a dotted name of the form package.module, any
-    # package structures not already created will still not be
-    # created.
-
-
-    long PyImport_GetMagicNumber()
-    # Return the magic number for Python bytecode files (a.k.a. .pyc
-    # and .pyo files). The magic number should be present in the first
-    # four bytes of the bytecode file, in little-endian byte order.
-
-    PyObject* PyImport_GetModuleDict() except NULL
-    # Return value: Borrowed reference.
-    # Return the dictionary used for the module administration
-    # (a.k.a. sys.modules). Note that this is a per-interpreter
-    # variable.
-
-
-    int PyImport_ImportFrozenModule(char *name) except -1
-    # Load a frozen module named name. Return 1 for success, 0 if the
-    # module is not found, and -1 with an exception set if the
-    # initialization failed. To access the imported module on a
-    # successful load, use PyImport_ImportModule(). (Note the misnomer
-    # -- this function would reload the module if it was already
-    # imported.)
-
-
-    int PyImport_ExtendInittab(_inittab *newtab) except -1
-    # Add a collection of modules to the table of built-in
-    # modules. The newtab array must end with a sentinel entry which
-    # contains NULL for the name field; failure to provide the
-    # sentinel value can result in a memory fault. Returns 0 on
-    # success or -1 if insufficient memory could be allocated to
-    # extend the internal table. In the event of failure, no modules
-    # are added to the internal table. This should be called before
-    # Py_Initialize().
-
-    #####################################################################
-    # 7.5.5 Module Objects
-    #####################################################################
-
-    # PyTypeObject PyModule_Type
-    #
-    # This instance of PyTypeObject represents the Python module
-    # type. This is exposed to Python programs as types.ModuleType.
-
-    bint PyModule_Check(object p)
-    # Return true if p is a module object, or a subtype of a module
-    # object.
-
-    bint PyModule_CheckExact(object p)
-    # Return true if p is a module object, but not a subtype of PyModule_Type. 
-
-    object PyModule_New(char *name)
-    # Return value: New reference.
-    # Return a new module object with the __name__ attribute set to
-    # name. Only the module's __doc__ and __name__ attributes are
-    # filled in; the caller is responsible for providing a __file__
-    # attribute.
-
-    PyObject* PyModule_GetDict(object module) except NULL
-    # Return value: Borrowed reference.
-    # Return the dictionary object that implements module's namespace;
-    # this object is the same as the __dict__ attribute of the module
-    # object. This function never fails. It is recommended extensions
-    # use other PyModule_*() and PyObject_*() functions rather than
-    # directly manipulate a module's __dict__.
-
-    char* PyModule_GetName(object module) except NULL
-    # Return module's __name__ value. If the module does not provide
-    # one, or if it is not a string, SystemError is raised and NULL is
-    # returned.
-
-    char* PyModule_GetFilename(object module) except NULL
-    # Return the name of the file from which module was loaded using
-    # module's __file__ attribute. If this is not defined, or if it is
-    # not a string, raise SystemError and return NULL.
-
-    int PyModule_AddObject(object module,  char *name, object value) except -1
-    # Add an object to module as name. This is a convenience function
-    # which can be used from the module's initialization
-    # function. This steals a reference to value. Return -1 on error,
-    # 0 on success. 
-
-    int PyModule_AddIntant(object module,  char *name, long value) except -1
-    # Add an integer ant to module as name. This convenience
-    # function can be used from the module's initialization
-    # function. Return -1 on error, 0 on success. 
-
-    int PyModule_AddStringant(object module,  char *name,  char *value) except -1
-    # Add a string constant to module as name. This convenience
-    # function can be used from the module's initialization
-    # function. The string value must be null-terminated. Return -1 on
-    # error, 0 on success. 
+# Present for backwards compatability
+from cpython.module cimport *
diff --git a/Cython/Includes/python_number.pxd b/Cython/Includes/python_number.pxd
index 44677fc66bccaca3396171627de0d7a01cb29343..7b544ff2bab36ce978f2915c40d40f05e3eded58 100644
--- a/Cython/Includes/python_number.pxd
+++ b/Cython/Includes/python_number.pxd
@@ -1,251 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    #####################################################################
-    # 6.2 Number Protocol
-    #####################################################################
-
-    bint PyNumber_Check(object o)
-    # Returns 1 if the object o provides numeric protocols, and false
-    # otherwise. This function always succeeds.
-
-    object PyNumber_Add(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of adding o1 and o2, or NULL on failure. This
-    # is the equivalent of the Python expression "o1 + o2".
-
-    object PyNumber_Subtract(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of subtracting o2 from o1, or NULL on
-    # failure. This is the equivalent of the Python expression "o1 -
-    # o2".
-
-    object PyNumber_Multiply(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of multiplying o1 and o2, or NULL on
-    # failure. This is the equivalent of the Python expression "o1 *
-    # o2".
-
-    object PyNumber_Divide(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of dividing o1 by o2, or NULL on
-    # failure. This is the equivalent of the Python expression "o1 /
-    # o2".
-
-    object PyNumber_FloorDivide(object o1, object o2)
-    # Return value: New reference.
-    # Return the floor of o1 divided by o2, or NULL on failure. This
-    # is equivalent to the ``classic'' division of integers. 
-
-    object PyNumber_TrueDivide(object o1, object o2)
-    # Return value: New reference.
-    # Return a reasonable approximation for the mathematical value of
-    # o1 divided by o2, or NULL on failure. The return value is
-    # ``approximate'' because binary floating point numbers are
-    # approximate; it is not possible to represent all real numbers in
-    # base two. This function can return a floating point value when
-    # passed two integers. 
-
-    object PyNumber_Remainder(object o1, object o2)
-    # Return value: New reference.
-    # Returns the remainder of dividing o1 by o2, or NULL on
-    # failure. This is the equivalent of the Python expression "o1 %
-    # o2".
-
-    object PyNumber_Divmod(object o1, object o2)
-    # Return value: New reference.
-    # See the built-in function divmod(). Returns NULL on
-    # failure. This is the equivalent of the Python expression
-    # "divmod(o1, o2)".
-
-    object PyNumber_Power(object o1, object o2, object o3)
-    # Return value: New reference.
-    # See the built-in function pow(). Returns NULL on failure. This
-    # is the equivalent of the Python expression "pow(o1, o2, o3)",
-    # where o3 is optional. If o3 is to be ignored, pass Py_None in
-    # its place (passing NULL for o3 would cause an illegal memory
-    # access).
-
-    object PyNumber_Negative(object o)
-    # Return value: New reference.
-    # Returns the negation of o on success, or NULL on failure. This
-    # is the equivalent of the Python expression "-o".
-
-    object PyNumber_Positive(object o)
-    # Return value: New reference.
-    # Returns o on success, or NULL on failure. This is the equivalent
-    # of the Python expression "+o".
-
-    object PyNumber_Absolute(object o)
-    # Return value: New reference.
-    # Returns the absolute value of o, or NULL on failure. This is the
-    # equivalent of the Python expression "abs(o)".
-
-    object PyNumber_Invert(object o)
-    # Return value: New reference.
-    # Returns the bitwise negation of o on success, or NULL on
-    # failure. This is the equivalent of the Python expression "~o".
-
-    object PyNumber_Lshift(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of left shifting o1 by o2 on success, or NULL
-    # on failure. This is the equivalent of the Python expression "o1
-    # << o2".
-
-    object PyNumber_Rshift(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of right shifting o1 by o2 on success, or
-    # NULL on failure. This is the equivalent of the Python expression
-    # "o1 >> o2".
-
-    object PyNumber_And(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
-    # failure. This is the equivalent of the Python expression "o1 &
-    # o2".
-
-    object PyNumber_Xor(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
-    # NULL on failure. This is the equivalent of the Python expression
-    # "o1 ^ o2".
-
-    object PyNumber_Or(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on failure. This is the equivalent of the Python expression "o1 | o2". 
-
-    object PyNumber_InPlaceAdd(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of adding o1 and o2, or NULL on failure. The
-    # operation is done in-place when o1 supports it. This is the
-    # equivalent of the Python statement "o1 += o2".
-
-    object PyNumber_InPlaceSubtract(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of subtracting o2 from o1, or NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 -= o2".
-
-    object PyNumber_InPlaceMultiply(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of multiplying o1 and o2, or NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 *= o2".
-
-    object PyNumber_InPlaceDivide(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of dividing o1 by o2, or NULL on failure. The
-    # operation is done in-place when o1 supports it. This is the
-    # equivalent of the Python statement "o1 /= o2".
-
-    object PyNumber_InPlaceFloorDivide(object o1, object o2)
-    # Return value: New reference.
-    # Returns the mathematical floor of dividing o1 by o2, or NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 //=
-    # o2". 
-
-    object PyNumber_InPlaceTrueDivide(object o1, object o2)
-    # Return value: New reference.
-    # Return a reasonable approximation for the mathematical value of
-    # o1 divided by o2, or NULL on failure. The return value is
-    # ``approximate'' because binary floating point numbers are
-    # approximate; it is not possible to represent all real numbers in
-    # base two. This function can return a floating point value when
-    # passed two integers. The operation is done in-place when o1
-    # supports it. 
-
-    object PyNumber_InPlaceRemainder(object o1, object o2)
-    # Return value: New reference.
-    # Returns the remainder of dividing o1 by o2, or NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 %= o2".
-
-    object PyNumber_InPlacePower(object o1, object o2, object o3)
-    # Return value: New reference.
-    # See the built-in function pow(). Returns NULL on failure. The
-    # operation is done in-place when o1 supports it. This is the
-    # equivalent of the Python statement "o1 **= o2" when o3 is
-    # Py_None, or an in-place variant of "pow(o1, o2, o3)"
-    # otherwise. If o3 is to be ignored, pass Py_None in its place
-    # (passing NULL for o3 would cause an illegal memory access).
-
-    object PyNumber_InPlaceLshift(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of left shifting o1 by o2 on success, or NULL
-    # on failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 <<= o2".
-
-    object PyNumber_InPlaceRshift(object o1, object o2)
-    # Return value: New reference.
-    # Returns the result of right shifting o1 by o2 on success, or
-    # NULL on failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 >>= o2".
-
-    object PyNumber_InPlaceAnd(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise and'' of o1 and o2 on success and NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 &= o2".
-
-    object PyNumber_InPlaceXor(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise exclusive or'' of o1 by o2 on success, or
-    # NULL on failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 ^= o2".
-
-    object PyNumber_InPlaceOr(object o1, object o2)
-    # Return value: New reference.
-    # Returns the ``bitwise or'' of o1 and o2 on success, or NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python statement "o1 |= o2".
-
-    int PyNumber_Coerce(PyObject **p1, PyObject **p2) except -1
-    # This function takes the addresses of two variables of type
-    # PyObject*. If the objects pointed to by *p1 and *p2 have the
-    # same type, increment their reference count and return 0
-    # (success). If the objects can be converted to a common numeric
-    # type, replace *p1 and *p2 by their converted value (with 'new'
-    # reference counts), and return 0. If no conversion is possible,
-    # or if some other error occurs, return -1 (failure) and don't
-    # increment the reference counts. The call PyNumber_Coerce(&o1,
-    # &o2) is equivalent to the Python statement "o1, o2 = coerce(o1,
-    # o2)".
-
-    object PyNumber_Int(object o)
-    # Return value: New reference.
-    # Returns the o converted to an integer object on success, or NULL
-    # on failure. If the argument is outside the integer range a long
-    # object will be returned instead. This is the equivalent of the
-    # Python expression "int(o)".
-
-    object PyNumber_Long(object o)
-    # Return value: New reference.
-    # Returns the o converted to a long integer object on success, or
-    # NULL on failure. This is the equivalent of the Python expression
-    # "long(o)".
-
-    object PyNumber_Float(object o)
-    # Return value: New reference.
-    # Returns the o converted to a float object on success, or NULL on
-    # failure. This is the equivalent of the Python expression
-    # "float(o)".
-
-    object PyNumber_Index(object o)
-    # Returns the o converted to a Python int or long on success or
-    # NULL with a TypeError exception raised on failure.
-
-    Py_ssize_t PyNumber_AsSsize_t(object o, object exc) except? -1
-    # Returns o converted to a Py_ssize_t value if o can be
-    # interpreted as an integer. If o can be converted to a Python int
-    # or long but the attempt to convert to a Py_ssize_t value would
-    # raise an OverflowError, then the exc argument is the type of
-    # exception that will be raised (usually IndexError or
-    # OverflowError). If exc is NULL, then the exception is cleared
-    # and the value is clipped to PY_SSIZE_T_MIN for a negative
-    # integer or PY_SSIZE_T_MAX for a positive integer. 
-
-    bint PyIndex_Check(object o)
-    # Returns True if o is an index integer (has the nb_index slot of
-    # the tp_as_number structure filled in).
+# Present for backwards compatability
+from cpython.number cimport *
diff --git a/Cython/Includes/python_object.pxd b/Cython/Includes/python_object.pxd
index c8be028399c71b5858999558337248a03e64a43b..dd8bff1d406f54461c28b0ba35d46846c103d939 100644
--- a/Cython/Includes/python_object.pxd
+++ b/Cython/Includes/python_object.pxd
@@ -1,284 +1,2 @@
-from python_ref cimport PyObject, PyTypeObject
-from stdio cimport FILE
-
-cdef extern from "Python.h":
-    
-    #####################################################################
-    # 6.1 Object Protocol
-    #####################################################################
-    int PyObject_Print(object o, FILE *fp, int flags) except -1
-    # Print an object o, on file fp. Returns -1 on error. The flags
-    # argument is used to enable certain printing options. The only
-    # option currently supported is Py_PRINT_RAW; if given, the str()
-    # of the object is written instead of the repr().
-
-    bint PyObject_HasAttrString(object o, char *attr_name)
-    # Returns 1 if o has the attribute attr_name, and 0
-    # otherwise. This is equivalent to the Python expression
-    # "hasattr(o, attr_name)". This function always succeeds.
-
-    object PyObject_GetAttrString(object o, char *attr_name)
-    # Return value: New reference.  Retrieve an attribute named
-    # attr_name from object o. Returns the attribute value on success,
-    # or NULL on failure. This is the equivalent of the Python
-    # expression "o.attr_name".
-
-    bint PyObject_HasAttr(object o, object attr_name)
-    # Returns 1 if o has the attribute attr_name, and 0
-    # otherwise. This is equivalent to the Python expression
-    # "hasattr(o, attr_name)". This function always succeeds.
-
-    object PyObject_GetAttr(object o, object attr_name)
-    # Return value: New reference.  Retrieve an attribute named
-    # attr_name from object o. Returns the attribute value on success,
-    # or NULL on failure. This is the equivalent of the Python
-    # expression "o.attr_name".
-
-    int PyObject_SetAttrString(object o, char *attr_name, object v) except -1
-    # Set the value of the attribute named attr_name, for object o, to
-    # the value v. Returns -1 on failure. This is the equivalent of
-    # the Python statement "o.attr_name = v".
-
-    int PyObject_SetAttr(object o, object attr_name, object v) except -1
-    # Set the value of the attribute named attr_name, for object o, to
-    # the value v. Returns -1 on failure. This is the equivalent of
-    # the Python statement "o.attr_name = v".
-
-    int PyObject_DelAttrString(object o, char *attr_name) except -1
-    # Delete attribute named attr_name, for object o. Returns -1 on
-    # failure. This is the equivalent of the Python statement: "del
-    # o.attr_name".
-
-    int PyObject_DelAttr(object o, object attr_name) except -1
-    # Delete attribute named attr_name, for object o. Returns -1 on
-    # failure. This is the equivalent of the Python statement "del
-    # o.attr_name".
-
-    object PyObject_RichCompare(object o1, object o2, int opid)
-    # Return value: New reference.
-    # Compare the values of o1 and o2 using the operation specified by
-    # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
-    # Py_GE, corresponding to <, <=, ==, !=, >, or >=
-    # respectively. This is the equivalent of the Python expression
-    # "o1 op o2", where op is the operator corresponding to
-    # opid. Returns the value of the comparison on success, or NULL on
-    # failure.
-
-    bint PyObject_RichCompareBool(object o1, object o2, int opid) except -1
-    # Compare the values of o1 and o2 using the operation specified by
-    # opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or
-    # Py_GE, corresponding to <, <=, ==, !=, >, or >=
-    # respectively. Returns -1 on error, 0 if the result is false, 1
-    # otherwise. This is the equivalent of the Python expression "o1
-    # op o2", where op is the operator corresponding to opid.
-
-    int PyObject_Cmp(object o1, object o2, int *result) except -1
-    # Compare the values of o1 and o2 using a routine provided by o1,
-    # if one exists, otherwise with a routine provided by o2. The
-    # result of the comparison is returned in result. Returns -1 on
-    # failure. This is the equivalent of the Python statement "result
-    # = cmp(o1, o2)".
-
-    int PyObject_Compare(object o1, object o2) except *
-    # Compare the values of o1 and o2 using a routine provided by o1,
-    # if one exists, otherwise with a routine provided by o2. Returns
-    # the result of the comparison on success. On error, the value
-    # returned is undefined; use PyErr_Occurred() to detect an
-    # error. This is equivalent to the Python expression "cmp(o1,
-    # o2)".
-
-    object PyObject_Repr(object o)
-    # Return value: New reference.
-    # Compute a string representation of object o. Returns the string
-    # representation on success, NULL on failure. This is the
-    # equivalent of the Python expression "repr(o)". Called by the
-    # repr() built-in function and by reverse quotes.
-
-    object PyObject_Str(object o)
-    # Return value: New reference.
-    # Compute a string representation of object o. Returns the string
-    # representation on success, NULL on failure. This is the
-    # equivalent of the Python expression "str(o)". Called by the
-    # str() built-in function and by the print statement.
-
-    object PyObject_Unicode(object o)
-    # Return value: New reference.
-    # Compute a Unicode string representation of object o. Returns the
-    # Unicode string representation on success, NULL on failure. This
-    # is the equivalent of the Python expression "unicode(o)". Called
-    # by the unicode() built-in function.
-
-    bint PyObject_IsInstance(object inst, object cls) except -1
-    # Returns 1 if inst is an instance of the class cls or a subclass
-    # of cls, or 0 if not. On error, returns -1 and sets an
-    # exception. If cls is a type object rather than a class object,
-    # PyObject_IsInstance() returns 1 if inst is of type cls. If cls
-    # is a tuple, the check will be done against every entry in
-    # cls. The result will be 1 when at least one of the checks
-    # returns 1, otherwise it will be 0. If inst is not a class
-    # instance and cls is neither a type object, nor a class object,
-    # nor a tuple, inst must have a __class__ attribute -- the class
-    # relationship of the value of that attribute with cls will be
-    # used to determine the result of this function. 
-
-    # Subclass determination is done in a fairly straightforward way,
-    # but includes a wrinkle that implementors of extensions to the
-    # class system may want to be aware of. If A and B are class
-    # objects, B is a subclass of A if it inherits from A either
-    # directly or indirectly. If either is not a class object, a more
-    # general mechanism is used to determine the class relationship of
-    # the two objects. When testing if B is a subclass of A, if A is
-    # B, PyObject_IsSubclass() returns true. If A and B are different
-    # objects, B's __bases__ attribute is searched in a depth-first
-    # fashion for A -- the presence of the __bases__ attribute is
-    # considered sufficient for this determination.
-
-    bint PyObject_IsSubclass(object derived, object cls) except -1
-    # Returns 1 if the class derived is identical to or derived from
-    # the class cls, otherwise returns 0. In case of an error, returns
-    # -1. If cls is a tuple, the check will be done against every
-    # entry in cls. The result will be 1 when at least one of the
-    # checks returns 1, otherwise it will be 0. If either derived or
-    # cls is not an actual class object (or tuple), this function uses
-    # the generic algorithm described above. New in version
-    # 2.1. Changed in version 2.3: Older versions of Python did not
-    # support a tuple as the second argument.
-
-    bint PyCallable_Check(object o)
-    # Determine if the object o is callable. Return 1 if the object is
-    # callable and 0 otherwise. This function always succeeds.
-
-    object PyObject_Call(object callable_object, object args, object kw)
-    # Return value: New reference.
-    # Call a callable Python object callable_object, with arguments
-    # given by the tuple args, and named arguments given by the
-    # dictionary kw. If no named arguments are needed, kw may be
-    # NULL. args must not be NULL, use an empty tuple if no arguments
-    # are needed. Returns the result of the call on success, or NULL
-    # on failure. This is the equivalent of the Python expression
-    # "apply(callable_object, args, kw)" or "callable_object(*args,
-    # **kw)".
-
-    object PyObject_CallObject(object callable_object, object args)
-    # Return value: New reference.
-    # Call a callable Python object callable_object, with arguments
-    # given by the tuple args. If no arguments are needed, then args
-    # may be NULL. Returns the result of the call on success, or NULL
-    # on failure. This is the equivalent of the Python expression
-    # "apply(callable_object, args)" or "callable_object(*args)".
-
-    object PyObject_CallFunction(object callable, char *format, ...)
-    # Return value: New reference.
-    # Call a callable Python object callable, with a variable number
-    # of C arguments. The C arguments are described using a
-    # Py_BuildValue() style format string. The format may be NULL,
-    # indicating that no arguments are provided. Returns the result of
-    # the call on success, or NULL on failure. This is the equivalent
-    # of the Python expression "apply(callable, args)" or
-    # "callable(*args)". Note that if you only pass object  args,
-    # PyObject_CallFunctionObjArgs is a faster alternative.
-
-    object PyObject_CallMethod(object o, char *method, char *format, ...)
-    # Return value: New reference.
-    # Call the method named method of object o with a variable number
-    # of C arguments. The C arguments are described by a
-    # Py_BuildValue() format string that should produce a tuple. The
-    # format may be NULL, indicating that no arguments are
-    # provided. Returns the result of the call on success, or NULL on
-    # failure. This is the equivalent of the Python expression
-    # "o.method(args)". Note that if you only pass object  args,
-    # PyObject_CallMethodObjArgs is a faster alternative.
-
-    #object PyObject_CallFunctionObjArgs(object callable, ..., NULL)
-    object PyObject_CallFunctionObjArgs(object callable, ...)
-    # Return value: New reference.
-    # Call a callable Python object callable, with a variable number
-    # of PyObject* arguments. The arguments are provided as a variable
-    # number of parameters followed by NULL. Returns the result of the
-    # call on success, or NULL on failure. 
-
-    #PyObject* PyObject_CallMethodObjArgs(object o, object name, ..., NULL)
-    object PyObject_CallMethodObjArgs(object o, object name, ...)
-    # Return value: New reference.
-    # Calls a method of the object o, where the name of the method is
-    # given as a Python string object in name. It is called with a
-    # variable number of PyObject* arguments. The arguments are
-    # provided as a variable number of parameters followed by
-    # NULL. Returns the result of the call on success, or NULL on
-    # failure.
-
-    long PyObject_Hash(object o) except? -1
-    # Compute and return the hash value of an object o. On failure,
-    # return -1. This is the equivalent of the Python expression
-    # "hash(o)".
-
-    bint PyObject_IsTrue(object o) except -1
-    # Returns 1 if the object o is considered to be true, and 0
-    # otherwise. This is equivalent to the Python expression "not not
-    # o". On failure, return -1.
-
-    bint PyObject_Not(object o) except -1
-    # Returns 0 if the object o is considered to be true, and 1
-    # otherwise. This is equivalent to the Python expression "not
-    # o". On failure, return -1.
-
-    object PyObject_Type(object o)
-    # Return value: New reference.
-    # When o is non-NULL, returns a type object corresponding to the
-    # object type of object o. On failure, raises SystemError and
-    # returns NULL. This is equivalent to the Python expression
-    # type(o). This function increments the reference count of the
-    # return value. There's really no reason to use this function
-    # instead of the common expression o->ob_type, which returns a
-    # pointer of type PyTypeObject*, except when the incremented
-    # reference count is needed.
-
-    bint PyObject_TypeCheck(object o, PyTypeObject *type)
-    # Return true if the object o is of type type or a subtype of
-    # type. Both parameters must be non-NULL.
-
-    Py_ssize_t PyObject_Length(object o) except -1
-    Py_ssize_t PyObject_Size(object o) except -1
-    # Return the length of object o. If the object o provides either
-    # the sequence and mapping protocols, the sequence length is
-    # returned. On error, -1 is returned. This is the equivalent to
-    # the Python expression "len(o)".
-
-    object PyObject_GetItem(object o, object key)
-    # Return value: New reference.
-    # Return element of o corresponding to the object key or NULL on
-    # failure. This is the equivalent of the Python expression
-    # "o[key]".
-
-    int PyObject_SetItem(object o, object key, object v) except -1
-    # Map the object key to the value v. Returns -1 on failure. This
-    # is the equivalent of the Python statement "o[key] = v".
-
-    int PyObject_DelItem(object o, object key) except -1
-    # Delete the mapping for key from o. Returns -1 on failure. This
-    # is the equivalent of the Python statement "del o[key]".
-
-    int PyObject_AsFileDescriptor(object o) except -1
-    # Derives a file-descriptor from a Python object. If the object is
-    # an integer or long integer, its value is returned. If not, the
-    # object's fileno() method is called if it exists; the method must
-    # return an integer or long integer, which is returned as the file
-    # descriptor value. Returns -1 on failure.
-
-    object PyObject_Dir(object o)
-    # Return value: New reference.
-    # This is equivalent to the Python expression "dir(o)", returning
-    # a (possibly empty) list of strings appropriate for the object
-    # argument, or NULL if there was an error. If the argument is
-    # NULL, this is like the Python "dir()", returning the names of
-    # the current locals; in this case, if no execution frame is
-    # active then NULL is returned but PyErr_Occurred() will return
-    # false.
-
-    object PyObject_GetIter(object o)
-    # Return value: New reference.
-    # This is equivalent to the Python expression "iter(o)". It
-    # returns a new iterator for the object argument, or the object
-    # itself if the object is already an iterator. Raises TypeError
-    # and returns NULL if the object cannot be iterated.
-
+# Present for backwards compatability
+from cpython.object cimport *
diff --git a/Cython/Includes/python_oldbuffer.pxd b/Cython/Includes/python_oldbuffer.pxd
index 0222428ed48e1cb84cde849f83b36e3079089245..d4bb2dc39a64a292e7ad12c07109e4384350520e 100644
--- a/Cython/Includes/python_oldbuffer.pxd
+++ b/Cython/Includes/python_oldbuffer.pxd
@@ -1,63 +1,2 @@
-# Legacy Python 2 buffer interface.
-#
-# These functions are no longer available in Python 3, use the new
-# buffer interface instead.
-
-cdef extern from "Python.h":
-    cdef enum _:
-        Py_END_OF_BUFFER
-    #    This constant may be passed as the size parameter to
-    #    PyBuffer_FromObject() or PyBuffer_FromReadWriteObject(). It
-    #    indicates that the new PyBufferObject should refer to base object
-    #    from the specified offset to the end of its exported
-    #    buffer. Using this enables the caller to avoid querying the base
-    #    object for its length.
-
-    bint PyBuffer_Check(object p)
-    #    Return true if the argument has type PyBuffer_Type.
-
-    object PyBuffer_FromObject(object base, Py_ssize_t offset, Py_ssize_t size)
-    #    Return value: New reference.
-    #
-    #    Return a new read-only buffer object. This raises TypeError if
-    #    base doesn't support the read-only buffer protocol or doesn't
-    #    provide exactly one buffer segment, or it raises ValueError if
-    #    offset is less than zero. The buffer will hold a reference to the
-    #    base object, and the buffer's contents will refer to the base
-    #    object's buffer interface, starting as position offset and
-    #    extending for size bytes. If size is Py_END_OF_BUFFER, then the
-    #    new buffer's contents extend to the length of the base object's
-    #    exported buffer data.
-
-    object PyBuffer_FromReadWriteObject(object base, Py_ssize_t offset, Py_ssize_t size)
-    #    Return value: New reference.
-    #
-    #    Return a new writable buffer object. Parameters and exceptions
-    #    are similar to those for PyBuffer_FromObject(). If the base
-    #    object does not export the writeable buffer protocol, then
-    #    TypeError is raised.
-
-    object PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
-    #    Return value: New reference.
-    #
-    #    Return a new read-only buffer object that reads from a specified
-    #    location in memory, with a specified size. The caller is
-    #    responsible for ensuring that the memory buffer, passed in as
-    #    ptr, is not deallocated while the returned buffer object
-    #    exists. Raises ValueError if size is less than zero. Note that
-    #    Py_END_OF_BUFFER may not be passed for the size parameter;
-    #    ValueError will be raised in that case.
-
-    object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)
-    #    Return value: New reference.
-    #
-    #    Similar to PyBuffer_FromMemory(), but the returned buffer is
-    #    writable.
-
-    object PyBuffer_New(Py_ssize_t size)
-    #    Return value: New reference.
-    #
-    #    Return a new writable buffer object that maintains its own memory
-    #    buffer of size bytes. ValueError is returned if size is not zero
-    #    or positive. Note that the memory buffer (as returned by
-    #    PyObject_AsWriteBuffer()) is not specifically aligned.
+# Present for backwards compatability
+from cpython.oldbuffer cimport *
diff --git a/Cython/Includes/python_pycapsule.pxd b/Cython/Includes/python_pycapsule.pxd
index 8117519445ac18506cdb0dbe2f01cdc19b00c641..a6f654382f33f596846c31c396782a2b569a1a70 100644
--- a/Cython/Includes/python_pycapsule.pxd
+++ b/Cython/Includes/python_pycapsule.pxd
@@ -1,146 +1,2 @@
-from python_ref cimport PyObject
-
-# available since Python 3.1!
-
-# note all char* in the below functions are actually const char*
-
-cdef extern from "Python.h":
-
-    ctypedef struct PyCapsule_Type
-    # This subtype of PyObject represents an opaque value, useful for
-    # C extension modules who need to pass an opaque value (as a void*
-    # pointer) through Python code to other C code. It is often used
-    # to make a C function pointer defined in one module available to
-    # other modules, so the regular import mechanism can be used to
-    # access C APIs defined in dynamically loaded modules.
-
-
-    ctypedef void (*PyCapsule_Destructor)(object o)
-    # The type of a destructor callback for a capsule.
-    #
-    # See PyCapsule_New() for the semantics of PyCapsule_Destructor
-    # callbacks.
-
-
-    bint PyCapsule_CheckExact(object o)
-    # Return true if its argument is a PyCapsule.
-
-
-    object PyCapsule_New(void *pointer, char *name,
-                         PyCapsule_Destructor destructor)
-    # Return value: New reference.
-    #
-    # Create a PyCapsule encapsulating the pointer. The pointer
-    # argument may not be NULL.
-    #
-    # On failure, set an exception and return NULL.
-    #
-    # The name string may either be NULL or a pointer to a valid C
-    # string. If non-NULL, this string must outlive the
-    # capsule. (Though it is permitted to free it inside the
-    # destructor.)
-    #
-    # If the destructor argument is not NULL, it will be called with
-    # the capsule as its argument when it is destroyed.
-    #
-    # If this capsule will be stored as an attribute of a module, the
-    # name should be specified as modulename.attributename. This will
-    # enable other modules to import the capsule using
-    # PyCapsule_Import().
-
-
-    void* PyCapsule_GetPointer(object capsule, char *name) except? NULL
-    # Retrieve the pointer stored in the capsule. On failure, set an
-    # exception and return NULL.
-    #
-    # The name parameter must compare exactly to the name stored in
-    # the capsule. If the name stored in the capsule is NULL, the name
-    # passed in must also be NULL. Python uses the C function strcmp()
-    # to compare capsule names.
-
-
-    PyCapsule_Destructor PyCapsule_GetDestructor(object capsule) except? NULL
-    # Return the current destructor stored in the capsule. On failure,
-    # set an exception and return NULL.
-    #
-    # It is legal for a capsule to have a NULL destructor. This makes
-    # a NULL return code somewhat ambiguous; use PyCapsule_IsValid()
-    # or PyErr_Occurred() to disambiguate.
-
-
-    char* PyCapsule_GetName(object capsule) except? NULL
-    # Return the current name stored in the capsule. On failure, set
-    # an exception and return NULL.
-    #
-    # It is legal for a capsule to have a NULL name. This makes a NULL
-    # return code somewhat ambiguous; use PyCapsule_IsValid() or
-    # PyErr_Occurred() to disambiguate.
-
-
-    void* PyCapsule_GetContext(object capsule) except? NULL
-    # Return the current context stored in the capsule. On failure,
-    # set an exception and return NULL.
-    #
-    # It is legal for a capsule to have a NULL context. This makes a
-    # NULL return code somewhat ambiguous; use PyCapsule_IsValid() or
-    # PyErr_Occurred() to disambiguate.
-
-
-    bint PyCapsule_IsValid(object capsule, char *name)
-    # Determines whether or not capsule is a valid capsule. A valid
-    # capsule is non-NULL, passes PyCapsule_CheckExact(), has a
-    # non-NULL pointer stored in it, and its internal name matches the
-    # name parameter. (See PyCapsule_GetPointer() for information on
-    # how capsule names are compared.)
-    #
-    # In other words, if PyCapsule_IsValid() returns a true value,
-    # calls to any of the accessors (any function starting with
-    # PyCapsule_Get()) are guaranteed to succeed.
-    # 
-    # Return a nonzero value if the object is valid and matches the
-    # name passed in. Return 0 otherwise. This function will not fail.
-
-
-    int PyCapsule_SetPointer(object capsule, void *pointer) except -1
-    # Set the void pointer inside capsule to pointer. The pointer may
-    # not be NULL.
-    #
-    # Return 0 on success. Return nonzero and set an exception on
-    # failure.
-
-
-    int PyCapsule_SetDestructor(object capsule, PyCapsule_Destructor destructor) except -1
-    # Set the destructor inside capsule to destructor.
-    #
-    # Return 0 on success. Return nonzero and set an exception on
-    # failure.
-
-
-    int PyCapsule_SetName(object capsule, char *name) except -1
-    # Set the name inside capsule to name. If non-NULL, the name must
-    # outlive the capsule. If the previous name stored in the capsule
-    # was not NULL, no attempt is made to free it.
-    #
-    # Return 0 on success. Return nonzero and set an exception on
-    # failure.
-
-
-    int PyCapsule_SetContext(object capsule, void *context) except -1
-    # Set the context pointer inside capsule to context.  Return 0 on
-    # success. Return nonzero and set an exception on failure.
-
-
-    void* PyCapsule_Import(char *name, int no_block) except? NULL
-    # Import a pointer to a C object from a capsule attribute in a
-    # module. The name parameter should specify the full name to the
-    # attribute, as in module.attribute. The name stored in the
-    # capsule must match this string exactly. If no_block is true,
-    # import the module without blocking (using
-    # PyImport_ImportModuleNoBlock()). If no_block is false, import
-    # the module conventionally (using PyImport_ImportModule()).
-    #
-    # Return the capsule’s internal pointer on success. On failure,
-    # set an exception and return NULL. However, if PyCapsule_Import()
-    # failed to import the module, and no_block was true, no exception
-    # is set.
-
+# Present for backwards compatability
+from cpython.pycapsule cimport *
diff --git a/Cython/Includes/python_ref.pxd b/Cython/Includes/python_ref.pxd
index 0bb49a3b70156a6ff0cc796bc53fa8255d1c4e4c..fc1783da48511e5ed98300dc555e823b03926b41 100644
--- a/Cython/Includes/python_ref.pxd
+++ b/Cython/Includes/python_ref.pxd
@@ -1,55 +1,2 @@
-cdef extern from "Python.h":
-    ctypedef struct PyTypeObject
-    ctypedef struct PyObject:
-        Py_ssize_t ob_refcnt
-        PyTypeObject *ob_type
-
-
-    #####################################################################
-    # 3. Reference Counts
-    #####################################################################
-    # The macros in this section are used for managing reference counts of Python objects.
-    void Py_INCREF(object o)
-    # Increment the reference count for object o. The object must not
-    # be NULL; if you aren't sure that it isn't NULL, use
-    # Py_XINCREF().
-
-    void Py_XINCREF(PyObject* o)
-    # Increment the reference count for object o. The object may be NULL, in which case the macro has no effect. 
-
-    void Py_DECREF(object o)
-    # Decrement the reference count for object o. The object must not
-    # be NULL; if you aren't sure that it isn't NULL, use
-    # Py_XDECREF(). If the reference count reaches zero, the object's
-    # type's deallocation function (which must not be NULL) is
-    # invoked.
-
-    # Warning: The deallocation function can cause arbitrary Python
-    # code to be invoked (e.g. when a class instance with a __del__()
-    # method is deallocated). While exceptions in such code are not
-    # propagated, the executed code has free access to all Python
-    # global variables. This means that any object that is reachable
-    # from a global variable should be in a consistent state before
-    # Py_DECREF() is invoked. For example, code to delete an object
-    # from a list should copy a reference to the deleted object in a
-    # temporary variable, update the list data structure, and then
-    # call Py_DECREF() for the temporary variable.
-
-    void Py_XDECREF(PyObject* o)
-    # Decrement the reference count for object o. The object may be
-    # NULL, in which case the macro has no effect; otherwise the
-    # effect is the same as for Py_DECREF(), and the same warning
-    # applies.
-
-    void Py_CLEAR(PyObject* o)
-    # Decrement the reference count for object o. The object may be
-    # NULL, in which case the macro has no effect; otherwise the
-    # effect is the same as for Py_DECREF(), except that the argument
-    # is also set to NULL. The warning for Py_DECREF() does not apply
-    # with respect to the object passed because the macro carefully
-    # uses a temporary variable and sets the argument to NULL before
-    # decrementing its reference count.
-    # It is a good idea to use this macro whenever decrementing the
-    # value of a variable that might be traversed during garbage
-    # collection.
-
+# Present for backwards compatability
+from cpython.ref cimport *
diff --git a/Cython/Includes/python_sequence.pxd b/Cython/Includes/python_sequence.pxd
index b3c243d67d34a4b44074f9bf41d2106c694e15bf..b73fa478924a47766a4b34c2e19979ed36630020 100644
--- a/Cython/Includes/python_sequence.pxd
+++ b/Cython/Includes/python_sequence.pxd
@@ -1,136 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 6.3 Sequence Protocol
-    ############################################################################
-
-    bint PySequence_Check(object o)
-    # Return 1 if the object provides sequence protocol, and 0
-    # otherwise. This function always succeeds.
-
-    Py_ssize_t PySequence_Size(object o) except -1
-    # Returns the number of objects in sequence o on success, and -1
-    # on failure. For objects that do not provide sequence protocol,
-    # this is equivalent to the Python expression "len(o)".
-
-    Py_ssize_t PySequence_Length(object o) except -1
-    # Alternate name for PySequence_Size(). 
-
-    object PySequence_Concat(object o1, object o2)
-    # Return value: New reference.
-    # Return the concatenation of o1 and o2 on success, and NULL on
-    # failure. This is the equivalent of the Python expression "o1 +
-    # o2".
-
-    object PySequence_Repeat(object o, Py_ssize_t count)
-    # Return value: New reference.
-    # Return the result of repeating sequence object o count times, or
-    # NULL on failure. This is the equivalent of the Python expression
-    # "o * count".
-
-    object PySequence_InPlaceConcat(object o1, object o2)
-    # Return value: New reference.
-    # Return the concatenation of o1 and o2 on success, and NULL on
-    # failure. The operation is done in-place when o1 supports
-    # it. This is the equivalent of the Python expression "o1 += o2".
-
-    object PySequence_InPlaceRepeat(object o, Py_ssize_t count)
-    # Return value: New reference.
-    # Return the result of repeating sequence object o count times, or
-    # NULL on failure. The operation is done in-place when o supports
-    # it. This is the equivalent of the Python expression "o *=
-    # count".
-
-    object PySequence_GetItem(object o, Py_ssize_t i)
-    # Return value: New reference.
-    # Return the ith element of o, or NULL on failure. This is the
-    # equivalent of the Python expression "o[i]".
-
-    object PySequence_GetSlice(object o, Py_ssize_t i1, Py_ssize_t i2)
-    # Return value: New reference.
-    # Return the slice of sequence object o between i1 and i2, or NULL
-    # on failure. This is the equivalent of the Python expression
-    # "o[i1:i2]".
-
-    int PySequence_SetItem(object o, Py_ssize_t i, object v) except -1
-    # Assign object v to the ith element of o. Returns -1 on
-    # failure. This is the equivalent of the Python statement "o[i] =
-    # v". This function does not steal a reference to v.
-
-    int PySequence_DelItem(object o, Py_ssize_t i) except -1
-    # Delete the ith element of object o. Returns -1 on failure. This
-    # is the equivalent of the Python statement "del o[i]".
-
-    int PySequence_SetSlice(object o, Py_ssize_t i1, Py_ssize_t i2, object v) except -1
-    # Assign the sequence object v to the slice in sequence object o
-    # from i1 to i2. This is the equivalent of the Python statement
-    # "o[i1:i2] = v".
-
-    int PySequence_DelSlice(object o, Py_ssize_t i1, Py_ssize_t i2) except -1
-    # Delete the slice in sequence object o from i1 to i2. Returns -1
-    # on failure. This is the equivalent of the Python statement "del
-    # o[i1:i2]".
-
-    int PySequence_Count(object o, object value) except -1
-    # Return the number of occurrences of value in o, that is, return
-    # the number of keys for which o[key] == value. On failure, return
-    # -1. This is equivalent to the Python expression
-    # "o.count(value)".
-
-    int PySequence_Contains(object o, object value) except -1
-    # Determine if o contains value. If an item in o is equal to
-    # value, return 1, otherwise return 0. On error, return -1. This
-    # is equivalent to the Python expression "value in o".
-
-    int PySequence_Index(object o, object value) except -1
-    # Return the first index i for which o[i] == value. On error,
-    # return -1. This is equivalent to the Python expression
-    # "o.index(value)".
-
-    object PySequence_List(object o)
-    # Return value: New reference.
-    # Return a list object with the same contents as the arbitrary
-    # sequence o. The returned list is guaranteed to be new.
-
-    object PySequence_Tuple(object o)
-    # Return value: New reference.
-    # Return a tuple object with the same contents as the arbitrary
-    # sequence o or NULL on failure. If o is a tuple, a new reference
-    # will be returned, otherwise a tuple will be constructed with the
-    # appropriate contents. This is equivalent to the Python
-    # expression "tuple(o)".
-
-    object PySequence_Fast(object o, char *m)
-    # Return value: New reference.
-    # Returns the sequence o as a tuple, unless it is already a tuple
-    # or list, in which case o is returned. Use
-    # PySequence_Fast_GET_ITEM() to access the members of the
-    # result. Returns NULL on failure. If the object is not a
-    # sequence, raises TypeError with m as the message text.
-
-    PyObject* PySequence_Fast_GET_ITEM(object o, Py_ssize_t i)
-    # Return value: Borrowed reference.
-    # Return the ith element of o, assuming that o was returned by
-    # PySequence_Fast(), o is not NULL, and that i is within bounds.
-
-    PyObject** PySequence_Fast_ITEMS(object o)
-    # Return the underlying array of PyObject pointers. Assumes that o
-    # was returned by PySequence_Fast() and o is not NULL. 
-
-    object PySequence_ITEM(object o, Py_ssize_t i)
-    # Return value: New reference.
-    # Return the ith element of o or NULL on failure. Macro form of
-    # PySequence_GetItem() but without checking that
-    # PySequence_Check(o) is true and without adjustment for negative
-    # indices.
-
-    int PySequence_Fast_GET_SIZE(object o)
-    # Returns the length of o, assuming that o was returned by
-    # PySequence_Fast() and that o is not NULL. The size can also be
-    # gotten by calling PySequence_Size() on o, but
-    # PySequence_Fast_GET_SIZE() is faster because it can assume o is
-    # a list or tuple.
-
-
+# Present for backwards compatability
+from cpython.sequence cimport *
diff --git a/Cython/Includes/python_set.pxd b/Cython/Includes/python_set.pxd
index 3cedcb5bd52a46874d5bcf25069dd06ed65b85f1..96a4780c207d4e56a306d6ded9b6bea3fb0a89e3 100644
--- a/Cython/Includes/python_set.pxd
+++ b/Cython/Includes/python_set.pxd
@@ -1,113 +1,2 @@
-cdef extern from "Python.h":
-
-    ############################################################################
-    # 7.5.14 Set Objects
-    ############################################################################
-
-    # This section details the public API for set and frozenset
-    # objects. Any functionality not listed below is best accessed
-    # using the either the abstract object protocol (including
-    # PyObject_CallMethod(), PyObject_RichCompareBool(),
-    # PyObject_Hash(), PyObject_Repr(), PyObject_IsTrue(),
-    # PyObject_Print(), and PyObject_GetIter()) or the abstract number
-    # protocol (including PyNumber_Add(), PyNumber_Subtract(),
-    # PyNumber_Or(), PyNumber_Xor(), PyNumber_InPlaceAdd(),
-    # PyNumber_InPlaceSubtract(), PyNumber_InPlaceOr(), and
-    # PyNumber_InPlaceXor()).
-
-    # PySetObject
-    # This subtype of PyObject is used to hold the internal data for
-    # both set and frozenset objects. It is like a PyDictObject in
-    # that it is a fixed size for small sets (much like tuple storage)
-    # and will point to a separate, variable sized block of memory for
-    # medium and large sized sets (much like list storage). None of
-    # the fields of this structure should be considered public and are
-    # subject to change. All access should be done through the
-    # documented API rather than by manipulating the values in the
-    # structure.
-
-    # PyTypeObject PySet_Type
-    # This is an instance of PyTypeObject representing the Python set type. 
-
-    # PyTypeObject PyFrozenSet_Type
-    # This is an instance of PyTypeObject representing the Python frozenset type. 
-
-    # The following type check macros work on pointers to any Python
-    # object. Likewise, the constructor functions work with any
-    # iterable Python object.
-
-    bint PyAnySet_Check(object p)
-    # Return true if p is a set object, a frozenset object, or an
-    # instance of a subtype.
-
-    bint PyAnySet_CheckExact(object p)
-    # Return true if p is a set object or a frozenset object but not
-    # an instance of a subtype.
-
-    bint PyFrozenSet_CheckExact(object p)
-    # Return true if p is a frozenset object but not an instance of a subtype. 
-
-    object PySet_New(object iterable)
-    # Return value: New reference.
-    # Return a new set containing objects returned by the
-    # iterable. The iterable may be NULL to create a new empty
-    # set. Return the new set on success or NULL on failure. Raise
-    # TypeError if iterable is not actually iterable. The constructor
-    # is also useful for copying a set (c=set(s)).
-
-    object PyFrozenSet_New(object iterable)
-    # Return value: New reference.
-    # Return a new frozenset containing objects returned by the
-    # iterable. The iterable may be NULL to create a new empty
-    # frozenset. Return the new set on success or NULL on
-    # failure. Raise TypeError if iterable is not actually iterable.
-
-
-    # The following functions and macros are available for instances
-    # of set or frozenset or instances of their subtypes.
-
-    int PySet_Size(object anyset) except -1
-    # Return the length of a set or frozenset object. Equivalent to
-    # "len(anyset)". Raises a PyExc_SystemError if anyset is not a
-    # set, frozenset, or an instance of a subtype.
-
-    int PySet_GET_SIZE(object anyset)
-    # Macro form of PySet_Size() without error checking. 
-
-    bint PySet_Contains(object anyset, object key) except -1
-    # Return 1 if found, 0 if not found, and -1 if an error is
-    # encountered. Unlike the Python __contains__() method, this
-    # function does not automatically convert unhashable sets into
-    # temporary frozensets. Raise a TypeError if the key is
-    # unhashable. Raise PyExc_SystemError if anyset is not a set,
-    # frozenset, or an instance of a subtype.
-
-
-    # The following functions are available for instances of set or
-    # its subtypes but not for instances of frozenset or its subtypes.
-
-    int PySet_Add(object set, object key) except -1
-    # Add key to a set instance. Does not apply to frozenset
-    # instances. Return 0 on success or -1 on failure. Raise a
-    # TypeError if the key is unhashable. Raise a MemoryError if there
-    # is no room to grow. Raise a SystemError if set is an not an
-    # instance of set or its subtype.
-
-    bint PySet_Discard(object set, object key) except -1
-    # Return 1 if found and removed, 0 if not found (no action taken),
-    # and -1 if an error is encountered. Does not raise KeyError for
-    # missing keys. Raise a TypeError if the key is unhashable. Unlike
-    # the Python discard() method, this function does not
-    # automatically convert unhashable sets into temporary
-    # frozensets. Raise PyExc_SystemError if set is an not an instance
-    # of set or its subtype.
-
-    object PySet_Pop(object set)
-    # Return value: New reference.
-    # Return a new reference to an arbitrary object in the set, and
-    # removes the object from the set. Return NULL on failure. Raise
-    # KeyError if the set is empty. Raise a SystemError if set is an
-    # not an instance of set or its subtype.
-
-    int PySet_Clear(object set)
-    # Empty an existing set of all elements. 
+# Present for backwards compatability
+from cpython.set cimport *
diff --git a/Cython/Includes/python_string.pxd b/Cython/Includes/python_string.pxd
index 54f3ff57a0eea6ad95b9bf78a9d98d1b17c2fbb0..df4fd4f4839f01ae027a5d1bf9fc0852f7f4ce35 100644
--- a/Cython/Includes/python_string.pxd
+++ b/Cython/Includes/python_string.pxd
@@ -1,198 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-    ctypedef struct va_list
-
-    ############################################################################
-    # 7.3.1 String Objects
-    ############################################################################
-
-    # These functions raise TypeError when expecting a string
-    # parameter and are called with a non-string parameter.
-    # PyStringObject
-    # This subtype of PyObject represents a Python string object. 
-    # PyTypeObject PyString_Type
-    # This instance of PyTypeObject represents the Python string type;
-    # it is the same object as str and types.StringType in the Python
-    # layer. 
-
-    bint PyString_Check(object o)
-    # Return true if the object o is a string object or an instance of
-    # a subtype of the string type. 
-
-    bint PyString_CheckExact(object o)
-    # Return true if the object o is a string object, but not an instance of a subtype of the string type. 
-
-    object PyString_FromString(char *v)
-    # Return value: New reference.
-    # Return a new string object with the value v on success, and NULL
-    # on failure. The parameter v must not be NULL; it will not be
-    # checked.
-
-    object PyString_FromStringAndSize(char *v, Py_ssize_t len)
-    # Return value: New reference.
-    # Return a new string object with the value v and length len on
-    # success, and NULL on failure. If v is NULL, the contents of the
-    # string are uninitialized.
-
-    object PyString_FromFormat(char *format, ...)
-    # Return value: New reference.
-    # Take a C printf()-style format string and a variable number of
-    # arguments, calculate the size of the resulting Python string and
-    # return a string with the values formatted into it. The variable
-    # arguments must be C types and must correspond exactly to the
-    # format characters in the format string. The following format
-    # characters are allowed:
-    # Format Characters 	Type 	Comment
-    # %% 	n/a 	The literal % character.
-    # %c 	int 	A single character, represented as an C int.
-    # %d 	int 	Exactly equivalent to printf("%d").
-    # %u 	unsigned int 	Exactly equivalent to printf("%u").
-    # %ld 	long 	Exactly equivalent to printf("%ld").
-    # %lu 	unsigned long 	Exactly equivalent to printf("%lu").
-    # %zd 	Py_ssize_t 	Exactly equivalent to printf("%zd").
-    # %zu 	size_t 	Exactly equivalent to printf("%zu").
-    # %i 	int 	Exactly equivalent to printf("%i").
-    # %x 	int 	Exactly equivalent to printf("%x").
-    # %s 	char* 	A null-terminated C character array.
-
-    # %p 	void* 	The hex representation of a C pointer.
-    #    Mostly equivalent to printf("%p") except that it is guaranteed to
-    #    start with the literal 0x regardless of what the platform's printf
-    #    yields.
-    # An unrecognized format character causes all the rest of the
-    # format string to be copied as-is to the result string, and any
-    # extra arguments discarded.
-
-    object PyString_FromFormatV(char *format, va_list vargs)
-    # Return value: New reference.
-    # Identical to PyString_FromFormat() except that it takes exactly two arguments. 
-
-    Py_ssize_t PyString_Size(object string) except -1
-    # Return the length of the string in string object string. 
-
-    Py_ssize_t PyString_GET_SIZE(object string)
-    # Macro form of PyString_Size() but without error checking. 
-
-    char* PyString_AsString(object string) except NULL
-    # Return a NUL-terminated representation of the contents of
-    # string. The pointer refers to the internal buffer of string, not
-    # a copy. The data must not be modified in any way, unless the
-    # string was just created using PyString_FromStringAndSize(NULL,
-    # size). It must not be deallocated. If string is a Unicode
-    # object, this function computes the default encoding of string
-    # and operates on that. If string is not a string object at all,
-    # PyString_AsString() returns NULL and raises TypeError.
-
-    char* PyString_AS_STRING(object string)
-    # Macro form of PyString_AsString() but without error
-    # checking. Only string objects are supported; no Unicode objects
-    # should be passed.
-
-    int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) except -1
-    # Return a NULL-terminated representation of the contents of the
-    # object obj through the output variables buffer and length.
-    #
-    # The function accepts both string and Unicode objects as
-    # input. For Unicode objects it returns the default encoded
-    # version of the object. If length is NULL, the resulting buffer
-    # may not contain NUL characters; if it does, the function returns
-    # -1 and a TypeError is raised.
-    
-    # The buffer refers to an internal string buffer of obj, not a
-    # copy. The data must not be modified in any way, unless the
-    # string was just created using PyString_FromStringAndSize(NULL,
-    # size). It must not be deallocated. If string is a Unicode
-    # object, this function computes the default encoding of string
-    # and operates on that. If string is not a string object at all,
-    # PyString_AsStringAndSize() returns -1 and raises TypeError.
-
-    void PyString_Concat(PyObject **string, object newpart)
-    # Create a new string object in *string containing the contents of
-    # newpart appended to string; the caller will own the new
-    # reference. The reference to the old value of string will be
-    # stolen. If the new string cannot be created, the old reference
-    # to string will still be discarded and the value of *string will
-    # be set to NULL; the appropriate exception will be set.
-
-    void PyString_ConcatAndDel(PyObject **string, object newpart)
-    # Create a new string object in *string containing the contents of
-    # newpart appended to string. This version decrements the
-    # reference count of newpart.
-
-    int _PyString_Resize(PyObject **string, Py_ssize_t newsize) except -1
-    # A way to resize a string object even though it is
-    # ``immutable''. Only use this to build up a brand new string
-    # object; don't use this if the string may already be known in
-    # other parts of the code. It is an error to call this function if
-    # the refcount on the input string object is not one. Pass the
-    # address of an existing string object as an lvalue (it may be
-    # written into), and the new size desired. On success, *string
-    # holds the resized string object and 0 is returned; the address
-    # in *string may differ from its input value. If the reallocation
-    # fails, the original string object at *string is deallocated,
-    # *string is set to NULL, a memory exception is set, and -1 is
-    # returned.
-
-    object PyString_Format(object format, object args)
-    # Return value: New reference.  Return a new string object from
-    # format and args. Analogous to format % args. The args argument
-    # must be a tuple.
-
-    void PyString_InternInPlace(PyObject **string)
-    # Intern the argument *string in place. The argument must be the
-    # address of a pointer variable pointing to a Python string
-    # object. If there is an existing interned string that is the same
-    # as *string, it sets *string to it (decrementing the reference
-    # count of the old string object and incrementing the reference
-    # count of the interned string object), otherwise it leaves
-    # *string alone and interns it (incrementing its reference
-    # count). (Clarification: even though there is a lot of talk about
-    # reference counts, think of this function as
-    # reference-count-neutral; you own the object after the call if
-    # and only if you owned it before the call.)
-
-    object PyString_InternFromString(char *v)
-    # Return value: New reference.
-    # A combination of PyString_FromString() and
-    # PyString_InternInPlace(), returning either a new string object
-    # that has been interned, or a new (``owned'') reference to an
-    # earlier interned string object with the same value.
-
-    object PyString_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
-    #  Return value: New reference.
-    # Create an object by decoding size bytes of the encoded buffer s
-    # using the codec registered for encoding. encoding and errors
-    # have the same meaning as the parameters of the same name in the
-    # unicode() built-in function. The codec to be used is looked up
-    # using the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-    object PyString_AsDecodedObject(object str, char *encoding, char *errors)
-    # Return value: New reference.
-    # Decode a string object by passing it to the codec registered for
-    # encoding and return the result as Python object. encoding and
-    # errors have the same meaning as the parameters of the same name
-    # in the string encode() method. The codec to be used is looked up
-    # using the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-    object PyString_Encode(char *s, Py_ssize_t size, char *encoding, char *errors)
-    # Return value: New reference.
-    # Encode the char buffer of the given size by passing it to the
-    # codec registered for encoding and return a Python
-    # object. encoding and errors have the same meaning as the
-    # parameters of the same name in the string encode() method. The
-    # codec to be used is looked up using the Python codec
-    # registry. Return NULL if an exception was raised by the codec.
-
-    object PyString_AsEncodedObject(object str, char *encoding, char *errors)
-    # Return value: New reference.
-    # Encode a string object using the codec registered for encoding
-    # and return the result as Python object. encoding and errors have
-    # the same meaning as the parameters of the same name in the
-    # string encode() method. The codec to be used is looked up using
-    # the Python codec registry. Return NULL if an exception was
-    # raised by the codec.
-
-
+# Present for backwards compatability
+from cpython.string cimport *
diff --git a/Cython/Includes/python_tuple.pxd b/Cython/Includes/python_tuple.pxd
index 025d2e174d92e1638257d32c37da944f46c66c0d..2362c090ee3d9b3caae0bcc934ae081bbb03221e 100644
--- a/Cython/Includes/python_tuple.pxd
+++ b/Cython/Includes/python_tuple.pxd
@@ -1,71 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    ############################################################################
-    # Tuples
-    ############################################################################
-
-    bint PyTuple_Check(object  p)
-    # Return true if p is a tuple object or an instance of a subtype
-    # of the tuple type.
-
-    bint PyTuple_CheckExact(object  p)
-    # Return true if p is a tuple object, but not an instance of a subtype of the tuple type.
-
-    object PyTuple_New(Py_ssize_t len)
-    # Return value: New reference.
-    # Return a new tuple object of size len, or NULL on failure. 
-
-    object PyTuple_Pack(Py_ssize_t n, ...)
-    # Return value: New reference.
-    # Return a new tuple object of size n, or NULL on failure. The
-    # tuple values are initialized to the subsequent n C arguments
-    # pointing to Python objects. "PyTuple_Pack(2, a, b)" is
-    # equivalent to "Py_BuildValue("(OO)", a, b)".
-
-    int PyTuple_Size(object  p) except -1
-    # Take a pointer to a tuple object, and return the size of that tuple. 
-
-    int PyTuple_GET_SIZE(object  p)
-    # Return the size of the tuple p, which must be non-NULL and point
-    # to a tuple; no error checking is performed.
-
-    PyObject* PyTuple_GetItem(object  p, Py_ssize_t pos) except NULL
-    # Return value: Borrowed reference.
-    # Return the object at position pos in the tuple pointed to by
-    # p. If pos is out of bounds, return NULL and sets an IndexError
-    # exception.
-
-    PyObject* PyTuple_GET_ITEM(object  p, Py_ssize_t pos)
-    # Return value: Borrowed reference.
-    # Like PyTuple_GetItem(), but does no checking of its arguments. 
-
-    object PyTuple_GetSlice(object  p, Py_ssize_t low, Py_ssize_t high)
-    # Return value: New reference.
-    # Take a slice of the tuple pointed to by p from low to high and return it as a new tuple. 
-
-    int PyTuple_SetItem(object  p, Py_ssize_t pos, object  o)
-    # Insert a reference to object o at position pos of the tuple
-    # pointed to by p. Return 0 on success. Note: This function
-    # ``steals'' a reference to o.
-
-    void PyTuple_SET_ITEM(object  p, Py_ssize_t pos, object  o)
-    # Like PyTuple_SetItem(), but does no error checking, and should
-    # only be used to fill in brand new tuples. Note: This function
-    # ``steals'' a reference to o.
-
-    int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1
-    # Can be used to resize a tuple. newsize will be the new length of
-    # the tuple. Because tuples are supposed to be immutable, this
-    # should only be used if there is only one reference to the
-    # object. Do not use this if the tuple may already be known to
-    # some other part of the code. The tuple will always grow or
-    # shrink at the end. Think of this as destroying the old tuple and
-    # creating a new one, only more efficiently. Returns 0 on
-    # success. Client code should never assume that the resulting
-    # value of *p will be the same as before calling this function. If
-    # the object referenced by *p is replaced, the original *p is
-    # destroyed. On failure, returns -1 and sets *p to NULL, and
-    # raises MemoryError or SystemError.
-
+# Present for backwards compatability
+from cpython.tuple cimport *
diff --git a/Cython/Includes/python_type.pxd b/Cython/Includes/python_type.pxd
index 362a0964fa4ce6853e6d6ec91be19225e7991cc5..b1c4d1ca976764ace0945689edadd88e0fec5c9a 100644
--- a/Cython/Includes/python_type.pxd
+++ b/Cython/Includes/python_type.pxd
@@ -1,45 +1,2 @@
-
-cdef extern from "Python.h":
-    # The C structure of the objects used to describe built-in types. 
-
-    ############################################################################
-    # 7.1.1 Type Objects
-    ############################################################################
-
-    # PyObject* PyType_Type
-    # This is the type object for type objects; it is the same object
-    # as type and types.TypeType in the Python layer.
-
-    bint PyType_Check(object o)
-    # Return true if the object o is a type object, including
-    # instances of types derived from the standard type object. Return
-    # false in all other cases.
-
-    bint PyType_CheckExact(object o)
-    # Return true if the object o is a type object, but not a subtype
-    # of the standard type object. Return false in all other
-    # cases.
-
-    bint PyType_HasFeature(object o, int feature)
-    # Return true if the type object o sets the feature feature. Type
-    # features are denoted by single bit flags.
-
-    bint PyType_IS_GC(object o)
-    # Return true if the type object includes support for the cycle
-    # detector; this tests the type flag Py_TPFLAGS_HAVE_GC. 
-
-    bint PyType_IsSubtype(object a, object b)
-    # Return true if a is a subtype of b. 
-
-    object PyType_GenericAlloc(object type, Py_ssize_t nitems)
-    # Return value: New reference.
-
-    object PyType_GenericNew(object type, object args, object kwds)
-    # Return value: New reference.
-
-    bint PyType_Ready(object type) except -1
-    # Finalize a type object. This should be called on all type
-    # objects to finish their initialization. This function is
-    # responsible for adding inherited slots from a type's base
-    # class. Return 0 on success, or return -1 and sets an exception
-    # on error.
+# Present for backwards compatability
+from cpython.type cimport *
diff --git a/Cython/Includes/python_unicode.pxd b/Cython/Includes/python_unicode.pxd
index 2a1f14f356b31df95b992c3f4c508b1bd9705e18..88fc5afb10193bee1d3adefd5a88b895dea3d196 100644
--- a/Cython/Includes/python_unicode.pxd
+++ b/Cython/Includes/python_unicode.pxd
@@ -1,385 +1,2 @@
-cdef extern from *:
-    ctypedef unsigned int Py_UNICODE
-
-    # Return true if the object o is a Unicode object or an instance
-    # of a Unicode subtype. Changed in version 2.2: Allowed subtypes
-    # to be accepted.
-    bint PyUnicode_Check(object o)
-
-    # Return true if the object o is a Unicode object, but not an
-    # instance of a subtype. New in version 2.2.
-    bint PyUnicode_CheckExact(object o)
-
-    # Return the size of the object. o has to be a PyUnicodeObject
-    # (not checked).
-    Py_ssize_t PyUnicode_GET_SIZE(object o)
-
-    # Return the size of the object's internal buffer in bytes. o has
-    # to be a PyUnicodeObject (not checked).
-    Py_ssize_t PyUnicode_GET_DATA_SIZE(object o)
-
-    # Return a pointer to the internal Py_UNICODE buffer of the
-    # object. o has to be a PyUnicodeObject (not checked).
-    Py_UNICODE* PyUnicode_AS_UNICODE(object o)
-
-    # Return a pointer to the internal buffer of the object. o has to
-    # be a PyUnicodeObject (not checked).
-    char* PyUnicode_AS_DATA(object o)
-
-    # Return 1 or 0 depending on whether ch is a whitespace character.
-    bint Py_UNICODE_ISSPACE(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is a lowercase character.
-    bint Py_UNICODE_ISLOWER(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is an uppercase character.
-    bint Py_UNICODE_ISUPPER(Py_UNICODE ch)
-    
-    # Return 1 or 0 depending on whether ch is a titlecase character. 
-    bint Py_UNICODE_ISTITLE(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is a linebreak character. 
-    bint Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is a decimal character. 
-    bint Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is a digit character. 
-    bint Py_UNICODE_ISDIGIT(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is a numeric character. 
-    bint Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is an alphabetic character. 
-    bint Py_UNICODE_ISALPHA(Py_UNICODE ch)
-
-    # Return 1 or 0 depending on whether ch is an alphanumeric character. 
-    bint Py_UNICODE_ISALNUM(Py_UNICODE ch)
-
-    # Return the character ch converted to lower case. 
-    Py_UNICODE Py_UNICODE_TOLOWER(Py_UNICODE ch)
-
-    # Return the character ch converted to upper case. 
-    Py_UNICODE Py_UNICODE_TOUPPER(Py_UNICODE ch)
-
-    # Return the character ch converted to title case. 
-    Py_UNICODE Py_UNICODE_TOTITLE(Py_UNICODE ch)
-
-    # Return the character ch converted to a decimal positive
-    # integer. Return -1 if this is not possible. This macro does not
-    # raise exceptions.
-    int Py_UNICODE_TODECIMAL(Py_UNICODE ch)
-
-    # Return the character ch converted to a single digit
-    # integer. Return -1 if this is not possible. This macro does not
-    # raise exceptions.
-    int Py_UNICODE_TODIGIT(Py_UNICODE ch)
-
-    # Return the character ch converted to a double. Return -1.0 if
-    # this is not possible. This macro does not raise exceptions.
-    double Py_UNICODE_TONUMERIC(Py_UNICODE ch)
-
-    # To create Unicode objects and access their basic sequence
-    # properties, use these APIs:
-
-    # Create a Unicode Object from the Py_UNICODE buffer u of the
-    # given size. u may be NULL which causes the contents to be
-    # undefined. It is the user's responsibility to fill in the needed
-    # data. The buffer is copied into the new object. If the buffer is
-    # not NULL, the return value might be a shared object. Therefore,
-    # modification of the resulting Unicode object is only allowed
-    # when u is NULL.
-    object PyUnicode_FromUnicode(Py_UNICODE *u, Py_ssize_t size)
-
-    # Return a read-only pointer to the Unicode object's internal
-    # Py_UNICODE buffer, NULL if unicode is not a Unicode object.
-    Py_UNICODE* PyUnicode_AsUnicode(object o) except NULL
-
-    # Return the length of the Unicode object. 
-    Py_ssize_t PyUnicode_GetSize(object o) except -1
-
-    # Coerce an encoded object obj to an Unicode object and return a
-    # reference with incremented refcount.
-    # String and other char buffer compatible objects are decoded
-    # according to the given encoding and using the error handling
-    # defined by errors. Both can be NULL to have the interface use
-    # the default values (see the next section for details).
-    # All other objects, including Unicode objects, cause a TypeError
-    # to be set.
-    object PyUnicode_FromEncodedObject(object o, char *encoding, char *errors)
-
-    # Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict")
-    # which is used throughout the interpreter whenever coercion to
-    # Unicode is needed.
-    object PyUnicode_FromObject(object obj)
-
-    # If the platform supports wchar_t and provides a header file
-    # wchar.h, Python can interface directly to this type using the
-    # following functions. Support is optimized if Python's own
-    # Py_UNICODE type is identical to the system's wchar_t.
-
-    #ctypedef int wchar_t
-
-    # Create a Unicode object from the wchar_t buffer w of the given
-    # size. Return NULL on failure.
-    #PyObject* PyUnicode_FromWideChar(wchar_t *w, Py_ssize_t size)
-
-    #Py_ssize_t PyUnicode_AsWideChar(object o, wchar_t *w, Py_ssize_t size)
-
-# Codecs
-
-    # Create a Unicode object by decoding size bytes of the encoded
-    # string s. encoding and errors have the same meaning as the
-    # parameters of the same name in the unicode() builtin
-    # function. The codec to be used is looked up using the Python
-    # codec registry. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_Decode(char *s, Py_ssize_t size, char *encoding, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size and return a
-    # Python string object. encoding and errors have the same meaning
-    # as the parameters of the same name in the Unicode encode()
-    # method. The codec to be used is looked up using the Python codec
-    # registry. Return NULL if an exception was raised by the codec.
-    object PyUnicode_Encode(Py_UNICODE *s, Py_ssize_t size,
-                            char *encoding, char *errors)
-
-    # Encode a Unicode object and return the result as Python string
-    # object. encoding and errors have the same meaning as the
-    # parameters of the same name in the Unicode encode() method. The
-    # codec to be used is looked up using the Python codec
-    # registry. Return NULL if an exception was raised by the codec.
-    object PyUnicode_AsEncodedString(object unicode, char *encoding, char *errors)
-
-# These are the UTF-8 codec APIs:
-
-    # Create a Unicode object by decoding size bytes of the UTF-8
-    # encoded string s. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_DecodeUTF8(char *s, Py_ssize_t size, char *errors)
-
-    # If consumed is NULL, behave like PyUnicode_DecodeUTF8(). If
-    # consumed is not NULL, trailing incomplete UTF-8 byte sequences
-    # will not be treated as an error. Those bytes will not be decoded
-    # and the number of bytes that have been decoded will be stored in
-    # consumed. New in version 2.4.
-    object PyUnicode_DecodeUTF8Stateful(char *s, Py_ssize_t size, char *errors, Py_ssize_t *consumed)
-
-    # Encode the Py_UNICODE buffer of the given size using UTF-8 and
-    # return a Python string object. Return NULL if an exception was
-    # raised by the codec.
-    object PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors)
-
-    # Encode a Unicode objects using UTF-8 and return the result as Python string object. Error handling is ``strict''. Return NULL if an exception was raised by the codec. 
-    object PyUnicode_AsUTF8String(object unicode)
-
-# These are the UTF-16 codec APIs:
-
-    # Decode length bytes from a UTF-16 encoded buffer string and
-    # return the corresponding Unicode object. errors (if non-NULL)
-    # defines the error handling. It defaults to ``strict''.
-    # 
-    # If byteorder is non-NULL, the decoder starts decoding using the
-    # given byte order:
-    #
-    #   *byteorder == -1: little endian
-    #   *byteorder == 0:  native order
-    #   *byteorder == 1:  big endian
-    #
-    # and then switches if the first two bytes of the input data are a
-    # byte order mark (BOM) and the specified byte order is native
-    # order. This BOM is not copied into the resulting Unicode
-    # string. After completion, *byteorder is set to the current byte
-    # order at the.
-    #
-    # If byteorder is NULL, the codec starts in native order mode.
-    object PyUnicode_DecodeUTF16(char *s, Py_ssize_t size, char *errors, int *byteorder)
-
-    # If consumed is NULL, behave like PyUnicode_DecodeUTF16(). If
-    # consumed is not NULL, PyUnicode_DecodeUTF16Stateful() will not
-    # treat trailing incomplete UTF-16 byte sequences (such as an odd
-    # number of bytes or a split surrogate pair) as an error. Those
-    # bytes will not be decoded and the number of bytes that have been
-    # decoded will be stored in consumed. New in version 2.4.
-    object PyUnicode_DecodeUTF16Stateful(char *s, Py_ssize_t size, char *errors, int *byteorder, Py_ssize_t *consumed)
-
-    # Return a Python string object holding the UTF-16 encoded value
-    # of the Unicode data in s. If byteorder is not 0, output is
-    # written according to the following byte order:
-    #
-    #   byteorder == -1: little endian
-    #   byteorder == 0:  native byte order (writes a BOM mark)
-    #   byteorder == 1:  big endian
-    #
-    # If byteorder is 0, the output string will always start with the
-    # Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark
-    # is prepended.
-    #
-    # If Py_UNICODE_WIDE is defined, a single Py_UNICODE value may get
-    # represented as a surrogate pair. If it is not defined, each
-    # Py_UNICODE values is interpreted as an UCS-2 character.
-    object PyUnicode_EncodeUTF16(Py_UNICODE *s, Py_ssize_t size, char *errors, int byteorder)
-
-    # Return a Python string using the UTF-16 encoding in native byte
-    # order. The string always starts with a BOM mark. Error handling
-    # is ``strict''. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_AsUTF16String(object unicode)
-
-# These are the ``Unicode Escape'' codec APIs:
-
-    # Create a Unicode object by decoding size bytes of the
-    # Unicode-Escape encoded string s. Return NULL if an exception was
-    # raised by the codec.
-    object PyUnicode_DecodeUnicodeEscape(char *s, Py_ssize_t size, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size using
-    # Unicode-Escape and return a Python string object. Return NULL if
-    # an exception was raised by the codec.
-    object PyUnicode_EncodeUnicodeEscape(Py_UNICODE *s, Py_ssize_t size)
-
-    # Encode a Unicode objects using Unicode-Escape and return the
-    # result as Python string object. Error handling is
-    # ``strict''. Return NULL if an exception was raised by the codec.
-    object PyUnicode_AsUnicodeEscapeString(object unicode)
-
-# These are the ``Raw Unicode Escape'' codec APIs:
-
-    # Create a Unicode object by decoding size bytes of the
-    # Raw-Unicode-Escape encoded string s. Return NULL if an exception
-    # was raised by the codec.
-    object PyUnicode_DecodeRawUnicodeEscape(char *s, Py_ssize_t size, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size using
-    # Raw-Unicode-Escape and return a Python string object. Return
-    # NULL if an exception was raised by the codec.
-    object PyUnicode_EncodeRawUnicodeEscape(Py_UNICODE *s, Py_ssize_t size, char *errors)
-
-    # Encode a Unicode objects using Raw-Unicode-Escape and return the
-    # result as Python string object. Error handling is
-    # ``strict''. Return NULL if an exception was raised by the codec.
-    object PyUnicode_AsRawUnicodeEscapeString(object unicode)
-
-# These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 Unicode ordinals and only these are accepted by the codecs during encoding.
-
-    # Create a Unicode object by decoding size bytes of the Latin-1
-    # encoded string s. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_DecodeLatin1(char *s, Py_ssize_t size, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size using Latin-1 and
-    # return a Python string object. Return NULL if an exception was
-    # raised by the codec.
-    object PyUnicode_EncodeLatin1(Py_UNICODE *s, Py_ssize_t size, char *errors)
-
-    # Encode a Unicode objects using Latin-1 and return the result as
-    # Python string object. Error handling is ``strict''. Return NULL
-    # if an exception was raised by the codec.
-    object PyUnicode_AsLatin1String(object unicode)
-
-# These are the ASCII codec APIs. Only 7-bit ASCII data is
-# accepted. All other codes generate errors.
-
-    # Create a Unicode object by decoding size bytes of the ASCII
-    # encoded string s. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_DecodeASCII(char *s, Py_ssize_t size, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size using ASCII and
-    # return a Python string object. Return NULL if an exception was
-    # raised by the codec.
-    object PyUnicode_EncodeASCII(Py_UNICODE *s, Py_ssize_t size, char *errors)
-
-    # Encode a Unicode objects using ASCII and return the result as
-    # Python string object. Error handling is ``strict''. Return NULL
-    # if an exception was raised by the codec.
-    object PyUnicode_AsASCIIString(object o)
-
-# These are the mapping codec APIs:
-#
-# This codec is special in that it can be used to implement many
-# different codecs (and this is in fact what was done to obtain most
-# of the standard codecs included in the encodings package). The codec
-# uses mapping to encode and decode characters.
-#
-# Decoding mappings must map single string characters to single
-# Unicode characters, integers (which are then interpreted as Unicode
-# ordinals) or None (meaning "undefined mapping" and causing an
-# error).
-#
-# Encoding mappings must map single Unicode characters to single
-# string characters, integers (which are then interpreted as Latin-1
-# ordinals) or None (meaning "undefined mapping" and causing an
-# error).
-#
-# The mapping objects provided must only support the __getitem__
-# mapping interface.
-#
-# If a character lookup fails with a LookupError, the character is
-# copied as-is meaning that its ordinal value will be interpreted as
-# Unicode or Latin-1 ordinal resp. Because of this, mappings only need
-# to contain those mappings which map characters to different code
-# points.
-
-    # Create a Unicode object by decoding size bytes of the encoded
-    # string s using the given mapping object. Return NULL if an
-    # exception was raised by the codec. If mapping is NULL latin-1
-    # decoding will be done. Else it can be a dictionary mapping byte
-    # or a unicode string, which is treated as a lookup table. Byte
-    # values greater that the length of the string and U+FFFE
-    # "characters" are treated as "undefined mapping". Changed in
-    # version 2.4: Allowed unicode string as mapping argument.
-    object PyUnicode_DecodeCharmap(char *s, Py_ssize_t size, object mapping, char *errors)
-
-    # Encode the Py_UNICODE buffer of the given size using the given
-    # mapping object and return a Python string object. Return NULL if
-    # an exception was raised by the codec.
-    object PyUnicode_EncodeCharmap(Py_UNICODE *s, Py_ssize_t size, object mapping, char *errors)
-
-    # Encode a Unicode objects using the given mapping object and
-    # return the result as Python string object. Error handling is
-    # ``strict''. Return NULL if an exception was raised by the codec.
-    object PyUnicode_AsCharmapString(object o, object mapping)
-
-# The following codec API is special in that maps Unicode to Unicode.
-
-    # Translate a Py_UNICODE buffer of the given length by applying a
-    # character mapping table to it and return the resulting Unicode
-    # object. Return NULL when an exception was raised by the codec.
-    #
-    # The mapping table must map Unicode ordinal integers to Unicode
-    # ordinal integers or None (causing deletion of the character).
-    #
-    # Mapping tables need only provide the __getitem__() interface;
-    # dictionaries and sequences work well. Unmapped character
-    # ordinals (ones which cause a LookupError) are left untouched and
-    # are copied as-is.
-    object PyUnicode_TranslateCharmap(Py_UNICODE *s, Py_ssize_t size,
-                                      object table, char *errors)
-
-# These are the MBCS codec APIs. They are currently only available on
-# Windows and use the Win32 MBCS converters to implement the
-# conversions. Note that MBCS (or DBCS) is a class of encodings, not
-# just one. The target encoding is defined by the user settings on the
-# machine running the codec.
-
-    # Create a Unicode object by decoding size bytes of the MBCS
-    # encoded string s. Return NULL if an exception was raised by the
-    # codec.
-    object PyUnicode_DecodeMBCS(char *s, Py_ssize_t size, char *errors)
-
-    # If consumed is NULL, behave like PyUnicode_DecodeMBCS(). If
-    # consumed is not NULL, PyUnicode_DecodeMBCSStateful() will not
-    # decode trailing lead byte and the number of bytes that have been
-    # decoded will be stored in consumed. New in version 2.5.
-    object PyUnicode_DecodeMBCSStateful(char *s, int size, char *errors, int *consumed)
-
-    # Encode the Py_UNICODE buffer of the given size using MBCS and
-    # return a Python string object. Return NULL if an exception was
-    # raised by the codec.
-    object PyUnicode_EncodeMBCS(Py_UNICODE *s, Py_ssize_t size, char *errors)
-
-    # Encode a Unicode objects using MBCS and return the result as
-    # Python string object. Error handling is ``strict''. Return NULL
-    # if an exception was raised by the codec.
-    object PyUnicode_AsMBCSString(object o)
+# Present for backwards compatability
+from cpython.unicode cimport *
diff --git a/Cython/Includes/python_version.pxd b/Cython/Includes/python_version.pxd
index e5aee0fb5e6c8c7d0acfffb459a0173fe3711f14..93aa7f37575cb4f8cf15e17ce1436fd6078800d9 100644
--- a/Cython/Includes/python_version.pxd
+++ b/Cython/Includes/python_version.pxd
@@ -1,32 +1,2 @@
-# Python version constants
-#
-# It's better to evaluate these at runtime (i.e. C compile time) using
-#
-#      if PY_MAJOR_VERSION >= 3:
-#           do_stuff_in_Py3_0_and_later()
-#      if PY_VERSION_HEX >= 0x02050000:
-#           do_stuff_in_Py2_5_and_later()
-#
-# than using the IF/DEF statements, which are evaluated at Cython
-# compile time.  This will keep your C code portable.
-
-
-cdef extern from *:
-    # the complete version, e.g. 0x010502B2 == 1.5.2b2
-    int PY_VERSION_HEX
-
-    # the individual sections as plain numbers
-    int PY_MAJOR_VERSION
-    int PY_MINOR_VERSION
-    int PY_MICRO_VERSION
-    int PY_RELEASE_LEVEL
-    int PY_RELEASE_SERIAL
-
-    # Note: PY_RELEASE_LEVEL is one of
-    #    0xA (alpha)
-    #    0xB (beta)
-    #    0xC (release candidate)
-    #    0xF (final)
-
-    char PY_VERSION[]
-    char PY_PATCHLEVEL_REVISION[]
+# Present for backwards compatability
+from cpython.version cimport *
diff --git a/Cython/Includes/python_weakref.pxd b/Cython/Includes/python_weakref.pxd
index 0611ffb3520649bb289fbd1aee763c7879978504..2337d093eb7586e075fae81fbbb2d667b5618c0d 100644
--- a/Cython/Includes/python_weakref.pxd
+++ b/Cython/Includes/python_weakref.pxd
@@ -1,42 +1,2 @@
-from python_ref cimport PyObject
-
-cdef extern from "Python.h":
-
-    bint PyWeakref_Check(object ob)
-    # Return true if ob is either a reference or proxy object.
-
-    bint PyWeakref_CheckRef(object ob)
-    # Return true if ob is a reference object.
-
-    bint PyWeakref_CheckProxy(ob)
-    # Return true if *ob* is a proxy object.
-
-    object PyWeakref_NewRef(object ob, object callback)
-    # Return a weak reference object for the object ob.  This will
-    # always return a new reference, but is not guaranteed to create a
-    # new object; an existing reference object may be returned.  The
-    # second parameter, callback, can be a callable object that
-    # receives notification when ob is garbage collected; it should
-    # accept a single parameter, which will be the weak reference
-    # object itself. callback may also be None or NULL.  If ob is not
-    # a weakly-referencable object, or if callback is not callable,
-    # None, or NULL, this will return NULL and raise TypeError.
-
-    object PyWeakref_NewProxy(object ob, object callback)
-    # Return a weak reference proxy object for the object ob.  This
-    # will always return a new reference, but is not guaranteed to
-    # create a new object; an existing proxy object may be returned.
-    # The second parameter, callback, can be a callable object that
-    # receives notification when ob is garbage collected; it should
-    # accept a single parameter, which will be the weak reference
-    # object itself. callback may also be None or NULL.  If ob is not
-    # a weakly-referencable object, or if callback is not callable,
-    # None, or NULL, this will return NULL and raise TypeError.
-
-    PyObject* PyWeakref_GetObject(object ref)
-    # Return the referenced object from a weak reference, ref.  If the
-    # referent is no longer live, returns None.
-
-    PyObject* PyWeakref_GET_OBJECT(object ref)
-    # Similar to PyWeakref_GetObject, but implemented as a macro that
-    # does no error checking.
+# Present for backwards compatability
+from cpython.weakref cimport *
diff --git a/Cython/Includes/stdio.pxd b/Cython/Includes/stdio.pxd
index cc574105f40fbacd47824afe947a6e6adfa4563a..f4af328d8f7dc90ac06d6b1841af82a5b8f5d744 100644
--- a/Cython/Includes/stdio.pxd
+++ b/Cython/Includes/stdio.pxd
@@ -1,9 +1,2 @@
-cdef extern from "stdio.h" nogil:
-    ctypedef struct FILE
-    int printf(char *format, ...)
-    int fprintf(FILE *stream, char *format, ...)
-    int sprintf(char *str, char *format, ...)
-    FILE *fopen(char *path, char *mode)
-    int fclose(FILE *strea)
-    cdef FILE *stdout
-    int scanf(char *format, ...)
+# Present for backwards compatability
+from libc.stdio cimport *
diff --git a/Cython/Includes/stdlib.pxd b/Cython/Includes/stdlib.pxd
index 40192d1352a7f26341ca7cd08aee0c77fb1f3834..0d2ce8eb3565e5c2ce20a85ad02a78be978a9bc6 100644
--- a/Cython/Includes/stdlib.pxd
+++ b/Cython/Includes/stdlib.pxd
@@ -1,7 +1,2 @@
-
-cdef extern from "stdlib.h" nogil:
-    void free(void *ptr)
-    void *malloc(size_t size)
-    void *realloc(void *ptr, size_t size)
-    size_t strlen(char *s)
-    char *strcpy(char *dest, char *src)
+# Present for backwards compatability
+from libc.stdlib cimport *
diff --git a/Cython/Plex/test_tm.py b/Cython/Plex/test_tm.py
deleted file mode 100644
index e08c9e68f930df0261628fc34ad64381d0300468..0000000000000000000000000000000000000000
--- a/Cython/Plex/test_tm.py
+++ /dev/null
@@ -1,24 +0,0 @@
-import sys
-sys.stderr = sys.stdout
-
-from TransitionMaps import TransitionMap
-
-m = TransitionMap()
-print m
-
-def add(c, s):
-  print
-  print "adding", repr(c), "-->", repr(s)
-  m.add_transition(c, s)
-  print m
-  print "keys:", m.keys()
-
-add('a','alpha')
-add('e', 'eta')
-add('f', 'foo')
-add('i', 'iota')
-add('i', 'imp')
-add('eol', 'elephant')
-
-
-
diff --git a/Cython/Runtime/refnanny.pyx b/Cython/Runtime/refnanny.pyx
index a7af253516b3d313848af7000fbac0b815637e91..63ad928a0fde459282cdb8629cd2e30c41ceda45 100644
--- a/Cython/Runtime/refnanny.pyx
+++ b/Cython/Runtime/refnanny.pyx
@@ -1,5 +1,5 @@
-from python_ref cimport Py_INCREF, Py_DECREF, Py_XDECREF
-from python_exc cimport PyObject, PyErr_Fetch, PyErr_Restore
+from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF, Py_XDECREF
+from cpython.exc cimport PyErr_Fetch, PyErr_Restore
 
 
 loglevel = 0
@@ -59,8 +59,11 @@ class Context(object):
         else:
             return None
 
-cdef void report_unraisable(object e):
+cdef void report_unraisable(object e=None):
     try:
+        if e is None:
+            import sys
+            e = sys.exc_info()[1]
         print u"refnanny raised an exception: %s" % e
     except:
         pass # We absolutely cannot exit with an exception
@@ -92,12 +95,16 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
     cdef PyObject* type = NULL, *value = NULL, *tb = NULL
     PyErr_Fetch(&type, &value, &tb)
     try:
-        if p_obj is NULL:
-            (<object>ctx).regref(None, lineno, True)
-        else:
-            (<object>ctx).regref(<object>p_obj, lineno, False)
-    except Exception, e:
-        report_unraisable(e)
+        try:
+            if p_obj is NULL:
+                (<object>ctx).regref(None, lineno, True)
+            else:
+                (<object>ctx).regref(<object>p_obj, lineno, False)
+        except:
+            report_unraisable()
+    except:
+        # __Pyx_GetException may itself raise errors
+        pass
     PyErr_Restore(type, value, tb)
 
 cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
@@ -106,12 +113,16 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
     cdef bint decref_ok = False
     PyErr_Fetch(&type, &value, &tb)
     try:
-        if p_obj is NULL:
-            decref_ok = (<object>ctx).delref(None, lineno, True)
-        else:
-            decref_ok = (<object>ctx).delref(<object>p_obj, lineno, False)
-    except Exception, e:
-        report_unraisable(e)
+        try:
+            if p_obj is NULL:
+                decref_ok = (<object>ctx).delref(None, lineno, True)
+            else:
+                decref_ok = (<object>ctx).delref(<object>p_obj, lineno, False)
+        except:
+            report_unraisable()
+    except:
+        # __Pyx_GetException may itself raise errors
+        pass
     PyErr_Restore(type, value, tb)
     return decref_ok
 
@@ -132,13 +143,17 @@ cdef void FinishContext(PyObject** ctx):
     cdef object errors = None
     PyErr_Fetch(&type, &value, &tb)
     try:
-        errors = (<object>ctx[0]).end()
-        pos = (<object>ctx[0]).filename, (<object>ctx[0]).name
-        if errors:
-            print u"%s: %s()" % pos
-            print errors
-    except Exception, e:
-        report_unraisable(e)
+        try:
+            errors = (<object>ctx[0]).end()
+            pos = (<object>ctx[0]).filename, (<object>ctx[0]).name
+            if errors:
+                print u"%s: %s()" % pos
+                print errors
+        except:
+            report_unraisable()
+    except:
+        # __Pyx_GetException may itself raise errors
+        pass
     Py_DECREF(<object>ctx[0])
     ctx[0] = NULL
     PyErr_Restore(type, value, tb)
diff --git a/Cython/Tests/xmlrunner.py b/Cython/Tests/xmlrunner.py
index 3b6e6ddfe76a68e956068f3d6bb63a81b8567026..a2054fc1f1bae06433d61a6b36bb7e3a2216205c 100644
--- a/Cython/Tests/xmlrunner.py
+++ b/Cython/Tests/xmlrunner.py
@@ -208,7 +208,9 @@ class _XMLTestResult(_TextTestResult):
         xml_testsuite.appendChild(testcase)
         
         testcase.setAttribute('classname', str(suite_name))
-        testcase.setAttribute('name', str(test_result.test_method.shortDescription() or test_result.test_method._testMethodName))
+        testcase.setAttribute('name', test_result.test_method.shortDescription()
+                              or getattr(test_result.test_method, '_testMethodName',
+                                         str(test_result.test_method)))
         testcase.setAttribute('time', '%.3f' % test_result.get_elapsed_time())
         
         if (test_result.outcome != _TestInfo.SUCCESS):
diff --git a/Demos/embed/Makefile b/Demos/embed/Makefile
index 5d05c4e2085bb6060afbec88a201566e9bb7b21c..0cdb7b44002dc83913692cdd780090deaf535201 100644
--- a/Demos/embed/Makefile
+++ b/Demos/embed/Makefile
@@ -1,7 +1,8 @@
 # Makefile for creating our standalone Cython program
-PYVERSION=$(shell python -c "import sys; print(sys.version[:3])")
-PYPREFIX=$(shell python -c "import sys; print(sys.prefix)")
-LINKFORSHARED=$(shell python -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LINKFORSHARED'))")
+PYTHON=python
+PYVERSION=$(shell $(PYTHON) -c "import sys; print(sys.version[:3])")
+PYPREFIX=$(shell $(PYTHON) -c "import sys; print(sys.prefix)")
+LINKFORSHARED=$(shell $(PYTHON) -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LINKFORSHARED'))")
 INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
 
 embedded: embedded.o
@@ -11,7 +12,7 @@ embedded.o: embedded.c
 	gcc -c $^ $(INCLUDES)
 
 embedded.c: embedded.pyx
-	@python ../../cython.py --embed embedded.pyx
+	@$(PYTHON) ../../cython.py --embed embedded.pyx
 
 all: embedded
 
@@ -21,4 +22,4 @@ clean:
 
 test: clean all
 	./embedded > test.output
-	python assert_equal.py embedded.output test.output
+	$(PYTHON) assert_equal.py embedded.output test.output
diff --git a/Makefile b/Makefile
index 337825cf1ded4bbc577c1066d287c4db623c6917..3b0d3cf61cdeae9974dc0f01dbd52d8f6d0d7483 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ repo: .hg
 clean:
 	@echo Cleaning Source
 	@rm -fr build
-	@rm -f *.pyc */*.pyc */*/*.pyc 
+	@rm -f *.py[co] */*.py[co] */*/*.py[co] */*/*/*.py[co]
 	@rm -f *.so */*.so */*/*.so 
 	@rm -f *.pyd */*.pyd */*/*.pyd 
 	@rm -f *~ */*~ */*/*~
diff --git a/runtests.py b/runtests.py
index f7a7c69bafbbffc7c9a05389847423bbfa050919..226bf9dd931956b51c22d0a1906ea73a9effb829 100644
--- a/runtests.py
+++ b/runtests.py
@@ -619,17 +619,24 @@ class EmbedTest(unittest.TestCase):
     def setUp(self):
         self.old_dir = os.getcwd()
         os.chdir(self.working_dir)
-        os.system("make clean > /dev/null")
+        os.system(
+            "make PYTHON='%s' clean > /dev/null" % sys.executable)
     
     def tearDown(self):
         try:
-            os.system("make clean > /dev/null")
+            os.system(
+                "make PYTHON='%s' clean > /dev/null" % sys.executable)
         except:
             pass
         os.chdir(self.old_dir)
         
     def test_embed(self):
-        self.assert_(os.system("make test > make.output") == 0)
+        self.assert_(os.system(
+            "make PYTHON='%s' test > make.output" % sys.executable) == 0)
+        try:
+            os.remove('make.output')
+        except OSError:
+            pass
 
 class MissingDependencyExcluder:
     def __init__(self, deps):
diff --git a/setup.py b/setup.py
index 9a9e02f37e35a1efaa5f110c22e5718083337965..6a3acdb9ae583ddfbc503bce0620f9a947ad59ed 100644
--- a/setup.py
+++ b/setup.py
@@ -3,9 +3,9 @@ from distutils.sysconfig import get_python_lib
 import os, os.path
 import sys
 
-if 'sdist' in sys.argv and sys.platform != "win32":
+if 'sdist' in sys.argv and sys.platform != "win32" and sys.version_info >= (2,4):
     # Record the current revision in .hgrev
-    import subprocess # os.popen is cleaner but depricated
+    import subprocess # os.popen is cleaner but deprecated
     changset = subprocess.Popen("hg log --rev tip | grep changeset", 
                                 shell=True,
                                 stdout=subprocess.PIPE).stdout.read()
@@ -14,10 +14,6 @@ if 'sdist' in sys.argv and sys.platform != "win32":
     hgrev.write(rev)
     hgrev.close()
 
-compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
-if sys.platform == "win32":
-    compiler_dir = compiler_dir[len(sys.prefix)+1:]
-
 if sys.platform == "darwin":
     # Don't create resource files on OS X tar.
     os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
@@ -41,23 +37,32 @@ if sys.version_info[0] >= 3:
     build_py.fixer_names = fixers
     add_command_class("build_py", build_py)
 
+pxd_packages = ['cpython', 'libc', 'libcpp']
 
 if sys.version_info < (2,4):
+    install_base_dir = get_python_lib(prefix='')
     import glob
-    cython_dir = os.path.join(get_python_lib(prefix=''), 'Cython')
-    compiler_dir = os.path.join(cython_dir, 'Compiler')
+    patterns = ['Cython/Includes/*.pxd',
+                'Cython/Plex/*.pxd',
+                'Cython/Compiler/*.pxd',
+                'Cython/Runtime/*.pyx']
+    for p in pxd_packages:
+        patterns.append('Cython/Includes/%s/*.pxd' % p)
+        patterns.append('Cython/Includes/%s/__init__.pyx' % p)
     setup_args['data_files'] = [
-        (cython_dir, [ f for pattern in
-                       ['Cython/Includes/*.pxd',
-                        'Cython/Plex/*.pxd',
-                        'Cython/Compiler/*.pxd',
-                        'Cython/Runtime/*.pyx']
-                       for f in glob.glob(pattern) ])]
+        (os.path.dirname(os.path.join(install_base_dir, pattern)),
+         [ f for f in glob.glob(pattern) ])
+        for pattern in patterns
+        ]
 else:
-    setup_args['package_data'] = {'Cython' : ['Includes/*.pxd',
-                                              'Plex/*.pxd',
-                                              'Compiler/*.pxd',
-                                              'Runtime/*.pyx']}
+    patterns = ['Includes/*.pxd',
+                'Plex/*.pxd',
+                'Compiler/*.pxd',
+                'Runtime/*.pyx']
+    for p in pxd_packages:
+        patterns.append('Includes/%s/*.pxd' % p)
+        patterns.append('Includes/%s/__init__.pyx' % p)
+    setup_args['package_data'] = {'Cython' : patterns}
 
 # This dict is used for passing extra arguments that are setuptools 
 # specific to setup
diff --git a/tests/compile/extpymemberdef.pyx b/tests/compile/extpymemberdef.pyx
index 58a62a38789d570450732a8beecf6baa21bf9d50..61bf6d1b9a60eb03ce39ef23204c39f3f99fba81 100644
--- a/tests/compile/extpymemberdef.pyx
+++ b/tests/compile/extpymemberdef.pyx
@@ -8,7 +8,7 @@ cdef class Spam:
     cdef public float f
     cdef public double d
     cdef public char *s
-    cdef public char a[42]
+    cdef readonly char a[42]
     cdef public object o
     cdef readonly int r
     cdef readonly Spam e
diff --git a/tests/errors/cdef_members_T517.pyx b/tests/errors/cdef_members_T517.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..ee95a4081ef7a73f1cc1b7cb7b18e21d19536403
--- /dev/null
+++ b/tests/errors/cdef_members_T517.pyx
@@ -0,0 +1,26 @@
+ctypedef void* VoidP
+
+cdef class Spam:
+    cdef          VoidP vp0
+    cdef readonly VoidP vp2
+    cdef public   VoidP vp1
+
+ctypedef struct Foo:
+    int i
+
+cdef class Bar:
+    cdef          Foo foo0
+    cdef readonly Foo foo2
+    cdef public   Foo foo1
+    pass
+
+_ERRORS = u"""
+5:24: C attribute of type 'VoidP' cannot be accessed from Python
+5:24: Cannot convert 'VoidP' to Python object
+6:24: C attribute of type 'VoidP' cannot be accessed from Python
+6:24: Cannot convert 'VoidP' to Python object
+6:24: Cannot convert Python object to 'VoidP'
+14:22: C attribute of type 'Foo' cannot be accessed from Python
+14:22: Cannot convert Python object to 'Foo'
+"""
+
diff --git a/tests/errors/e_extweakref.pyx b/tests/errors/e_extweakref.pyx
index 6ce4cf3c3cf1e72ce0274a90efd0383e2fef992c..8354dcb5f85bf338e3c77bce4ecb6e306d58c7fa 100644
--- a/tests/errors/e_extweakref.pyx
+++ b/tests/errors/e_extweakref.pyx
@@ -13,7 +13,10 @@ cdef void f():
 	x = c.__weakref__
 	c.__weakref__ = x
 _ERRORS = u"""
+5:20: Illegal use of special attribute __weakref__
+5:20: Illegal use of special attribute __weakref__
 5:20: Special attribute __weakref__ cannot be exposed to Python
+8:22: Illegal use of special attribute __weakref__
 8:22: Special attribute __weakref__ cannot be exposed to Python
 13:6: Illegal use of special attribute __weakref__
 14:2: Illegal use of special attribute __weakref__
diff --git a/tests/run/cdef_members_T517.pyx b/tests/run/cdef_members_T517.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..229968178fa727e52c502764836042ee360cab59
--- /dev/null
+++ b/tests/run/cdef_members_T517.pyx
@@ -0,0 +1,134 @@
+#cython: embedsignature=True
+__doc__ = u"""
+>>> a = A()
+>>> a.h = 7
+>>> a.i = 127
+>>> a.l = 255
+>>> a.q = 255
+>>> a.f = 1.0/2.0
+>>> a.d = 1/2.0 + 1/4.0
+>>> a.g = 1/2.0 + 1/4.0 + 1/8.0
+>>> a.Zf = 1+2j
+>>> a.Zd = 3+4j
+>>> a.Zg = 5+6j
+
+>>> a.h, a.i, a.l
+(7, 127, 255)
+>>> a.ro_h, a.ro_i, a.ro_l
+(7, 127, 255)
+>>> a.f, a.d, a.g
+(0.5, 0.75, 0.875)
+>>> a.ro_f, a.ro_d, a.ro_g
+(0.5, 0.75, 0.875)
+>>> a.Zf, a.Zd, a.Zg
+((1+2j), (3+4j), (5+6j))
+>>> a.ro_Zf, a.ro_Zd, a.ro_Zg
+((1+2j), (3+4j), (5+6j))
+
+>>> b = B()
+>>> b.a0 #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+>>> b.b0 #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+>>> b.c0 #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+
+>>> isinstance(b.a1, type(None))
+True
+>>> isinstance(b.a2, type(None))
+True
+>>> isinstance(b.b1, list)
+True
+>>> isinstance(b.b2, list)
+True
+>>> isinstance(b.c1, A)
+True
+>>> isinstance(b.c2, A)
+True
+
+>>> b.a1 = a
+>>> b.a1 is not b.a2
+True
+
+>>> b.b1 = 1 #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+TypeError: ...
+>>> b.c1 = 1 #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+TypeError: ...
+>>> b.a2 = None #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+>>> b.b2 = [] #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+>>> b.c2 = A() #doctest: +ELLIPSIS
+Traceback (most recent call last):
+    ...
+AttributeError: ...
+"""
+
+cdef class A:
+
+    cdef public short h
+    cdef public int i
+    cdef public long l
+    cdef public long long q
+    cdef public float f
+    cdef public double d
+    cdef public long double g
+    cdef public float complex Zf
+    cdef public double complex Zd
+    cdef public long double complex Zg
+
+    cdef readonly short ro_h
+    cdef readonly int ro_i
+    cdef readonly long ro_l
+    cdef readonly long long ro_q
+    cdef readonly float ro_f
+    cdef readonly double ro_d
+    cdef readonly long double ro_g
+    cdef readonly float complex ro_Zf
+    cdef readonly double complex ro_Zd
+    cdef readonly long double complex ro_Zg
+
+    def __cinit__(self):
+        self.ro_h = 7
+        self.ro_i = 127
+        self.ro_l = 255
+        self.ro_q = 255
+        self.ro_f = 1.0/2.0
+        self.ro_d = 1/2.0 + 1/4.0
+        self.ro_g = 1/2.0 + 1/4.0 + 1/8.0
+        self.ro_Zf = 1+2j
+        self.ro_Zd = 3+4j
+        self.ro_Zg = 5+6j
+
+
+cdef class B:
+
+    cdef object a0
+    cdef public object a1
+    cdef readonly object a2
+
+    cdef list b0
+    cdef public list b1
+    cdef readonly list b2
+
+    cdef A c0
+    cdef public A c1
+    cdef readonly A c2
+
+    def __cinit__(self):
+        self.b0 = self.b1 = self.b2 = []
+        self.c0 = self.c1 = self.c2 = A()
diff --git a/tests/run/cython_includes.pyx b/tests/run/cython_includes.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..ddaec586942cc349f228eaee90a388922dea9c32
--- /dev/null
+++ b/tests/run/cython_includes.pyx
@@ -0,0 +1,32 @@
+
+from libc.stdio cimport sprintf
+from python cimport PyType_Check
+from python_type cimport PyType_Check as PyType_Check2
+from cpython.type cimport PyType_Check as PyType_Check3
+
+def libc_cimports():
+    """
+    >>> libc_cimports()
+    hello
+    """
+    cdef char buf[10]
+    sprintf(buf, b'hello')
+    print (<object>buf).decode('ASCII')
+
+def cpython_cimports():
+    """
+    >>> cpython_cimports()
+    True
+    False
+    True
+    False
+    True
+    False
+    """
+    print PyType_Check(list)
+    print PyType_Check([])
+    print PyType_Check2(list)
+    print PyType_Check2([])
+    print PyType_Check3(list)
+    print PyType_Check3([])
+    
diff --git a/tests/run/embedsignatures.pyx b/tests/run/embedsignatures.pyx
index 3fafdbedadb4692bfd8322b5f0da75294e468cac..0bfcdcadd213067979ab7e95f7f03f9eff8ddc88 100644
--- a/tests/run/embedsignatures.pyx
+++ b/tests/run/embedsignatures.pyx
@@ -5,6 +5,15 @@ __doc__ = ur"""
     >>> print (Ext.__doc__)
     Ext(a, b, c=None)
 
+    >>> print (Ext.attr0.__doc__)
+    attr0: 'int'
+    >>> print (Ext.attr1.__doc__)
+    attr1: object
+    >>> print (Ext.attr2.__doc__)
+    attr2: list
+    >>> print (Ext.attr3.__doc__)
+    attr3: embedsignatures.Ext
+
     >>> print (Ext.a.__doc__)
     Ext.a(self)
 
@@ -145,6 +154,11 @@ __doc__ = ur"""
 
 cdef class Ext:
 
+    cdef public int  attr0
+    cdef public      attr1
+    cdef public list attr2
+    cdef public Ext  attr3
+
     def __init__(self, a, b, c=None):
         pass
 
diff --git a/tests/run/typedfieldbug_T303.pyx b/tests/run/typedfieldbug_T303.pyx
index 82094d4be87dd2a565e1cee4f84e24bb133fbcb9..653fa513a35af322ddf046c05c43464280416d82 100644
--- a/tests/run/typedfieldbug_T303.pyx
+++ b/tests/run/typedfieldbug_T303.pyx
@@ -1,12 +1,12 @@
 __doc__ = """
->>> readonly()
+>>> readonly() #doctest: +ELLIPSIS
 Traceback (most recent call last):
-...
-TypeError: readonly attribute
+    ...
+TypeError: ...
 """
 
 import sys
-if sys.version_info[0] >= 3:
+if sys.version_info[0:2] >= (2,4):
     __doc__ = __doc__.replace(u'TypeError:', u'AttributeError:')
 
 
@@ -51,9 +51,7 @@ def f():
 def longdouble_access():
     """
     >>> longdouble_access()
-    Traceback (most recent call last):
-    ...
-    SystemError: bad memberdescr type
+    42.0
     """
     cdef object c = MyClass()
     print c.float_isreally_longdouble