[Cython] PATCH: population of builtin types for 'isinstance' optimization
author"Lisandro Dalcin" <dalcinl@gmail.com>
Tue, 30 Sep 2008 18:14:06 +0000 (11:14 -0700)
committer"Lisandro Dalcin" <dalcinl@gmail.com>
Tue, 30 Sep 2008 18:14:06 +0000 (11:14 -0700)
Cython/Compiler/Builtin.py
Cython/Compiler/Symtab.py

index b7d3f1bf820c7d0641ff0f34f1962645b6d0e529..89ca0f97ba0c3e969f6f9da42d30534434f7dbe7 100644 (file)
@@ -83,23 +83,34 @@ builtin_function_table = [
 builtin_types_table = [
 
     ("type",    "PyType_Type",     []),
-#    ("str",     "PyBytes_Type",   []),
+
+    ("bool",    "PyBool_Type",     []),
+    ("int",     "PyInt_Type",      []),
+    ("long",    "PyLong_Type",     []),
+    ("float",   "PyFloat_Type",    []),
+    ("complex", "PyComplex_Type",  []),
+
+    ("bytes",   "PyBytes_Type",    []),
+    ("str",     "PyString_Type",   []),
     ("unicode", "PyUnicode_Type",  []),
-    ("file",    "PyFile_Type",     []),
-#    ("slice",   "PySlice_Type",    []),
-#    ("set",     "PySet_Type",      []),
-    ("frozenset", "PyFrozenSet_Type",   []),
 
     ("tuple",   "PyTuple_Type",    []),
-    
+
     ("list",    "PyList_Type",     [("append", "OO",   "i", "PyList_Append"),
                                     ("insert", "OiO",  "i", "PyList_Insert"),
                                     ("sort",   "O",    "i", "PyList_Sort"),
                                     ("reverse","O",    "i", "PyList_Reverse")]),
-                                    
+
     ("dict",    "PyDict_Type",     [("items", "O",   "O", "PyDict_Items"),
                                     ("keys",  "O",   "O", "PyDict_Keys"),
                                     ("values","O",   "O", "PyDict_Values")]),
+
+    ("set",       "PySet_Type",       []),
+    ("frozenset", "PyFrozenSet_Type", []),
+
+    ("slice",   "PySlice_Type",    []),
+    ("file",    "PyFile_Type",     []),
+
 ]
 
 builtin_structs_table = [
index ec41d83d64c1682a3350b7371f60945517483690..759a566a7c8830fbda6888a3684363e385760297 100644 (file)
@@ -719,21 +719,27 @@ class BuiltinScope(Scope):
 
     def builtin_scope(self):
         return self
-        
+
     builtin_entries = {
+
+        "type":   ["((PyObject*)&PyType_Type)", py_object_type],
+
+        "bool":   ["((PyObject*)&PyBool_Type)", py_object_type],
         "int":    ["((PyObject*)&PyInt_Type)", py_object_type],
         "long":   ["((PyObject*)&PyLong_Type)", py_object_type],
         "float":  ["((PyObject*)&PyFloat_Type)", py_object_type],
-        
-        "str":    ["((PyObject*)&PyBytes_Type)", py_object_type],
+        "complex":["((PyObject*)&PyComplex_Type)", py_object_type],
+
+        "bytes":  ["((PyObject*)&PyBytes_Type)", py_object_type],
+        "str":    ["((PyObject*)&PyString_Type)", py_object_type],
         "unicode":["((PyObject*)&PyUnicode_Type)", py_object_type],
+
         "tuple":  ["((PyObject*)&PyTuple_Type)", py_object_type],
         "list":   ["((PyObject*)&PyList_Type)", py_object_type],
         "dict":   ["((PyObject*)&PyDict_Type)", py_object_type],
         "set":    ["((PyObject*)&PySet_Type)", py_object_type],
         "frozenset":   ["((PyObject*)&PyFrozenSet_Type)", py_object_type],
-        
-        "type":   ["((PyObject*)&PyType_Type)", py_object_type],
+
         "slice":  ["((PyObject*)&PySlice_Type)", py_object_type],
         "file":   ["((PyObject*)&PyFile_Type)", py_object_type],