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
34587532
Commit
34587532
authored
Dec 08, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use boundscheck directive for lists/tuples.
parent
9614a25e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+13
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
34587532
...
...
@@ -1841,11 +1841,18 @@ class IndexNode(ExprNode):
self
.
original_index_type
=
self
.
index
.
type
if
self
.
base
.
type
.
is_pyobject
:
if
self
.
index
.
type
.
is_int
:
if
(
not
setting
and
(
self
.
base
.
type
is
list_type
or
self
.
base
.
type
is
tuple_type
)
and
(
not
self
.
index
.
type
.
signed
or
isinstance
(
self
.
index
,
IntNode
)
and
int
(
self
.
index
.
value
)
>=
0
)
and
not
env
.
directives
[
'boundscheck'
]):
self
.
is_temp
=
0
else
:
self
.
is_temp
=
1
self
.
index
=
self
.
index
.
coerce_to
(
PyrexTypes
.
c_py_ssize_t_type
,
env
).
coerce_to_simple
(
env
)
else
:
self
.
index
=
self
.
index
.
coerce_to_pyobject
(
env
)
self
.
is_temp
=
1
self
.
type
=
py_object_type
self
.
is_temp
=
1
else
:
if
self
.
base
.
type
.
is_ptr
or
self
.
base
.
type
.
is_array
:
self
.
type
=
self
.
base
.
type
.
base_type
...
...
@@ -1883,6 +1890,10 @@ class IndexNode(ExprNode):
def
calculate_result_code
(
self
):
if
self
.
is_buffer_access
:
return
"(*%s)"
%
self
.
buffer_ptr_code
elif
self
.
base
.
type
is
list_type
:
return
"PyList_GET_ITEM(%s, %s)"
%
(
self
.
base
.
result
(),
self
.
index
.
result
())
elif
self
.
base
.
type
is
tuple_type
:
return
"PyTuple_GET_ITEM(%s, %s)"
%
(
self
.
base
.
result
(),
self
.
index
.
result
())
else
:
return
"(%s[%s])"
%
(
self
.
base
.
result
(),
self
.
index
.
result
())
...
...
@@ -1930,7 +1941,7 @@ class IndexNode(ExprNode):
# is_temp is True, so must pull out value and incref it.
code
.
putln
(
"%s = *%s;"
%
(
self
.
result
(),
self
.
buffer_ptr_code
))
code
.
putln
(
"__Pyx_INCREF((PyObject*)%s);"
%
self
.
result
())
elif
self
.
type
.
is_pyobject
:
elif
self
.
type
.
is_pyobject
and
self
.
is_temp
:
if
self
.
index
.
type
.
is_int
:
index_code
=
self
.
index
.
result
()
if
self
.
base
.
type
is
list_type
:
...
...
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