msgspec
msgspec copied to clipboard
can msgspec provide a faster enum implementation?
Description
if msgspec.Struct is faster than dataclasses, can msgspec also provide enums?
There is fastenum which claims to be faster than regular python enum. but its not written in C.
also i would like if the api didn't require the usage of auto()
Why? Unlike Struct/dataclass, normally you don't create arbitrary number of enum instances
I played some time ago trying to make faster enum. turns out that magic auto type detection is really inefficient as is. I Gained x6 on startup. (which ... is almost irrelevant considering the number and what's enum is used for. ) and had 3% on access .. which ... same.
Double class access is "slow". Don't think you'll gain that much with 2 level of struct.