Skip to content

fix: Create a new HandConfig instance when config=None in HandCalculator.estimate_hand_value#271

Merged
Nihisil merged 1 commit into
masterfrom
fix/config-const
May 12, 2026
Merged

fix: Create a new HandConfig instance when config=None in HandCalculator.estimate_hand_value#271
Nihisil merged 1 commit into
masterfrom
fix/config-const

Conversation

@Apricot-S
Copy link
Copy Markdown
Collaborator

@Apricot-S Apricot-S commented May 10, 2026

Currently, HandCalculator.estimate_hand_value uses the module-level _DEFAULT_CONFIG when config=None.
However, during hand calculation, the dora han count is updated dynamically.

Because _DEFAULT_CONFIG is mutable, running the calculator in a multi-threaded environment can result in incorrect dora han counts.

To avoid this issue, a new HandConfig instance is now created whenever config=None.

As a trade-off, the method becomes slightly slower.

@Apricot-S Apricot-S added this to the v2.1.0 milestone May 10, 2026
@Apricot-S Apricot-S added the bug label May 10, 2026
@Apricot-S Apricot-S requested a review from Nihisil as a code owner May 10, 2026 15:20
@Apricot-S
Copy link
Copy Markdown
Collaborator Author

It might be a good idea to explicitly state in the docstring that the value of config provided as an argument will be modified within the method.

Copy link
Copy Markdown
Contributor

@Nihisil Nihisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is ok to fix this bug as is now, but I think later we should reconsider our approach here and config shouldn't be modified during hand calculations

@Nihisil Nihisil merged commit 3a4f3b4 into master May 12, 2026
11 checks passed
@Nihisil Nihisil deleted the fix/config-const branch May 12, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants