You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PERF]: Use a list for lookup in contiguous FastEnums #1637
Our FastEnum implementation (and our usage of stdlib.enum.IntEnum before that) uses a dictionary from integers to a singleton enum value to return an enum from C (which is a simple int) to Python (which is a value/name pair of a specific type).
For enums where all of the values are contiguous starting at zero, (which we could determine at code-generation time) we could instead use a list for this mapping which would provide O(1) lookup.
Activity
leofang commentedon Feb 18, 2026
We'll need to ensure the codegen checks for this. In many cases library teams like to leave holes lol
mdboom commentedon Feb 19, 2026
Oh, yes, indeed. Many are contiguous, but a lot of them aren't. And a lot are "bit flags", too.
No measurable improvement with this change, so closing.