Skip to content

Question / Feature Request: First-class support for msgspec as an alternative to Pydantic #603

@alexted

Description

@alexted

Is your feature request related to a problem?

Currently, many asynchronous Python projects are moving away from Pydantic in favor of msgspec due to its superior performance in serialization and validation. While taskiq is flexible, the documentation and default examples heavily lean towards Pydantic.
I would like to clarify the current state of msgspec support and suggest making it a first-class citizen in the taskiq ecosystem.

Describe the solution you'd like

  1. Compatibility: Are there any known architectural constraints that prevent using msgspec.Struct for task arguments and result schemas instead of Pydantic models?
  2. Encoders: Is there a recommended way to implement a custom TaskiqEncoder using msgspec to ensure minimal overhead during task serialization?
  3. Validation: Does the library plan to provide a built-in MsgspecBroker or similar integration to bypass Pydantic's validation logic entirely?

Describe alternatives you've considered

It would be great to have:

  • An official taskiq-msgspec package or a dedicated encoder implementation.
  • Documentation/examples showing how to define tasks using msgspec.Struct without triggering Pydantic-based validation under the hood.
  • Benchmarks or a "performance-first" guide for users who prioritize speed and low memory footprint.

Additional context

For high-load backend systems, reducing the serialization overhead is critical. msgspec is often 10-80x faster than Pydantic, and having it as a seamless alternative would make taskiq the go-to choice for performance-critical distributed tasks.

Which component would this affect?

Other

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions