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
Fix update() ordering to be more consistent with add() ordering #159
Fix update() ordering to be more consistent with add() ordering #159
Conversation
5df8758
to
2c46e47
Compare
I'm not sure this is correct. I think you would need to reverse the order of the inserted values to update(). Can you write a test that adds each element individually and compares with calling update()? Also, the two test cases currently given look the same to me. Test cases in those files should use the "modulo" and "negate" keys respectively. |
I don't think I need to reverse the direction of the values to update... I can write the test you suggest and show that I am not required to reverse the order given my change.
That is a great suggestion! That will certainly help the tests look consistent. I'll go ahead and mention up front that the |
…internally against using the `add()` method
…internally against using the `add()` method
The modulo test shouldn’t need to use a tuple. Can you try something like this:
|
Having played with it in the repl for a bit I see now the surprising behavior :) Can you also share your benchmarking (just a snippet from IPython is fine)? It’s typically tricky to measure performance accurately. If we had a million values then I would assume inserting them at the beginning is slower than extending them to the end. |
I had originally used your benchmarking tools from this project to verify I didn't see any differences, but here are some IPython snippets like you asked. I figured it would be best to have the SL populated with some data before calling The first snippet is using the current release of
The second snippet is with my change:
So, there is certainly some performance hit. It seems like the hit ratio is worse as the number of elements being inserted drops. So it seems that there is probably some initial overhead which is proportional to the size, but that the overhead is much smaller than the actual time it takes to complete the |
I was able to decrease the performance hit by using
The ~41% slow down is still pretty bad but not nearly as bad as 167%. I suspect the cause is that Can you update the code to use
|
What you've got there looks awesome! I'll get your changes pushed in and do a last cursory check. |
The benchmarks plots look good on my end. Also, I have run the same tests that I did on the IPython console with the new changes:
Timings now look like (668ms, 641us, 9.34us respectively) These show an improvement in performance to the timings done with the last iteration of code (681ms, 718us, 17.6us respectively) These also compare nicely to the original timings of the code (before any changes on this issue) (633ms, 590us, 9.46us respectively) I feel good about this after @grantjenks suggested this latest code change. Thanks! Any other questions about this unanswered @grantjenks ? |
I'll try to push a new version this week. If I forget, please ping me. |
This pull request fixes #158 by prepending existing elements to new ones (to stick with the same ordering as the
add()
method).I have run the included
tox
tests and benchmarks offline and have not seen any noticeable difference in performance after looking at the benchmark plots.