[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-25 Thread Ethan Furman
Ethan Furman added the comment: Fixed in 3.10 in issue38250. Also fixed in my 3rd-party library, aenum 3.0: (https://pypi.org/project/aenum/) -- resolution: -> wont fix stage: -> resolved status: open -> closed superseder: -> enum.Flag should be more set-like type: ->

[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-13 Thread Ethan Furman
Ethan Furman added the comment: Yes. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-13 Thread Kevin Chen
Kevin Chen added the comment: Awesome thanks! Does the rewrite fix the issue with creating negated flags as well? -- ___ Python tracker ___

[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-12 Thread Ethan Furman
Ethan Furman added the comment: I just finished a rewrite of Flag for 3.10. Using your test below I was able to tweak the rewrite so the final numbers are: Took normal 0.148092 seconds. Took cached 0.017438 seconds. Your original post had a ratio of nearly 200 -- it is now 8.7ish.

[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-12 Thread Guido van Rossum
Change by Guido van Rossum : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-12 Thread Kevin Chen
New submission from Kevin Chen : Here's a code sample: ``` import time from enum import Flag, auto class MyFlag(Flag): NONE = 0 FLAG_1 = auto() FLAG_2 = auto() FLAG_3 = auto() FLAG_4 = auto() FLAG_5 = auto() FLAG_6 = auto() # # NOT_FLAG_1_OR_2 = ~FLAG_1 &