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
7c6b5218
Commit
7c6b5218
authored
Aug 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dict change: scan manually instead of conservatively
parent
c30e503e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
microbenchmarks/string_key_ubench.py
microbenchmarks/string_key_ubench.py
+18
-0
src/runtime/dict.cpp
src/runtime/dict.cpp
+4
-8
src/runtime/types.h
src/runtime/types.h
+1
-1
No files found.
microbenchmarks/string_key_ubench.py
0 → 100644
View file @
7c6b5218
# Test the speed of using strings as dictionary keys.
# We internally optimize many things to not use dictionaries,
# but there are some times that we can't.
def
f
():
d
=
{
'a'
:
1
}
for
i
in
xrange
(
3000000
):
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
d
[
'a'
]
f
()
src/runtime/dict.cpp
View file @
7c6b5218
...
...
@@ -689,14 +689,10 @@ void BoxedDict::gcHandler(GCVisitor* v, Box* b) {
BoxedDict
*
d
=
(
BoxedDict
*
)
b
;
// This feels like a cludge, but we need to find anything that
// the unordered_map might have allocated.
// Another way to handle this would be to rt_alloc the unordered_map
// as well, though that incurs extra memory dereferences which would
// be nice to avoid.
void
**
start
=
(
void
**
)
&
d
->
d
;
void
**
end
=
start
+
(
sizeof
(
d
->
d
)
/
8
);
v
->
visitPotentialRange
(
start
,
end
);
for
(
auto
p
:
d
->
d
)
{
v
->
visit
(
p
.
first
);
v
->
visit
(
p
.
second
);
}
}
void
BoxedDictIterator
::
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
...
...
src/runtime/types.h
View file @
7c6b5218
...
...
@@ -661,7 +661,7 @@ struct PyLt {
class
BoxedDict
:
public
Box
{
public:
typedef
std
::
unordered_map
<
Box
*
,
Box
*
,
PyHasher
,
PyEq
,
StlCompatAllocator
<
std
::
pair
<
Box
*
,
Box
*>>
>
DictMap
;
typedef
std
::
unordered_map
<
Box
*
,
Box
*
,
PyHasher
,
PyEq
>
DictMap
;
DictMap
d
;
...
...
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