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
02234c6a
Commit
02234c6a
authored
Jan 10, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid redundant C-Py-C roundtrip for Py_UCS4 return values
parent
fbcf496e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+3
-0
tests/run/py_ucs4_type.pyx
tests/run/py_ucs4_type.pyx
+18
-0
No files found.
Cython/Compiler/Optimize.py
View file @
02234c6a
...
...
@@ -2021,6 +2021,9 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
if
node
.
type
.
assignable_from
(
arg
.
arg
.
type
):
# completely redundant C->Py->C coercion
return
arg
.
arg
.
coerce_to
(
node
.
type
,
self
.
current_env
())
elif
arg
.
type
is
Builtin
.
unicode_type
:
if
arg
.
arg
.
type
.
is_unicode_char
and
node
.
type
.
is_unicode_char
:
return
arg
.
arg
.
coerce_to
(
node
.
type
,
self
.
current_env
())
elif
isinstance
(
arg
,
ExprNodes
.
SimpleCallNode
):
if
node
.
type
.
is_int
or
node
.
type
.
is_float
:
return
self
.
_optimise_numeric_cast_call
(
node
,
arg
)
...
...
tests/run/py_ucs4_type.pyx
View file @
02234c6a
...
...
@@ -145,6 +145,24 @@ def unicode_methods(Py_UCS4 uchar):
uchar
.
title
(),
]
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode'
,
'//CoerceFromPyTypeNode'
,
)
def
unicode_method_return_type
(
Py_UCS4
uchar
):
"""
>>> unicode_method_return_type(ord('A'))
[True, False]
>>> unicode_method_return_type(ord('a'))
[False, True]
"""
cdef
Py_UCS4
uc
,
ul
uc
,
ul
=
uchar
.
upper
(),
uchar
.
lower
()
return
[
uc
==
uchar
,
ul
==
uchar
]
@
cython
.
test_assert_path_exists
(
'//IntNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode'
,
'//PythonCapiCallNode'
)
...
...
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