You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any chance of adding hooks to support extension types? This would basically require an API where callers could specify two callback functions one for encoding and one for decoding. Then mp_encode_lua_type and mp_decode_to_lua_type would call these functions to produce the actual values to be used when serializing.
Examples of two different ways this can be done for msgpack-python are below
I'm reading about the EXT type, there are two aspects; EXT with existing MsgPack Types, and EXT with custom types. The R implementation seems to understand this best and uses EXT to encode raw vectors, at least for numeric types (not sure about custom types). The Python implementation IMO is missing that aspect (the existing MsgPack Types).
mp_unpack could likely handle the EXT for existing types without any modification to the interface. For mp_pack it's a bit tricky, exactly how to pass the EXT Type, especially in the case of nested Tables, but also considering an unpack/pack sequence where type should be maintained.
One possibility might be to use a "weak table" (similar to how Lua stores array size: https://www.lua.org/pil/contents.html#17) and place the EXT Type in that table, either during mp_unpack, or explicitly before calling mp_pack. Now, perhaps that same mechanism could be used for decode functions which would open up support for custom types.
That would neatly deal with nested tables as well as custom types.
Any chance of adding hooks to support extension types? This would basically require an API where callers could specify two callback functions one for encoding and one for decoding. Then
mp_encode_lua_type
andmp_decode_to_lua_type
would call these functions to produce the actual values to be used when serializing.Examples of two different ways this can be done for msgpack-python are below
https://pypi.python.org/pypi/msgpack-python#packing-unpacking-of-custom-data-type
https://pypi.python.org/pypi/msgpack-python#extended-types
The text was updated successfully, but these errors were encountered: