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
ae62e5ee
Commit
ae62e5ee
authored
Jul 24, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable previously unused optimisation code for bytes iteration (found via coverage analysis)
parent
33af5045
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-1
tests/run/carray_slicing.pyx
tests/run/carray_slicing.pyx
+15
-0
No files found.
Cython/Compiler/Optimize.py
View file @
ae62e5ee
...
@@ -237,7 +237,7 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -237,7 +237,7 @@ class IterationTransform(Visitor.VisitorTransform):
def
_transform_bytes_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
def
_transform_bytes_iteration
(
self
,
node
,
slice_node
,
reversed
=
False
):
target_type
=
node
.
target
.
type
target_type
=
node
.
target
.
type
if
not
target_type
.
is_int
:
if
not
target_type
.
is_int
and
target_type
is
not
Builtin
.
bytes_type
:
# bytes iteration returns bytes objects in Py2, but
# bytes iteration returns bytes objects in Py2, but
# integers in Py3
# integers in Py3
return
node
return
node
...
...
tests/run/carray_slicing.pyx
View file @
ae62e5ee
...
@@ -46,6 +46,21 @@ def slice_charptr_for_loop_c():
...
@@ -46,6 +46,21 @@ def slice_charptr_for_loop_c():
print
[
chr
(
c
)
for
c
in
cstring
[
1
:
5
]
]
print
[
chr
(
c
)
for
c
in
cstring
[
1
:
5
]
]
print
[
chr
(
c
)
for
c
in
cstring
[
4
:
9
]
]
print
[
chr
(
c
)
for
c
in
cstring
[
4
:
9
]
]
#@cython.test_assert_path_exists("//ForFromStatNode",
# "//ForFromStatNode//IndexNode")
#@cython.test_fail_if_path_exists("//ForInStatNode")
def
slice_charptr_for_loop_c_to_bytes
():
"""
>>> slice_charptr_for_loop_c_to_bytes()
['a', 'b', 'c']
['b', 'c', 'A', 'B']
['B', 'C', 'q', 't', 'p']
"""
cdef
bytes
b
print
[
b
for
b
in
cstring
[:
3
]
]
print
[
b
for
b
in
cstring
[
1
:
5
]
]
print
[
b
for
b
in
cstring
[
4
:
9
]
]
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//IndexNode"
)
"//ForFromStatNode//IndexNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
...
...
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