Skip to content

msgpack.Encoder flag to skip any coercion of data types not native to the encoding #734

Open
@nfcampos

Description

@nfcampos

Description

Hi

This library is great, well documented and well thought-out, thanks for the work you've put into it!

I'm the lead maintainer of https://github.com/langchain-ai/langgraph and was considering using msgspec to power serialization of the checkpoints. Checkpoints snapshot the current state of the computation in LangGraph, and as such contain custom python objects, for which we don't have a schema. We serialize these as a tuple containing a reference to the constructor, and the arguments needed to recreate it after deserialization.

Would you consider adding a flag to the msgpack Encoder in the library to send any types that dont map 1:1 to msgpack types to enc_hook? This would enable us to use your library, as we then encode those types as msgpack extension types. Without this flag, for instance when a users values contain a uuid they get back a string, when it contains a set they get back a list, when it contains an enum value they get back the value (eg a string).

You can see here how we serialize to msgpack langchain-ai/langgraph#1716 currently using a slower library that doesn't coerce types

We wouldn't need any changes to the Decoder interface, that one already covers our needs with ext_hook

Thanks
Nuno

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions