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
1f8ffaa1
Commit
1f8ffaa1
authored
Oct 25, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ticket 436: efficiently support char*.decode() through C-API calls
parent
eed632a1
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
62 deletions
+180
-62
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+134
-45
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-16
Cython/Compiler/Visitor.py
Cython/Compiler/Visitor.py
+16
-0
tests/run/carray_slicing.pyx
tests/run/carray_slicing.pyx
+27
-0
No files found.
Cython/Compiler/Main.py
View file @
1f8ffaa1
...
...
@@ -136,7 +136,7 @@ class Context(object):
IntroduceBufferAuxiliaryVars
(
self
),
_check_c_declarations
,
AnalyseExpressionsTransform
(
self
),
OptimizeBuiltinCalls
(),
OptimizeBuiltinCalls
(
self
),
IterationTransform
(),
SwitchTransform
(),
DropRefcountingTransform
(),
...
...
Cython/Compiler/Optimize.py
View file @
1f8ffaa1
This diff is collapsed.
Click to expand it.
Cython/Compiler/ParseTreeTransforms.py
View file @
1f8ffaa1
from
Cython.Compiler.Visitor
import
VisitorTransform
,
CythonTransform
,
TreeVisitor
from
Cython.Compiler.Visitor
import
VisitorTransform
,
TreeVisitor
from
Cython.Compiler.Visitor
import
CythonTransform
,
EnvTransform
from
Cython.Compiler.ModuleNode
import
ModuleNode
from
Cython.Compiler.Nodes
import
*
from
Cython.Compiler.ExprNodes
import
*
...
...
@@ -938,21 +939,6 @@ class GilCheck(VisitorTransform):
return
node
class
EnvTransform
(
CythonTransform
):
"""
This transformation keeps a stack of the environments.
"""
def
__call__
(
self
,
root
):
self
.
env_stack
=
[
root
.
scope
]
return
super
(
EnvTransform
,
self
).
__call__
(
root
)
def
visit_FuncDefNode
(
self
,
node
):
self
.
env_stack
.
append
(
node
.
local_scope
)
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
return
node
class
TransformBuiltinMethods
(
EnvTransform
):
def
visit_SingleAssignmentNode
(
self
,
node
):
...
...
Cython/Compiler/Visitor.py
View file @
1f8ffaa1
...
...
@@ -306,6 +306,22 @@ class ScopeTrackingTransform(CythonTransform):
def
visit_CStructOrUnionDefNode
(
self
,
node
):
return
self
.
visit_scope
(
node
,
'struct'
)
class
EnvTransform
(
CythonTransform
):
"""
This transformation keeps a stack of the environments.
"""
def
__call__
(
self
,
root
):
self
.
env_stack
=
[
root
.
scope
]
return
super
(
EnvTransform
,
self
).
__call__
(
root
)
def
visit_FuncDefNode
(
self
,
node
):
self
.
env_stack
.
append
(
node
.
local_scope
)
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
return
node
class
RecursiveNodeReplacer
(
VisitorTransform
):
"""
Recursively replace all occurrences of a node in a subtree by
...
...
tests/run/carray_slicing.pyx
0 → 100644
View file @
1f8ffaa1
cdef
char
*
cstring
=
"abcABCqtp"
def
slice_charptr_end
():
"""
>>> print str(slice_charptr_end()).replace("b'", "'")
('a', 'abc', 'abcABCqtp')
"""
return
cstring
[:
1
],
cstring
[:
3
],
cstring
[:
9
]
def
slice_charptr_decode
():
"""
>>> print str(slice_charptr_decode()).replace("u'", "'")
('a', 'abc', 'abcABCqtp')
"""
return
(
cstring
[:
1
].
decode
(
'UTF-8'
),
cstring
[:
3
].
decode
(
'UTF-8'
),
cstring
[:
9
].
decode
(
'UTF-8'
))
def
slice_charptr_decode_errormode
():
"""
>>> print str(slice_charptr_decode_errormode()).replace("u'", "'")
('a', 'abc', 'abcABCqtp')
"""
return
(
cstring
[:
1
].
decode
(
'UTF-8'
,
'strict'
),
cstring
[:
3
].
decode
(
'UTF-8'
,
'replace'
),
cstring
[:
9
].
decode
(
'UTF-8'
,
'unicode_escape'
))
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