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
29945fa6
Commit
29945fa6
authored
Feb 06, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for indexing into / looping over unicode strings, infer Py_UCS4 instead of Py_UNICODE
parent
ac871a9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
29945fa6
...
...
@@ -2066,14 +2066,14 @@ class IndexNode(ExprNode):
if
index_type
and
index_type
.
is_int
or
isinstance
(
self
.
index
,
(
IntNode
,
LongNode
)):
# indexing!
if
base_type
is
unicode_type
:
# Py_U
NICODE
will automatically coerce to a unicode string
# if required, so this is safe.
We only infer Py_UNICODE
# Py_U
CS4
will automatically coerce to a unicode string
# if required, so this is safe.
We only infer Py_UCS4
# when the index is a C integer type. Otherwise, we may
# need to use normal Python item access, in which case
# it's faster to return the one-char unicode string than
# to receive it, throw it away, and potentially rebuild it
# on a subsequent PyObject coercion.
return
PyrexTypes
.
c_py_u
nicode
_type
return
PyrexTypes
.
c_py_u
cs4
_type
elif
isinstance
(
self
.
base
,
BytesNode
):
#if env.global_scope().context.language_level >= 3:
# # infering 'char' can be made to work in Python 3 mode
...
...
@@ -2193,7 +2193,7 @@ class IndexNode(ExprNode):
if
self
.
index
.
type
.
is_int
and
base_type
is
unicode_type
:
# Py_UNICODE/Py_UCS4 will automatically coerce to a unicode string
# if required, so this is fast and safe
self
.
type
=
PyrexTypes
.
c_py_u
nicode
_type
self
.
type
=
PyrexTypes
.
c_py_u
cs4
_type
elif
is_slice
and
base_type
in
(
bytes_type
,
str_type
,
unicode_type
,
list_type
,
tuple_type
):
self
.
type
=
base_type
else
:
...
...
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