Skip to content
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

gh-118961: random.choices undefined behavior when some weights are not finite or negative #118962

Closed
wants to merge 4 commits into from

Conversation

leikdga
Copy link
Contributor

@leikdga leikdga commented May 12, 2024

gh-118961: random.choices undefined behavior when some weights are not finite or negative

@leikdga leikdga requested a review from rhettinger as a code owner May 12, 2024 04:07
@leikdga leikdga changed the title Fix issue 118961 Fix issue gh-118961: random.choices undefined behavior when some weights are not finite or negative May 12, 2024
@leikdga leikdga changed the title Fix issue gh-118961: random.choices undefined behavior when some weights are not finite or negative Fix issue gh118961: random.choices undefined behavior when some weights are not finite or negative May 12, 2024
@leikdga leikdga changed the title Fix issue gh118961: random.choices undefined behavior when some weights are not finite or negative Fix issue gh-118961: random.choices undefined behavior when some weights are not finite or negative May 12, 2024
@Eclips4 Eclips4 changed the title Fix issue gh-118961: random.choices undefined behavior when some weights are not finite or negative gh-118961: random.choices undefined behavior when some weights are not finite or negative May 12, 2024
@gaogaotiantian
Copy link
Member

What's the performance penalty for this?

@leikdga
Copy link
Contributor Author

leikdga commented May 14, 2024

What's the performance penalty for this?

Good question! This does add an O(N) check to the function, which results in a relatively significant performance loss, especially when k << len(weights).
Please see the issue for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants