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
dict: perturb shift should be done when first conflict #72388
Comments
Current perturb shift code is like following: for (perturb = hash; ; perturb >>= PERTURB_SHIFT) {
i = mask & ((i << 2) + i + perturb + 1); This loop is start after first conflict. It means perturb == hash for first conflict. The purpose of perturb shift is avoid long conflict chain when keys more example: Consider about ma_keys == 16 and keys are [1, 17, 33, 49, 65].
When first perturb = hash >> PERTURB_SHIFT:
While it's difficult to see performance difference from benchmark, this should be decrease possibility of 2nd conflict. |
Good catch! I agree - and I wrote this code to begin with, so my opinion should count ;-) |
I agree and my opinion counts even more because I long ago made this change for setobjects ;-) |
General comment on the patch: I believe per PEP-7, we're still sticking to ANSI C (aka C89), and specifically, "all declarations must be at the top of a block (not necessarily at the top of function". The patch assumes lax standards compliance (or C99+ compliance), declaring variables in the for loop initializer section and midway through blocks. This should be changed to declare all variables at the top of blocks, and not in for loop initializer sections. |
Removing those unrelated changes looks like it would dramatically reduce the churn too, making review easier. |
josh.r:
Python 3.6 branch allows some C99 features.
While I think refactoring around changes is practical [1], I agree that I made too much change. I'll reduce diff size. [1] Changing without refactoring is hard sometimes. Whole file refactoring |
Could anyone review the patch? |
Fixed conflict with current 3.6 branch, and added NEWS entry. |
While I think this patch is safe, I need LGTM from another committer Could Tim or Raymond review the patch before 3.6beta2? |
LGTM! Ship it :-) |
Added comments on Rietveld. |
LGTM. But why you moved the declaration of perturb? |
New changeset cf2778fd7acb by INADA Naoki in branch '3.6': New changeset 80b01cd94a63 by INADA Naoki in branch 'default': |
Thank you, Tim and Serhiy. My first commit has been pushed now! Serhiy: |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: