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
Boxiang Sun
cython
Commits
79d4bd3d
Commit
79d4bd3d
authored
Jul 09, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Non-ndim buffer indices falls back to Python; stops double-analysing index tuples
parent
3da50c6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
21 deletions
+32
-21
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+32
-21
No files found.
Cython/Compiler/ExprNodes.py
View file @
79d4bd3d
...
...
@@ -1289,29 +1289,40 @@ class IndexNode(ExprNode):
self
.
is_buffer_access
=
False
self
.
base
.
analyse_types
(
env
)
skip_child_analysis
=
False
buffer_access
=
False
if
self
.
base
.
type
.
buffer_options
is
not
None
:
if
isinstance
(
self
.
index
,
TupleNode
):
indices
=
self
.
index
.
args
else
:
indices
=
[
self
.
index
]
all_ints
=
True
for
x
in
indices
:
x
.
analyse_types
(
env
)
if
not
x
.
type
.
is_int
:
all_ints
=
False
if
all_ints
:
# self.indices = [
# x.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env)
# for x in indices]
self
.
indices
=
indices
self
.
index
=
None
self
.
type
=
self
.
base
.
type
.
buffer_options
.
dtype
self
.
is_temp
=
1
self
.
is_buffer_access
=
True
if
len
(
indices
)
==
self
.
base
.
type
.
buffer_options
.
ndim
:
buffer_access
=
True
skip_child_analysis
=
True
for
x
in
indices
:
x
.
analyse_types
(
env
)
if
not
x
.
type
.
is_int
:
buffer_access
=
False
if
buffer_access
:
# self.indices = [
# x.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env)
# for x in indices]
self
.
indices
=
indices
self
.
index
=
None
self
.
type
=
self
.
base
.
type
.
buffer_options
.
dtype
self
.
is_temp
=
1
self
.
is_buffer_access
=
True
# Note: This might be cleaned up by having IndexNode
# parsed in a saner way and only construct the tuple if
# needed.
if
not
self
.
is_buffer_access
:
self
.
index
.
analyse_types
(
env
)
# ok to analyse as tuple
if
not
buffer_access
:
if
isinstance
(
self
.
index
,
TupleNode
):
self
.
index
.
analyse_types
(
env
,
skip_children
=
skip_child_analysis
)
elif
not
skip_child_analysis
:
self
.
index
.
analyse_types
(
env
)
if
self
.
base
.
type
.
is_pyobject
:
if
self
.
index
.
type
.
is_int
:
self
.
original_index_type
=
self
.
index
.
type
...
...
@@ -2212,10 +2223,10 @@ class SequenceNode(ExprNode):
for
arg
in
self
.
args
:
arg
.
analyse_target_declaration
(
env
)
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
,
skip_children
=
False
):
for
i
in
range
(
len
(
self
.
args
)):
arg
=
self
.
args
[
i
]
arg
.
analyse_types
(
env
)
if
not
skip_children
:
arg
.
analyse_types
(
env
)
self
.
args
[
i
]
=
arg
.
coerce_to_pyobject
(
env
)
self
.
type
=
py_object_type
self
.
gil_check
(
env
)
...
...
@@ -2320,12 +2331,12 @@ class TupleNode(SequenceNode):
gil_message
=
"Constructing Python tuple"
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
,
skip_children
=
False
):
if
len
(
self
.
args
)
==
0
:
self
.
is_temp
=
0
self
.
is_literal
=
1
else
:
SequenceNode
.
analyse_types
(
self
,
env
)
SequenceNode
.
analyse_types
(
self
,
env
,
skip_children
)
self
.
type
=
tuple_type
def
calculate_result_code
(
self
):
...
...
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