Add faster implementation of _IonNature.ion_hash#22
Merged
popematt merged 2 commits intoamazon-ion:masterfrom Sep 3, 2021
Merged
Add faster implementation of _IonNature.ion_hash#22popematt merged 2 commits intoamazon-ion:masterfrom
popematt merged 2 commits intoamazon-ion:masterfrom
Conversation
tgregg
approved these changes
Sep 2, 2021
Comment on lines
+481
to
+483
| return _bytes.replace(bytes([_ESCAPE_BYTE]), bytes([_ESCAPE_BYTE, _ESCAPE_BYTE])) \ | ||
| .replace(_BEGIN_MARKER, bytes([_ESCAPE_BYTE, _BEGIN_MARKER_BYTE])) \ | ||
| .replace(_END_MARKER, bytes([_ESCAPE_BYTE, _END_MARKER_BYTE])) |
There was a problem hiding this comment.
Should we avoid recomputing bytes([...]) on each call by storing the values?
Contributor
Author
There was a problem hiding this comment.
I don't know. I have also heard that looking up non-local values can be expensive in Python, and if we want to compute once and store the value, then it would need to be a non-local value. I'll create a followup issue to see if it would improve performance.
There was a problem hiding this comment.
That's fine with me, although it does seem like a simple enough thing to try given that you already have a basic perf testing setup.
cheqianh
approved these changes
Sep 2, 2021
This file contains hidden or 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
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.
Issue #, if available:
Not necessarily a fix; at least an improvement for #21
Description of changes:
New implementation of
.ion_hash()that does away with the overhead of instantiatingion_writers. As part of this change, I improved the performance of the_escape()function, which has the side effect of also benefitting theion_hash_readerand theion_hash_writer.I did some very informal performance testing using this script.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.