New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PagedMemory: Use dicts to store items when there are only a few. #3471
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rhelmot
approved these changes
Aug 3, 2022
ltfish
force-pushed
the
feat/dynamicdictlist
branch
2 times, most recently
from
August 4, 2022 08:14
d35b68b
to
a280286
Compare
Apparently this is never merged (or finished). I'll get to it today. |
ltfish
force-pushed
the
feat/dynamicdictlist
branch
from
September 5, 2022 03:19
a280286
to
172e17d
Compare
My profiling script: import matplotlib.pyplot as plt
import timeit
NUMBER = 10000
def profile_list_dict(elements: int):
t0 = timeit.Timer("dict(d)", setup=f"""
class A:
pass
d = dict((v, A()) for v in range({elements}))""")
t1 = timeit.Timer("list(l)", setup=f"""
class A:
pass
l = [None] * 4096
for i in range({elements}):
l[i] = A()""")
d = t0.timeit(number=NUMBER)
l = t1.timeit(number=NUMBER)
print("#:", elements)
print("dict:", d)
print("list:", l)
return d, l
def main():
d_ = [ ]
l_ = [ ]
tt = [ ]
for elements in range(0, 4096, 50):
d, l = profile_list_dict(elements)
tt.append(elements)
d_.append(d)
l_.append(l)
# plot it
fig, ax = plt.subplots()
ax.plot(tt, d_, label="dict")
ax.plot(tt, l_, label="list")
ax.legend()
plt.savefig("result.png")
plt.show()
if __name__ == "__main__":
main() CPython 3.10: PyPy 3.9: Looks like we need two different thresholds :/ |
ltfish
added a commit
to angr/angr-doc
that referenced
this pull request
Sep 5, 2022
ltfish
added a commit
to angr/angr-doc
that referenced
this pull request
Sep 5, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TODO:
DynamicDictList
to supportDynamicDictList[element_type]
.