msgspec icon indicating copy to clipboard operation
msgspec copied to clipboard

can msgspec provide a faster enum implementation?

Open aspizu opened this issue 1 year ago • 3 comments

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.

aspizu avatar Apr 30 '24 00:04 aspizu

also i would like if the api didn't require the usage of auto()

aspizu avatar Apr 30 '24 00:04 aspizu

Why? Unlike Struct/dataclass, normally you don't create arbitrary number of enum instances

rafalkrupinski avatar Jan 03 '25 12:01 rafalkrupinski

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.

ethan-0l avatar Apr 23 '25 00:04 ethan-0l