Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
6a63b319
Commit
6a63b319
authored
May 25, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faster version of attrwrapper.clear()
parent
a921480a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
src/core/types.h
src/core/types.h
+2
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-0
src/runtime/types.cpp
src/runtime/types.cpp
+6
-6
test/tests/dict_setting.py
test/tests/dict_setting.py
+3
-1
No files found.
src/core/types.h
View file @
6a63b319
...
...
@@ -500,6 +500,8 @@ public:
bool
nonzeroIC
();
Box
*
hasnextOrNullIC
();
Box
*
nextIC
();
friend
class
AttrWrapper
;
};
static_assert
(
offsetof
(
Box
,
cls
)
==
offsetof
(
struct
_object
,
ob_type
),
""
);
...
...
src/runtime/objmodel.cpp
View file @
6a63b319
...
...
@@ -536,6 +536,8 @@ HiddenClass* HiddenClass::getOrMakeChild(const std::string& attr) {
HiddenClass
*
HiddenClass
::
getAttrwrapperChild
()
{
assert
(
type
==
NORMAL
);
assert
(
attrwrapper_offset
==
-
1
);
if
(
!
attrwrapper_child
)
{
attrwrapper_child
=
new
HiddenClass
(
this
);
attrwrapper_child
->
attrwrapper_offset
=
this
->
attributeArraySize
();
...
...
src/runtime/types.cpp
View file @
6a63b319
...
...
@@ -1553,12 +1553,12 @@ public:
HCAttrs
*
attrs
=
self
->
b
->
getHCAttrsPtr
();
RELEASE_ASSERT
(
attrs
->
hcls
->
type
==
HiddenClass
::
NORMAL
||
attrs
->
hcls
->
type
==
HiddenClass
::
SINGLETON
,
""
);
while
(
true
)
{
const
auto
&
attrMap
=
attrs
->
hcls
->
getStrAttrOffsets
(
);
if
(
attrMap
.
size
()
==
0
)
break
;
self
->
b
->
delattr
(
attrMap
.
begin
()
->
first
(),
NULL
);
}
// Clear the attrs array:
new
((
void
*
)
attrs
)
HCAttrs
(
root_hcls
);
// Add the existing attrwrapper object (ie self) back as the attrwrapper:
self
->
b
->
appendNewHCAttr
(
self
,
NULL
)
;
attrs
->
hcls
=
attrs
->
hcls
->
getAttrwrapperChild
(
);
return
None
;
}
...
...
test/tests/dict_setting.py
View file @
6a63b319
...
...
@@ -44,6 +44,8 @@ class C(object):
return
0
c
=
C
()
c
.
attr
=
"test"
c
.
__dict__
.
clear
()
d1
=
c
.
__dict__
d1
.
clear
()
print
hasattr
(
c
,
"attr"
)
print
hasattr
(
c
,
"foo"
)
print
c
.
__dict__
is
d1
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