jcrist · GitHub

@jcrist

Previously we only allowed struct types to subclass from other struct
types. We now structs to include any base class that:
- Doesn't have a metaclass (this is actually a CPython restriction, and
  has nothing to do with `msgspec`).
- Doesn't define `__init__` or `__new__`.
A main use case of this is "mixin" types that add a few additional
methods, and may work on types other than structs (if they only work on
structs, the mixin should really already be a `Struct` type anyway).
For mild efficiency reasons we recommend defining `__slots__ = ()` when
possible on your mixin types to avoid allocating unnecessary space for a
`__dict__`, but this isn't required.

Read the original on github.com ↗