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
Kirill Smelkov
cython
Commits
08ce728f
Commit
08ce728f
authored
Jan 02, 2022
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compile the Cython.StringIOTree module by default to speed up the code generation a little.
parent
ad3fef8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
Cython/StringIOTree.pxd
Cython/StringIOTree.pxd
+5
-0
Cython/StringIOTree.py
Cython/StringIOTree.py
+13
-3
setup.py
setup.py
+1
-1
No files found.
Cython/StringIOTree.pxd
View file @
08ce728f
cimport
cython
cimport
cython
cdef
object
StringIO
@
cython
.
final
cdef
class
StringIOTree
:
cdef
class
StringIOTree
:
cdef
public
list
prepended_children
cdef
public
list
prepended_children
cdef
public
object
stream
cdef
public
object
stream
...
@@ -8,6 +11,8 @@ cdef class StringIOTree:
...
@@ -8,6 +11,8 @@ cdef class StringIOTree:
@
cython
.
locals
(
x
=
StringIOTree
)
@
cython
.
locals
(
x
=
StringIOTree
)
cpdef
getvalue
(
self
)
cpdef
getvalue
(
self
)
@
cython
.
locals
(
x
=
StringIOTree
)
cdef
_collect_in
(
self
,
list
target_list
)
@
cython
.
locals
(
child
=
StringIOTree
)
@
cython
.
locals
(
child
=
StringIOTree
)
cpdef
copyto
(
self
,
target
)
cpdef
copyto
(
self
,
target
)
cpdef
commit
(
self
)
cpdef
commit
(
self
)
...
...
Cython/StringIOTree.py
View file @
08ce728f
...
@@ -39,7 +39,6 @@ try:
...
@@ -39,7 +39,6 @@ try:
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
except
ImportError
:
except
ImportError
:
from
io
import
StringIO
from
io
import
StringIO
import
sys
class
StringIOTree
(
object
):
class
StringIOTree
(
object
):
...
@@ -56,10 +55,17 @@ class StringIOTree(object):
...
@@ -56,10 +55,17 @@ class StringIOTree(object):
self
.
markers
=
[]
self
.
markers
=
[]
def
getvalue
(
self
):
def
getvalue
(
self
):
content
=
[
x
.
getvalue
()
for
x
in
self
.
prepended_children
]
content
=
[]
content
.
append
(
self
.
stream
.
getvalue
()
)
self
.
_collect_in
(
content
)
return
""
.
join
(
content
)
return
""
.
join
(
content
)
def
_collect_in
(
self
,
target_list
):
for
x
in
self
.
prepended_children
:
x
.
_collect_in
(
target_list
)
stream_content
=
self
.
stream
.
getvalue
()
if
stream_content
:
target_list
.
append
(
stream_content
)
def
copyto
(
self
,
target
):
def
copyto
(
self
,
target
):
"""Potentially cheaper than getvalue as no string concatenation
"""Potentially cheaper than getvalue as no string concatenation
needs to happen."""
needs to happen."""
...
@@ -108,6 +114,7 @@ class StringIOTree(object):
...
@@ -108,6 +114,7 @@ class StringIOTree(object):
children
=
self
.
prepended_children
children
=
self
.
prepended_children
return
[
m
for
c
in
children
for
m
in
c
.
allmarkers
()]
+
self
.
markers
return
[
m
for
c
in
children
for
m
in
c
.
allmarkers
()]
+
self
.
markers
"""
# Print the result of allmarkers in a nice human-readable form. Use it only for debugging.
# Print the result of allmarkers in a nice human-readable form. Use it only for debugging.
# Prints e.g.
# Prints e.g.
# /path/to/source.pyx:
# /path/to/source.pyx:
...
@@ -147,4 +154,7 @@ class StringIOTree(object):
...
@@ -147,4 +154,7 @@ class StringIOTree(object):
reprstr += "-" + str(c_linenos[i]) + " "
reprstr += "-" + str(c_linenos[i]) + " "
i += 1
i += 1
reprstr += "
\
n
"
reprstr += "
\
n
"
import sys
sys.stdout.write(reprstr)
sys.stdout.write(reprstr)
"""
setup.py
View file @
08ce728f
...
@@ -93,10 +93,10 @@ def compile_cython_modules(profile=False, coverage=False, compile_more=False, cy
...
@@ -93,10 +93,10 @@ def compile_cython_modules(profile=False, coverage=False, compile_more=False, cy
"Cython.Runtime.refnanny"
,
"Cython.Runtime.refnanny"
,
"Cython.Compiler.FusedNode"
,
"Cython.Compiler.FusedNode"
,
"Cython.Tempita._tempita"
,
"Cython.Tempita._tempita"
,
"Cython.StringIOTree"
,
]
]
if
compile_more
:
if
compile_more
:
compiled_modules
.
extend
([
compiled_modules
.
extend
([
"Cython.StringIOTree"
,
"Cython.Compiler.Code"
,
"Cython.Compiler.Code"
,
"Cython.Compiler.Lexicon"
,
"Cython.Compiler.Lexicon"
,
"Cython.Compiler.Parsing"
,
"Cython.Compiler.Parsing"
,
...
...
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