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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
fd11571a
Commit
fd11571a
authored
Nov 07, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify some builtin method optimisations
parent
a69b00fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
28 deletions
+19
-28
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+4
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+0
-27
tests/run/list.pyx
tests/run/list.pyx
+15
-0
No files found.
Cython/Compiler/Builtin.py
View file @
fd11571a
...
@@ -112,7 +112,10 @@ builtin_types_table = [
...
@@ -112,7 +112,10 @@ builtin_types_table = [
(
"tuple"
,
"PyTuple_Type"
,
[]),
(
"tuple"
,
"PyTuple_Type"
,
[]),
(
"list"
,
"PyList_Type"
,
[(
"insert"
,
"TzO"
,
"i"
,
"PyList_Insert"
)]),
(
"list"
,
"PyList_Type"
,
[(
"insert"
,
"TzO"
,
"i"
,
"PyList_Insert"
),
(
"reverse"
,
"T"
,
"i"
,
"PyList_Reverse"
),
(
"append"
,
"TO"
,
"i"
,
"PyList_Append"
),
]),
(
"dict"
,
"PyDict_Type"
,
[(
"items"
,
"T"
,
"O"
,
"PyDict_Items"
),
(
"dict"
,
"PyDict_Type"
,
[(
"items"
,
"T"
,
"O"
,
"PyDict_Items"
),
(
"keys"
,
"T"
,
"O"
,
"PyDict_Keys"
),
(
"keys"
,
"T"
,
"O"
,
"PyDict_Keys"
),
...
...
Cython/Compiler/Optimize.py
View file @
fd11571a
...
@@ -2063,23 +2063,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -2063,23 +2063,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
_handle_simple_method_list_pop
=
_handle_simple_method_object_pop
_handle_simple_method_list_pop
=
_handle_simple_method_object_pop
PyList_Append_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"list"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"item"
,
PyrexTypes
.
py_object_type
,
None
),
],
exception_value
=
"-1"
)
def
_handle_simple_method_list_append
(
self
,
node
,
args
,
is_unbound_method
):
"""Call PyList_Append() instead of l.append().
"""
if
len
(
args
)
!=
2
:
self
.
_error_wrong_arg_count
(
'list.append'
,
node
,
args
,
2
)
return
node
return
self
.
_substitute_method_call
(
node
,
"PyList_Append"
,
self
.
PyList_Append_func_type
,
'append'
,
is_unbound_method
,
args
)
single_param_func_type
=
PyrexTypes
.
CFuncType
(
single_param_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
c_int_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"obj"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"obj"
,
PyrexTypes
.
py_object_type
,
None
),
...
@@ -2095,16 +2078,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -2095,16 +2078,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
node
,
"PyList_Sort"
,
self
.
single_param_func_type
,
node
,
"PyList_Sort"
,
self
.
single_param_func_type
,
'sort'
,
is_unbound_method
,
args
)
'sort'
,
is_unbound_method
,
args
)
def
_handle_simple_method_list_reverse
(
self
,
node
,
args
,
is_unbound_method
):
"""Call PyList_Reverse() instead of l.reverse().
"""
if
len
(
args
)
!=
1
:
self
.
_error_wrong_arg_count
(
'list.reverse'
,
node
,
args
,
1
)
return
node
return
self
.
_substitute_method_call
(
node
,
"PyList_Reverse"
,
self
.
single_param_func_type
,
'reverse'
,
is_unbound_method
,
args
)
Pyx_PyDict_GetItem_func_type
=
PyrexTypes
.
CFuncType
(
Pyx_PyDict_GetItem_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"dict"
,
PyrexTypes
.
py_object_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"dict"
,
PyrexTypes
.
py_object_type
,
None
),
...
...
tests/run/list.pyx
View file @
fd11571a
cimport
cython
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
"""
"""
>>> f(1, 2, 3, 4, 5)
>>> f(1, 2, 3, 4, 5)
...
@@ -54,6 +57,7 @@ def test_list_sort_reversed():
...
@@ -54,6 +57,7 @@ def test_list_sort_reversed():
l1
.
sort
(
reversed
=
True
)
l1
.
sort
(
reversed
=
True
)
return
l1
return
l1
@
cython
.
test_assert_path_exists
(
"//SimpleCallNode//NoneCheckNode"
)
def
test_list_reverse
():
def
test_list_reverse
():
"""
"""
>>> test_list_reverse()
>>> test_list_reverse()
...
@@ -64,6 +68,17 @@ def test_list_reverse():
...
@@ -64,6 +68,17 @@ def test_list_reverse():
l1
.
reverse
()
l1
.
reverse
()
return
l1
return
l1
@
cython
.
test_assert_path_exists
(
"//SimpleCallNode//NoneCheckNode"
)
def
test_list_append
():
"""
>>> test_list_append()
[1, 2, 3, 4]
"""
cdef
list
l1
=
[
1
,
2
]
l1
.
append
(
3
)
l1
.
append
(
4
)
return
l1
def
test_list_pop
():
def
test_list_pop
():
"""
"""
>>> test_list_pop()
>>> test_list_pop()
...
...
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