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
9a9ed566
Commit
9a9ed566
authored
Nov 17, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify (and centralise) module cleanup code generation for tuple constants
parent
d037a456
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+9
-10
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-4
No files found.
Cython/Compiler/Code.py
View file @
9a9ed566
...
...
@@ -557,9 +557,6 @@ class GlobalState(object):
def get_cached_constants_writer(self):
return self.parts['cached_constants']
def get_globals_cleanup_writer(self):
return self.parts['cleanup_globals']
def get_int_const(self, str_value, longness=False):
longness = bool(longness)
try:
...
...
@@ -568,9 +565,14 @@ class GlobalState(object):
c = self.new_int_const(str_value, longness)
return c
def get_py_const(self, type, prefix=''):
def get_py_const(self, type, prefix=''
, cleanup_level=None
):
# create a new Python object constant
return self.new_py_const(type, prefix)
const = self.new_py_const(type, prefix)
if cleanup_level is not None
\
and cleanup_level >= Options.generate_cleanup_code:
cleanup_writer = self.parts['cleanup_globals']
cleanup_writer.put_xdecref_clear(const.cname, type, nanny=False)
return const
def get_string_const(self, text):
# return a C string constant, creating a new one if necessary
...
...
@@ -962,8 +964,8 @@ class CCodeWriter(object):
def get_py_num(self, str_value, longness):
return self.globalstate.get_int_const(str_value, longness).cname
def get_py_const(self, type, prefix=''):
return self.globalstate.get_py_const(type, prefix).cname
def get_py_const(self, type, prefix=''
, cleanup_level=None
):
return self.globalstate.get_py_const(type, prefix
, cleanup_level
).cname
def get_string_const(self, text):
return self.globalstate.get_string_const(text).cname
...
...
@@ -983,9 +985,6 @@ class CCodeWriter(object):
def get_cached_constants_writer(self):
return self.globalstate.get_cached_constants_writer()
def get_globals_cleanup_writer(self):
return self.globalstate.get_globals_cleanup_writer()
# code generation
def putln(self, code = "", safe=False):
...
...
Cython/Compiler/ExprNodes.py
View file @
9a9ed566
...
...
@@ -3963,10 +3963,7 @@ class TupleNode(SequenceNode):
if
self
.
is_literal
:
# non-empty cached tuple => result is global constant,
# creation code goes into separate code writer
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'tuple_'
)
if
Options
.
generate_cleanup_code
>=
2
:
cleanup_writer
=
code
.
get_globals_cleanup_writer
()
cleanup_writer
.
put_xdecref_clear
(
self
.
result
(),
py_object_type
,
nanny
=
False
)
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'tuple_'
,
cleanup_level
=
2
)
code
=
code
.
get_cached_constants_writer
()
code
.
mark_pos
(
self
.
pos
)
...
...
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