Speed operations by memory for prefix within node rather than dynamically #39
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.
First off, love the code and approach. I'd work the problem nearly identically so I'm starting with the code you've graciously shared and making the necessary mods which should benefit all pytricia users.
This first MR makes no interface changes, but provides further speed improvement by eliminating unnecessary dynamic memory allocation for the prefix. This is particularly beneficial because nearly all access operations previously performed dynamic allocation of a prefix, and then nearly always throwing it away. Now it can be done stack allocation which is more efficient for this case, yielding ~20% speed improvements from prior baseline in my testing.
It looked like the existing code had this use in mind with the implementation of
New_Prefix2
however it was not actually used that way. With this update I adjustedNew_Prefix2
and directly replacedNew_Prefix
itself.prefix is used in loads of places so the updates are extensive, but not complicated. All tests pass. Only warning is that while I attempted code updates for the py2 ifdef sections I don't have a good ability to test they are correct. At the point in the game it may be reasonable to just drop py2 support for newer versions anyways.
My next MR will be geared at addressing #20 to allow quick save/restore functionality for already build pytricia objects.
Thanks again!