-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Document that enums with unhashable members are created non-performantly #105535
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
Comments
I will try to create a pull request for this issue. I think it will be done by the end of the day. |
@mzhu22: Out of curiosity, do you have an actual use-case that uses many unhashable values? |
@ethanfurman So not a use-case of unhashable values, but rather an example of the performance trap. We have a use-case of dynamically generating Enums from user data. Originally the enum member values were strings, but we switched to dataclasses to include additional metadata. For some corner cases where enums had a lot of values, we noticed a dramatic performance hit, until we looked into it, and made the dataclasses immutable. |
Definitely a good reason for the warning. |
…H-107119) Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…ion (pythonGH-107119) (cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…ion (pythonGH-107119) (cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…tion (GH-107119) (GH116511) (cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…tion (GH-107119) (GH-116512) (cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…ion (pythonGH-107119) Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
…ion (pythonGH-107119) Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
Documentation
#28907 fixes enum creation taking quadratic time relative to the number of members, but only for members whose values are hashable. If not fixed, ideally this would be documented somewhere as it could potentially be a big performance trap
Linked PRs
The text was updated successfully, but these errors were encountered: