Skip to content

Add a 'Bypass' type that just concatenates its contents to output#661

Open
marcoffee wants to merge 1 commit into
msgpack:mainfrom
marcoffee:feature/bypass
Open

Add a 'Bypass' type that just concatenates its contents to output#661
marcoffee wants to merge 1 commit into
msgpack:mainfrom
marcoffee:feature/bypass

Conversation

@marcoffee

@marcoffee marcoffee commented Feb 13, 2026

Copy link
Copy Markdown

This is a very useful feature for when you have a class that know how to convert its structure to msgpack (specially from compiled modules) and you don't want to have its contents converted to the binary object by returning the converted msgpack from default.

As an example, orjson has a similar feature, which they call Fragment.

Some use cases include, but are not limited to:

  • bypassing valid msgpack data from compiled classes (specially deep classes, with many subclasses, dicts, lists)
  • caching msgpack output when you need to serialize a class multiple times on the same or different calls
  • appending an already serialized payload to a new payload (such as including it on a list or as a value on a dict)

PS: Sorry for closing and reopening it, I had some failed linter tests and wanted to fix them, but ended up pushing a version without any changes, which triggered GitHub's auto close feature.

@marcoffee marcoffee force-pushed the feature/bypass branch 4 times, most recently from 924c6f0 to e4ec35b Compare May 11, 2026 17:40
@methane

methane commented Jun 12, 2026

Copy link
Copy Markdown
Member

ja: JSONの中にJSONをネストするにはエスケープが必要になりますが、msgpackの中にmsgpackをネストして格納する場合はエスケープが必要ありません。
en: To nest JSON within JSON, escaping is required, but when nesting msgpack within msgpack, escaping is not necessary.

ja: そのため、このようなハックが有効になるようなデータを扱う場合は、msgpackをネストすることが良いプラクティスになります。
en: Therefore, when dealing with data that benefits from such a hack, nesting msgpack becomes a good practice.

ja: それでもこの機能が必要だと思うのであれば、同様の機能を実装している他のmsgpack実装を複数紹介してください。少なくとも1つはPython以外の言語用のライブラリを選んでください。
en: If you still believe this feature is necessary, please provide multiple examples of other msgpack implementations that have similar functionality. At least one of them should be a library for a language other than Python.

ja: もし他にこの機能を実装しているmsgpack実装が見つからず、それでもこの機能が本当に必要なんだと強く確信しているのであれば、その確信を私に伝えるための十分な根拠を提供してください。

en: If you cannot find any other msgpack implementations that have this feature, and you are still strongly convinced that this feature is truly necessary, please provide sufficient evidence to convince me of your conviction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants