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
Kirill Smelkov
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):
...
@@ -1289,29 +1289,40 @@ class IndexNode(ExprNode):
self
.
is_buffer_access
=
False
self
.
is_buffer_access
=
False
self
.
base
.
analyse_types
(
env
)
self
.
base
.
analyse_types
(
env
)
skip_child_analysis
=
False
buffer_access
=
False
if
self
.
base
.
type
.
buffer_options
is
not
None
:
if
self
.
base
.
type
.
buffer_options
is
not
None
:
if
isinstance
(
self
.
index
,
TupleNode
):
if
isinstance
(
self
.
index
,
TupleNode
):
indices
=
self
.
index
.
args
indices
=
self
.
index
.
args
else
:
else
:
indices
=
[
self
.
index
]
indices
=
[
self
.
index
]
all_ints
=
True
if
len
(
indices
)
==
self
.
base
.
type
.
buffer_options
.
ndim
:
for
x
in
indices
:
buffer_access
=
True
x
.
analyse_types
(
env
)
skip_child_analysis
=
True
if
not
x
.
type
.
is_int
:
for
x
in
indices
:
all_ints
=
False
x
.
analyse_types
(
env
)
if
all_ints
:
if
not
x
.
type
.
is_int
:
# self.indices = [
buffer_access
=
False
# x.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env)
if
buffer_access
:
# for x in indices]
# self.indices = [
self
.
indices
=
indices
# x.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env)
self
.
index
=
None
# for x in indices]
self
.
type
=
self
.
base
.
type
.
buffer_options
.
dtype
self
.
indices
=
indices
self
.
is_temp
=
1
self
.
index
=
None
self
.
is_buffer_access
=
True
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
:
if
not
buffer_access
:
self
.
index
.
analyse_types
(
env
)
# ok to analyse as tuple
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
.
base
.
type
.
is_pyobject
:
if
self
.
index
.
type
.
is_int
:
if
self
.
index
.
type
.
is_int
:
self
.
original_index_type
=
self
.
index
.
type
self
.
original_index_type
=
self
.
index
.
type
...
@@ -2212,10 +2223,10 @@ class SequenceNode(ExprNode):
...
@@ -2212,10 +2223,10 @@ class SequenceNode(ExprNode):
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
arg
.
analyse_target_declaration
(
env
)
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
)):
for
i
in
range
(
len
(
self
.
args
)):
arg
=
self
.
args
[
i
]
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
.
args
[
i
]
=
arg
.
coerce_to_pyobject
(
env
)
self
.
type
=
py_object_type
self
.
type
=
py_object_type
self
.
gil_check
(
env
)
self
.
gil_check
(
env
)
...
@@ -2320,12 +2331,12 @@ class TupleNode(SequenceNode):
...
@@ -2320,12 +2331,12 @@ class TupleNode(SequenceNode):
gil_message
=
"Constructing Python tuple"
gil_message
=
"Constructing Python tuple"
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
,
skip_children
=
False
):
if
len
(
self
.
args
)
==
0
:
if
len
(
self
.
args
)
==
0
:
self
.
is_temp
=
0
self
.
is_temp
=
0
self
.
is_literal
=
1
self
.
is_literal
=
1
else
:
else
:
SequenceNode
.
analyse_types
(
self
,
env
)
SequenceNode
.
analyse_types
(
self
,
env
,
skip_children
)
self
.
type
=
tuple_type
self
.
type
=
tuple_type
def
calculate_result_code
(
self
):
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