Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5c5f0717
Commit
5c5f0717
authored
Sep 18, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rolled back accidentally committed files
parent
411a6354
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
61 deletions
+17
-61
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+2
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+15
-55
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+0
-3
tests/bugs.txt
tests/bugs.txt
+0
-1
No files found.
Cython/Compiler/Builtin.py
View file @
5c5f0717
...
@@ -21,7 +21,7 @@ builtin_function_table = [
...
@@ -21,7 +21,7 @@ builtin_function_table = [
#('eval', "", "", ""),
#('eval', "", "", ""),
#('execfile', "", "", ""),
#('execfile', "", "", ""),
#('filter', "", "", ""),
#('filter', "", "", ""),
#('getattr', "OO", "O", "PyObject_GetAttr"), #
optimised later on
#('getattr', "OO", "O", "PyObject_GetAttr"), # optimised later on
(
'getattr3'
,
"OOO"
,
"O"
,
"__Pyx_GetAttr3"
,
"getattr"
),
(
'getattr3'
,
"OOO"
,
"O"
,
"__Pyx_GetAttr3"
,
"getattr"
),
(
'hasattr'
,
"OO"
,
"b"
,
"PyObject_HasAttr"
),
(
'hasattr'
,
"OO"
,
"b"
,
"PyObject_HasAttr"
),
(
'hash'
,
"O"
,
"l"
,
"PyObject_Hash"
),
(
'hash'
,
"O"
,
"l"
,
"PyObject_Hash"
),
...
@@ -29,7 +29,7 @@ builtin_function_table = [
...
@@ -29,7 +29,7 @@ builtin_function_table = [
#('id', "", "", ""),
#('id', "", "", ""),
#('input', "", "", ""),
#('input', "", "", ""),
(
'intern'
,
"s"
,
"O"
,
"__Pyx_InternFromString"
),
(
'intern'
,
"s"
,
"O"
,
"__Pyx_InternFromString"
),
#('isinstance', "OO", "b", "PyObject_IsInstance"), # optimised later on
(
'isinstance'
,
"OO"
,
"b"
,
"PyObject_IsInstance"
),
(
'issubclass'
,
"OO"
,
"b"
,
"PyObject_IsSubclass"
),
(
'issubclass'
,
"OO"
,
"b"
,
"PyObject_IsSubclass"
),
(
'iter'
,
"O"
,
"O"
,
"PyObject_GetIter"
),
(
'iter'
,
"O"
,
"O"
,
"PyObject_GetIter"
),
(
'len'
,
"O"
,
"Z"
,
"PyObject_Length"
),
(
'len'
,
"O"
,
"Z"
,
"PyObject_Length"
),
...
...
Cython/Compiler/Optimize.py
View file @
5c5f0717
...
@@ -712,41 +712,6 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform):
...
@@ -712,41 +712,6 @@ class OptimizeBuiltinCalls(Visitor.VisitorTransform):
"expected 2 or 3, found %d"
%
len
(
args
))
"expected 2 or 3, found %d"
%
len
(
args
))
return
node
return
node
PyObject_TypeCheck_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_bint_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"obj"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"type"
,
PyrexTypes
.
c_py_type_object_ptr_type
,
None
),
])
PyObject_IsInstance_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_bint_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"obj"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"type"
,
PyrexTypes
.
py_object_type
,
None
),
])
def
_handle_simple_function_isinstance
(
self
,
node
,
pos_args
):
"""Replace generic calls to isinstance(x, type) by a more
efficient type check.
"""
args
=
pos_args
.
args
if
len
(
args
)
!=
2
:
error
(
node
.
pos
,
"isinstance(x, type) called with wrong number of args, found %d"
%
len
(
args
))
return
node
type_arg
=
args
[
1
]
if
type_arg
.
type
is
Builtin
.
type_type
:
function_name
=
"PyObject_TypeCheck"
function_type
=
self
.
PyObject_TypeCheck_func_type
args
[
1
]
=
ExprNodes
.
CastNode
(
type_arg
,
PyrexTypes
.
c_py_type_object_ptr_type
)
else
:
function_name
=
"PyObject_IsInstance"
function_type
=
self
.
PyObject_IsInstance_func_type
return
ExprNodes
.
PythonCapiCallNode
(
node
.
pos
,
function_name
,
function_type
,
args
=
args
,
is_temp
=
node
.
is_temp
)
Pyx_Type_func_type
=
PyrexTypes
.
CFuncType
(
Pyx_Type_func_type
=
PyrexTypes
.
CFuncType
(
Builtin
.
type_type
,
[
Builtin
.
type_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
)
PyrexTypes
.
CFuncTypeArg
(
"object"
,
PyrexTypes
.
py_object_type
,
None
)
...
@@ -1093,8 +1058,8 @@ class FinalOptimizePhase(Visitor.CythonTransform):
...
@@ -1093,8 +1058,8 @@ class FinalOptimizePhase(Visitor.CythonTransform):
just before the C code generation phase.
just before the C code generation phase.
The optimizations currently implemented in this class are:
The optimizations currently implemented in this class are:
- Eliminate None assignment and refcounting for first assignment.
- Eliminate None assignment and refcounting for first assignment.
-
Eliminate dead coercion nodes.
-
isinstance -> typecheck for cdef types
"""
"""
def
visit_SingleAssignmentNode
(
self
,
node
):
def
visit_SingleAssignmentNode
(
self
,
node
):
"""Avoid redundant initialisation of local variables before their
"""Avoid redundant initialisation of local variables before their
...
@@ -1110,23 +1075,18 @@ class FinalOptimizePhase(Visitor.CythonTransform):
...
@@ -1110,23 +1075,18 @@ class FinalOptimizePhase(Visitor.CythonTransform):
lhs
.
entry
.
init
=
0
lhs
.
entry
.
init
=
0
return
node
return
node
def
visit_NoneCheckNode
(
self
,
node
):
def
visit_SimpleCallNode
(
self
,
node
):
"""Remove NoneCheckNode nodes wrapping nodes that cannot
"""Replace generic calls to isinstance(x, type) by a more efficient
possibly be None.
type check.
FIXME: the list below might be better maintained as a node
class attribute...
"""
"""
target
=
node
.
arg
self
.
visitchildren
(
node
)
if
isinstance
(
target
,
ExprNodes
.
NoneNode
):
if
node
.
function
.
type
.
is_cfunction
and
isinstance
(
node
.
function
,
ExprNodes
.
NameNode
):
return
node
if
node
.
function
.
name
==
'isinstance'
:
if
not
target
.
type
.
is_pyobject
:
type_arg
=
node
.
args
[
1
]
return
target
if
type_arg
.
type
.
is_builtin_type
and
type_arg
.
type
.
name
==
'type'
:
if
isinstance
(
target
,
(
ExprNodes
.
ConstNode
,
from
CythonScope
import
utility_scope
ExprNodes
.
NumBinopNode
)):
node
.
function
.
entry
=
utility_scope
.
lookup
(
'PyObject_TypeCheck'
)
return
target
node
.
function
.
type
=
node
.
function
.
entry
.
type
if
isinstance
(
target
,
(
ExprNodes
.
SequenceNode
,
PyTypeObjectPtr
=
PyrexTypes
.
CPtrType
(
utility_scope
.
lookup
(
'PyTypeObject'
).
type
)
ExprNodes
.
ComprehensionNode
,
node
.
args
[
1
]
=
ExprNodes
.
CastNode
(
node
.
args
[
1
],
PyTypeObjectPtr
)
ExprNodes
.
SetNode
,
ExprNodes
.
DictNode
)):
return
target
return
node
return
node
Cython/Compiler/PyrexTypes.py
View file @
5c5f0717
...
@@ -1691,9 +1691,6 @@ c_anon_enum_type = CAnonEnumType(-1, 1)
...
@@ -1691,9 +1691,6 @@ c_anon_enum_type = CAnonEnumType(-1, 1)
c_py_buffer_type
=
CStructOrUnionType
(
"Py_buffer"
,
"struct"
,
None
,
1
,
"Py_buffer"
)
c_py_buffer_type
=
CStructOrUnionType
(
"Py_buffer"
,
"struct"
,
None
,
1
,
"Py_buffer"
)
c_py_buffer_ptr_type
=
CPtrType
(
c_py_buffer_type
)
c_py_buffer_ptr_type
=
CPtrType
(
c_py_buffer_type
)
c_py_type_object_type
=
CStructOrUnionType
(
"PyTypeObject"
,
"struct"
,
None
,
1
,
"PyTypeObject"
)
c_py_type_object_ptr_type
=
CPtrType
(
c_py_type_object_type
)
error_type
=
ErrorType
()
error_type
=
ErrorType
()
unspecified_type
=
UnspecifiedType
()
unspecified_type
=
UnspecifiedType
()
...
...
tests/bugs.txt
View file @
5c5f0717
...
@@ -8,7 +8,6 @@ unsignedbehaviour_T184
...
@@ -8,7 +8,6 @@ unsignedbehaviour_T184
funcexc_iter_T228
funcexc_iter_T228
bad_c_struct_T252
bad_c_struct_T252
missing_baseclass_in_predecl_T262
missing_baseclass_in_predecl_T262
compile_time_unraisable_T370
# Not yet enabled
# Not yet enabled
profile_test
profile_test
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment