cython-devel
changeset 1187:897597836a72
[Cython] PATCH: population of builtin types for 'isinstance' optimization
| author | "Lisandro Dalcin" <dalcinl@gmail.com> |
|---|---|
| date | Tue Sep 30 11:14:06 2008 -0700 (3 years ago) |
| parents | 49a5a04effce |
| children | c26fb25a899b |
| files | Cython/Compiler/Builtin.py Cython/Compiler/Symtab.py |
line diff
1.1 --- a/Cython/Compiler/Builtin.py Tue Sep 30 00:26:31 2008 -0700
1.2 +++ b/Cython/Compiler/Builtin.py Tue Sep 30 11:14:06 2008 -0700
1.3 @@ -83,23 +83,34 @@
1.4 builtin_types_table = [
1.5
1.6 ("type", "PyType_Type", []),
1.7 -# ("str", "PyBytes_Type", []),
1.8 +
1.9 + ("bool", "PyBool_Type", []),
1.10 + ("int", "PyInt_Type", []),
1.11 + ("long", "PyLong_Type", []),
1.12 + ("float", "PyFloat_Type", []),
1.13 + ("complex", "PyComplex_Type", []),
1.14 +
1.15 + ("bytes", "PyBytes_Type", []),
1.16 + ("str", "PyString_Type", []),
1.17 ("unicode", "PyUnicode_Type", []),
1.18 - ("file", "PyFile_Type", []),
1.19 -# ("slice", "PySlice_Type", []),
1.20 -# ("set", "PySet_Type", []),
1.21 - ("frozenset", "PyFrozenSet_Type", []),
1.22
1.23 ("tuple", "PyTuple_Type", []),
1.24 -
1.25 +
1.26 ("list", "PyList_Type", [("append", "OO", "i", "PyList_Append"),
1.27 ("insert", "OiO", "i", "PyList_Insert"),
1.28 ("sort", "O", "i", "PyList_Sort"),
1.29 ("reverse","O", "i", "PyList_Reverse")]),
1.30 -
1.31 +
1.32 ("dict", "PyDict_Type", [("items", "O", "O", "PyDict_Items"),
1.33 ("keys", "O", "O", "PyDict_Keys"),
1.34 ("values","O", "O", "PyDict_Values")]),
1.35 +
1.36 + ("set", "PySet_Type", []),
1.37 + ("frozenset", "PyFrozenSet_Type", []),
1.38 +
1.39 + ("slice", "PySlice_Type", []),
1.40 + ("file", "PyFile_Type", []),
1.41 +
1.42 ]
1.43
1.44 builtin_structs_table = [
2.1 --- a/Cython/Compiler/Symtab.py Tue Sep 30 00:26:31 2008 -0700
2.2 +++ b/Cython/Compiler/Symtab.py Tue Sep 30 11:14:06 2008 -0700
2.3 @@ -719,21 +719,27 @@
2.4
2.5 def builtin_scope(self):
2.6 return self
2.7 -
2.8 +
2.9 builtin_entries = {
2.10 +
2.11 + "type": ["((PyObject*)&PyType_Type)", py_object_type],
2.12 +
2.13 + "bool": ["((PyObject*)&PyBool_Type)", py_object_type],
2.14 "int": ["((PyObject*)&PyInt_Type)", py_object_type],
2.15 "long": ["((PyObject*)&PyLong_Type)", py_object_type],
2.16 "float": ["((PyObject*)&PyFloat_Type)", py_object_type],
2.17 -
2.18 - "str": ["((PyObject*)&PyBytes_Type)", py_object_type],
2.19 + "complex":["((PyObject*)&PyComplex_Type)", py_object_type],
2.20 +
2.21 + "bytes": ["((PyObject*)&PyBytes_Type)", py_object_type],
2.22 + "str": ["((PyObject*)&PyString_Type)", py_object_type],
2.23 "unicode":["((PyObject*)&PyUnicode_Type)", py_object_type],
2.24 +
2.25 "tuple": ["((PyObject*)&PyTuple_Type)", py_object_type],
2.26 "list": ["((PyObject*)&PyList_Type)", py_object_type],
2.27 "dict": ["((PyObject*)&PyDict_Type)", py_object_type],
2.28 "set": ["((PyObject*)&PySet_Type)", py_object_type],
2.29 "frozenset": ["((PyObject*)&PyFrozenSet_Type)", py_object_type],
2.30 -
2.31 - "type": ["((PyObject*)&PyType_Type)", py_object_type],
2.32 +
2.33 "slice": ["((PyObject*)&PySlice_Type)", py_object_type],
2.34 "file": ["((PyObject*)&PyFile_Type)", py_object_type],
2.35
