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
ad54b979
Commit
ad54b979
authored
Apr 28, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.29.x'
parents
382b5f09
b62774ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-2
tests/run/tuple_constants.pyx
tests/run/tuple_constants.pyx
+35
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
ad54b979
...
...
@@ -198,11 +198,13 @@ def make_dedup_key(outer_type, item_nodes):
@return: A tuple that can be used as a dict key for deduplication.
"""
item_keys
=
[
(
py_object_type
,
None
)
if
node
is
None
(
py_object_type
,
None
,
type
(
None
)
)
if
node
is
None
# For sequences and their "mult_factor", see TupleNode.
else
make_dedup_key
(
node
.
type
,
[
node
.
mult_factor
if
node
.
is_literal
else
None
]
+
node
.
args
)
if
node
.
is_sequence_constructor
else
make_dedup_key
(
node
.
type
,
(
node
.
start
,
node
.
stop
,
node
.
step
))
if
node
.
is_slice
else
(
node
.
type
,
node
.
constant_result
)
if
node
.
has_constant_result
()
# For constants, look at the Python value type if we don't know the concrete Cython type.
else
(
node
.
type
,
node
.
constant_result
,
type
(
node
.
constant_result
)
if
node
.
type
is
py_object_type
else
None
)
if
node
.
has_constant_result
()
else
None
# something we cannot handle => short-circuit below
for
node
in
item_nodes
]
...
...
@@ -1207,6 +1209,10 @@ class BoolNode(ConstNode):
return
str
(
int
(
self
.
value
))
def
coerce_to
(
self
,
dst_type
,
env
):
if
dst_type
==
self
.
type
:
return
self
if
dst_type
is
py_object_type
and
self
.
type
is
Builtin
.
bool_type
:
return
self
if
dst_type
.
is_pyobject
and
self
.
type
.
is_int
:
return
BoolNode
(
self
.
pos
,
value
=
self
.
value
,
...
...
tests/run/tuple_constants.pyx
View file @
ad54b979
...
...
@@ -132,3 +132,38 @@ def return_nonconstant_tuple():
"""
a
=
eval
(
"1"
)
return
(
'a'
,
a
,
'd'
)
def
constant_types_comparing_equal
():
"""
>>> constant_types_comparing_equal()
((False, False), (0, 0), (0.0, 0.0), (0, False), (False, 0.0), (0, 0.0))
"""
bool_tuple
=
(
False
,
False
)
int_tuple
=
(
0
,
0
)
float_tuple
=
(
0.0
,
0.0
)
int_bool
=
(
0
,
False
)
bool_float
=
(
False
,
0.0
)
int_float
=
(
0
,
0.0
)
assert
bool_tuple
is
(
False
,
False
)
assert
int_tuple
is
(
0
,
0
)
assert
bool_tuple
==
int_tuple
assert
bool_tuple
is
not
int_tuple
assert
float_tuple
is
(
0.
,
0.
)
assert
float_tuple
==
int_tuple
assert
float_tuple
is
not
int_tuple
assert
int_bool
is
(
0
,
False
)
assert
int_bool
==
bool_tuple
assert
int_bool
is
not
bool_tuple
assert
int_bool
is
not
int_tuple
assert
bool_float
is
(
False
,
0.
)
assert
bool_float
==
bool_tuple
assert
bool_float
is
not
bool_tuple
assert
bool_float
is
not
float_tuple
assert
int_float
is
(
0
,
0.
)
assert
int_float
==
int_tuple
assert
int_float
is
not
int_tuple
assert
int_float
is
not
float_tuple
return
bool_tuple
,
int_tuple
,
float_tuple
,
int_bool
,
bool_float
,
int_float
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