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
80fcedd4
Commit
80fcedd4
authored
Jun 24, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare empty __slots__ in pyclass wrappers instead of __dict__ in cclass wrappers
parent
29eb4407
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
34 deletions
+15
-34
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+15
-34
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
80fcedd4
...
...
@@ -288,13 +288,10 @@ def NAME(self, ARGDECLS):
stats
=
[]
if
not
cclass_bases
.
args
:
# the memory layout for the underlying cyobject
and the __dict__
should always be the same
# the memory layout for the underlying cyobject should always be the same
# -> maybe use a single common base cclass in the future
underlying_cyobject
=
self
.
synthesize_underlying_cyobject_attribute
(
node
)
stats
.
append
(
underlying_cyobject
)
# add a __dict__ to support inheriting from a pyclass
dict_attribute
=
self
.
synthesize_dict_attribute
(
node
)
stats
.
append
(
dict_attribute
)
# insert method wrappers in the statement list
self
.
insert_cypclass_method_wrappers
(
node
,
cclass_name
,
stats
)
...
...
@@ -359,35 +356,6 @@ def NAME(self, ARGDECLS):
return
underlying_cyobject
def
synthesize_dict_attribute
(
self
,
node
):
base_type_node
=
Nodes
.
CSimpleBaseTypeNode
(
node
.
pos
,
name
=
EncodedString
(
"dict"
),
module_path
=
[],
is_basic_c_type
=
0
,
signed
=
1
,
complex
=
0
,
longness
=
0
,
is_self_arg
=
0
,
templates
=
None
)
dict_name_declarator
=
Nodes
.
CNameDeclaratorNode
(
node
.
pos
,
name
=
EncodedString
(
"__dict__"
),
cname
=
None
)
dict_attribute
=
Nodes
.
CVarDefNode
(
pos
=
node
.
pos
,
visibility
=
'private'
,
base_type
=
base_type_node
,
declarators
=
[
dict_name_declarator
],
in_pxd
=
node
.
in_pxd
,
doc
=
None
,
api
=
0
,
modifiers
=
[],
overridable
=
0
)
return
dict_attribute
def
synthesize_underlying_assignment
(
self
,
pos
,
cast_name_node
,
self_name
,
underlying_name
,
underlying_type
):
# > reference to the self argument of the wrapper method
self_obj
=
ExprNodes
.
NameNode
(
pos
,
name
=
self_name
)
...
...
@@ -513,11 +481,24 @@ def NAME(self, ARGDECLS):
return
method_wrapper
def
synthesize_empty_slots
(
self
,
node
):
lhs
=
ExprNodes
.
NameNode
(
node
.
pos
,
name
=
EncodedString
(
"__slots__"
))
rhs
=
ExprNodes
.
TupleNode
(
node
.
pos
,
args
=
[])
stat
=
Nodes
.
SingleAssignmentNode
(
node
.
pos
,
lhs
=
lhs
,
rhs
=
rhs
)
return
stat
def
synthesize_wrapper_pyclass
(
self
,
node
,
cclass_wrapper
,
qualified_name
,
cclass_name
,
pyclass_name
):
py_bases
=
self
.
synthesize_base_tuple
(
node
)
py_stats
=
[]
# declare '__slots__ = ()' to allow this pyclass to be a base class
# of an extension type that doesn't define a 'cdef dict __dict__'.
py_empty_slots
=
self
.
synthesize_empty_slots
(
node
)
py_stats
=
[
py_empty_slots
]
for
defnode
in
cclass_wrapper
.
body
.
stats
:
if
isinstance
(
defnode
,
Nodes
.
DefNode
):
def_name
=
defnode
.
name
...
...
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