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
Gwenaël Samain
cython
Commits
caea47a4
Commit
caea47a4
authored
Dec 22, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid redundant NULL inits for extension type fields in tp_new()
parent
b0618a07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+10
-8
No files found.
Cython/Compiler/ModuleNode.py
View file @
caea47a4
...
...
@@ -1074,8 +1074,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
base_type
=
type
.
base_type
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
\
scope
.
get_refcounted_entries
(
include_weakref
=
True
)
cpp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cpp_class
]
scope
.
get_refcounted_entries
()
if
scope
.
is_internal
:
# internal classes (should) never need None inits, normal zeroing will do
py_attrs
=
[]
cpp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cpp_class
]
new_func_entry
=
scope
.
lookup_here
(
"__new__"
)
if
base_type
or
(
new_func_entry
and
new_func_entry
.
is_special
...
...
@@ -1105,7 +1109,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"static PyObject *%s(PyTypeObject *t, %sPyObject *a, %sPyObject *k) {"
%
(
slot_func
,
unused_marker
,
unused_marker
))
need_self_cast
=
type
.
vtabslot_cname
or
have_entries
or
cpp_class_attrs
need_self_cast
=
(
type
.
vtabslot_cname
or
(
py_buffers
or
memoryview_slices
or
py_attrs
)
or
cpp_class_attrs
)
if
need_self_cast
:
code
.
putln
(
"%s;"
%
scope
.
parent_type
.
declaration_code
(
"p"
))
if
base_type
:
...
...
@@ -1153,11 +1159,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
(
entry
.
cname
,
entry
.
type
.
declaration_code
(
""
)))
for
entry
in
py_attrs
:
if
scope
.
is_internal
or
entry
.
name
==
"__weakref__"
:
# internal classes do not need None inits
code
.
putln
(
"p->%s = 0;"
%
entry
.
cname
)
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
)
for
entry
in
memoryview_slices
:
code
.
putln
(
"p->%s.data = NULL;"
%
entry
.
cname
)
...
...
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