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
6d16147e
Commit
6d16147e
authored
Jan 17, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
empty tuple optimization
parent
30aff7fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+16
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-0
Cython/Compiler/Naming.py
Cython/Compiler/Naming.py
+2
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
6d16147e
...
@@ -2118,6 +2118,19 @@ class SequenceNode(ExprNode):
...
@@ -2118,6 +2118,19 @@ class SequenceNode(ExprNode):
class
TupleNode
(
SequenceNode
):
class
TupleNode
(
SequenceNode
):
# Tuple constructor.
# Tuple constructor.
def
analyse_types
(
self
,
env
):
if
len
(
self
.
args
)
==
0
:
self
.
type
=
py_object_type
self
.
is_temp
=
0
else
:
SequenceNode
.
analyse_types
(
self
,
env
)
def
calculate_result_code
(
self
):
if
len
(
self
.
args
)
>
0
:
error
(
pos
,
"Positive length tuples must be constructed."
)
else
:
return
Naming
.
empty_tuple
def
compile_time_value
(
self
,
denv
):
def
compile_time_value
(
self
,
denv
):
values
=
self
.
compile_time_value_list
(
denv
)
values
=
self
.
compile_time_value_list
(
denv
)
...
@@ -2127,6 +2140,9 @@ class TupleNode(SequenceNode):
...
@@ -2127,6 +2140,9 @@ class TupleNode(SequenceNode):
self
.
compile_time_value_error
(
e
)
self
.
compile_time_value_error
(
e
)
def
generate_operation_code
(
self
,
code
):
def
generate_operation_code
(
self
,
code
):
if
len
(
self
.
args
)
==
0
:
# result_code is Naming.empty_tuple
return
code
.
putln
(
code
.
putln
(
"%s = PyTuple_New(%s); %s"
%
(
"%s = PyTuple_New(%s); %s"
%
(
self
.
result_code
,
self
.
result_code
,
...
...
Cython/Compiler/ModuleNode.py
View file @
6d16147e
...
@@ -286,6 +286,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -286,6 +286,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
''
)
code
.
putln
(
''
)
code
.
putln
(
'static PyObject *%s;'
%
env
.
module_cname
)
code
.
putln
(
'static PyObject *%s;'
%
env
.
module_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
builtins_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
builtins_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
empty_tuple
)
if
Options
.
pre_import
is
not
None
:
if
Options
.
pre_import
is
not
None
:
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
preimport_cname
)
code
.
putln
(
'static PyObject *%s;'
%
Naming
.
preimport_cname
)
code
.
putln
(
'static int %s;'
%
Naming
.
lineno_cname
)
code
.
putln
(
'static int %s;'
%
Naming
.
lineno_cname
)
...
@@ -1271,6 +1272,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1271,6 +1272,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
Options
.
cache_builtins
:
if
Options
.
cache_builtins
:
code
.
putln
(
"/*--- Builtin init code ---*/"
)
code
.
putln
(
"/*--- Builtin init code ---*/"
)
self
.
generate_builtin_init_code
(
env
,
code
)
self
.
generate_builtin_init_code
(
env
,
code
)
code
.
putln
(
"%s = PyTuple_New(0); %s"
%
(
Naming
.
empty_tuple
,
code
.
error_goto_if_null
(
Naming
.
empty_tuple
,
self
.
pos
)));
code
.
putln
(
"/*--- Global init code ---*/"
)
code
.
putln
(
"/*--- Global init code ---*/"
)
self
.
generate_global_init_code
(
env
,
code
)
self
.
generate_global_init_code
(
env
,
code
)
...
@@ -1324,6 +1327,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1324,6 +1327,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"/*--- Builtin cleanup code ---*/"
)
code
.
putln
(
"/*--- Builtin cleanup code ---*/"
)
for
entry
in
env
.
cached_builtins
:
for
entry
in
env
.
cached_builtins
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_decref_clear
(
entry
)
code
.
putln
(
"Py_DECREF(%s); %s = 0;"
%
(
Naming
.
empty_tuple
,
Naming
.
empty_tuple
));
code
.
putln
(
"/*--- Intern cleanup code ---*/"
)
code
.
putln
(
"/*--- Intern cleanup code ---*/"
)
for
entry
in
env
.
pynum_entries
:
for
entry
in
env
.
pynum_entries
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_decref_clear
(
entry
)
...
...
Cython/Compiler/Naming.py
View file @
6d16147e
...
@@ -58,6 +58,8 @@ vtabslot_cname = pyrex_prefix + "vtab"
...
@@ -58,6 +58,8 @@ vtabslot_cname = pyrex_prefix + "vtab"
c_api_tab_cname
=
pyrex_prefix
+
"c_api_tab"
c_api_tab_cname
=
pyrex_prefix
+
"c_api_tab"
gilstate_cname
=
pyrex_prefix
+
"state"
gilstate_cname
=
pyrex_prefix
+
"state"
skip_dispatch_cname
=
pyrex_prefix
+
"skip_dispatch"
skip_dispatch_cname
=
pyrex_prefix
+
"skip_dispatch"
empty_tuple
=
pyrex_prefix
+
"empty_tuple"
extern_c_macro
=
pyrex_prefix
.
upper
()
+
"EXTERN_C"
extern_c_macro
=
pyrex_prefix
.
upper
()
+
"EXTERN_C"
...
...
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