refactor: improve performance for hand calculations further#192
Merged
refactor: improve performance for hand calculations further#192
Conversation
Apricot-S
requested changes
Feb 7, 2026
|
|
||
| if not calculated_hands: | ||
| return HandResponse(error=HandCalculator.ERR_HAND_NOT_CORRECT) | ||
| return HandResponse(error=HandCalculator.ERR_HAND_NOT_WINNING) |
Collaborator
There was a problem hiding this comment.
No breaking changes are required if we do the following:
hand_options = HandDivider.divide_hand(tiles_34, melds)
is_kokushi = not is_open_hand and config.yaku.kokushi.is_condition_met(None, tiles_34)
if not hand_options and not is_kokushi:
return HandResponse(error=HandCalculator.ERR_HAND_NOT_WINNING)
...
if not calculated_hands:
return HandResponse(error=HandCalculator.ERR_HAND_NOT_CORRECT)
Contributor
Author
There was a problem hiding this comment.
Do you think it is worth to keep comparability here? It was really rare case and hack with additional error response. Now we have a chance to fix it properly
Apricot-S
approved these changes
Feb 7, 2026
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.
Closes #171
@Apricot-S fixed hand divider, so now it produces empty output if hand is not agari.
With that improvement we can simplify hand calculation and remove additional
is_agaricheck from there.All 2.1kk validation set hands pass with this change.
Benchmark results
Benchmark was run with
n=5andlimit=200000.Old
New
Overall profile
estimate_hand_valuefunction