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
ad049a21
Commit
ad049a21
authored
Apr 30, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid redundant initialisation of closure variables with None/NULL
parent
0da9830b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
10 deletions
+6
-10
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-9
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
ad049a21
...
@@ -901,7 +901,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -901,7 +901,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type
.
vtabslot_cname
,
type
.
vtabslot_cname
,
struct_type_cast
,
type
.
vtabptr_cname
))
struct_type_cast
,
type
.
vtabptr_cname
))
for
entry
in
py_attrs
:
for
entry
in
py_attrs
:
if
entry
.
name
==
"__weakref__"
:
if
scope
.
is_internal
or
entry
.
name
==
"__weakref__"
:
# internal classes do not need None inits
code
.
putln
(
"p->%s = 0;"
%
entry
.
cname
)
code
.
putln
(
"p->%s = 0;"
%
entry
.
cname
)
else
:
else
:
code
.
put_init_var_to_py_none
(
entry
,
"p->%s"
,
nanny
=
False
)
code
.
put_init_var_to_py_none
(
entry
,
"p->%s"
,
nanny
=
False
)
...
...
Cython/Compiler/Nodes.py
View file @
ad049a21
...
@@ -1063,17 +1063,8 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1063,17 +1063,8 @@ class FuncDefNode(StatNode, BlockNode):
Naming
.
empty_tuple
))
Naming
.
empty_tuple
))
# TODO: error handling
# TODO: error handling
code
.
put_gotref
(
Naming
.
cur_scope_cname
)
code
.
put_gotref
(
Naming
.
cur_scope_cname
)
# The code below is because we assume the local variables are
# innitially NULL.
# Note that it is unsafe to decref the scope at this point.
# Note that it is unsafe to decref the scope at this point.
for
entry
in
lenv
.
arg_entries
+
lenv
.
var_entries
:
if
entry
.
in_closure
and
entry
.
type
.
is_pyobject
:
code
.
put_gotref
(
entry
.
cname
)
# so the refnanny doesn't whine
code
.
put_var_decref_clear
(
entry
)
if
env
.
is_closure_scope
:
if
env
.
is_closure_scope
:
if
lenv
.
is_closure_scope
:
code
.
put_gotref
(
outer_scope_cname
)
code
.
put_decref
(
outer_scope_cname
,
env
.
scope_class
.
type
)
code
.
putln
(
"%s = (%s)%s;"
%
(
code
.
putln
(
"%s = (%s)%s;"
%
(
outer_scope_cname
,
outer_scope_cname
,
env
.
scope_class
.
type
.
declaration_code
(
''
),
env
.
scope_class
.
type
.
declaration_code
(
''
),
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
ad049a21
...
@@ -872,6 +872,7 @@ class CreateClosureClasses(CythonTransform):
...
@@ -872,6 +872,7 @@ class CreateClosureClasses(CythonTransform):
pos
=
node
.
pos
,
defining
=
True
,
implementing
=
True
)
pos
=
node
.
pos
,
defining
=
True
,
implementing
=
True
)
func_scope
.
scope_class
=
entry
func_scope
.
scope_class
=
entry
class_scope
=
entry
.
type
.
scope
class_scope
=
entry
.
type
.
scope
class_scope
.
is_internal
=
True
if
node
.
entry
.
scope
.
is_closure_scope
:
if
node
.
entry
.
scope
.
is_closure_scope
:
class_scope
.
declare_var
(
pos
=
node
.
pos
,
class_scope
.
declare_var
(
pos
=
node
.
pos
,
name
=
Naming
.
outer_scope_cname
,
# this could conflict?
name
=
Naming
.
outer_scope_cname
,
# this could conflict?
...
...
Cython/Compiler/Symtab.py
View file @
ad049a21
...
@@ -194,6 +194,7 @@ class Scope(object):
...
@@ -194,6 +194,7 @@ class Scope(object):
# return_type PyrexType or None Return type of function owning scope
# return_type PyrexType or None Return type of function owning scope
# is_py_class_scope boolean Is a Python class scope
# is_py_class_scope boolean Is a Python class scope
# is_c_class_scope boolean Is an extension type scope
# is_c_class_scope boolean Is an extension type scope
# is_closure_scope boolean
# scope_prefix string Disambiguator for C names
# scope_prefix string Disambiguator for C names
# in_cinclude boolean Suppress C declaration code
# in_cinclude boolean Suppress C declaration code
# qualified_name string "
modname
" or "
modname
.
classname
"
# qualified_name string "
modname
" or "
modname
.
classname
"
...
@@ -203,11 +204,13 @@ class Scope(object):
...
@@ -203,11 +204,13 @@ class Scope(object):
# nogil boolean In a nogil section
# nogil boolean In a nogil section
# directives dict Helper variable for the recursive
# directives dict Helper variable for the recursive
# analysis, contains directive values.
# analysis, contains directive values.
# is_internal boolean Is only used internally (simpler setup)
is_py_class_scope = 0
is_py_class_scope = 0
is_c_class_scope = 0
is_c_class_scope = 0
is_closure_scope = 0
is_closure_scope = 0
is_module_scope = 0
is_module_scope = 0
is_internal = 0
scope_prefix = ""
scope_prefix = ""
in_cinclude = 0
in_cinclude = 0
nogil = 0
nogil = 0
...
...
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