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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b0890818
Commit
b0890818
authored
Oct 27, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes for compile-time slicing
parent
3fe3c573
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+16
-4
tests/run/ct_DEF.pyx
tests/run/ct_DEF.pyx
+8
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
b0890818
...
...
@@ -1754,8 +1754,14 @@ class SliceIndexNode(ExprNode):
def
compile_time_value
(
self
,
denv
):
base
=
self
.
base
.
compile_time_value
(
denv
)
start
=
self
.
start
.
compile_time_value
(
denv
)
stop
=
self
.
stop
.
compile_time_value
(
denv
)
if
self
.
start
is
None
:
start
=
0
else
:
start
=
self
.
start
.
compile_time_value
(
denv
)
if
self
.
stop
is
None
:
stop
=
None
else
:
stop
=
self
.
stop
.
compile_time_value
(
denv
)
try
:
return
base
[
start
:
stop
]
except
Exception
,
e
:
...
...
@@ -1837,8 +1843,14 @@ class SliceNode(ExprNode):
def
compile_time_value
(
self
,
denv
):
start
=
self
.
start
.
compile_time_value
(
denv
)
stop
=
self
.
stop
.
compile_time_value
(
denv
)
step
=
step
.
step
.
compile_time_value
(
denv
)
if
self
.
stop
is
None
:
stop
=
None
else
:
stop
=
self
.
stop
.
compile_time_value
(
denv
)
if
self
.
step
is
None
:
step
=
None
else
:
step
=
self
.
step
.
compile_time_value
(
denv
)
try
:
return
slice
(
start
,
stop
,
step
)
except
Exception
,
e
:
...
...
tests/run/ct_DEF.pyx
View file @
b0890818
...
...
@@ -51,6 +51,8 @@ DEF TWO = TUPLE[1]
DEF
FIVE
=
TWO
+
3
DEF
TRUE
=
TRUE_FALSE
[
0
]
DEF
FALSE
=
TRUE_FALSE
[
1
]
DEF
INT_TUPLE1
=
TUPLE
[:
2
]
DEF
INT_TUPLE2
=
TUPLE
[
1
:
4
:
2
]
def
c
():
cdef
char
c
...
...
@@ -108,6 +110,12 @@ def two():
two
=
TWO
return
two
# this doesn't currently work!
#def two2():
# cdef int two
# two = INT_TUPLE1[-1]
# return two
def
five
():
cdef
int
five
five
=
FIVE
...
...
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