Make message.to_dict() return bytes for DATA type field
#386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is for resolving the issue Regression in 2.2.0: yaml.dump can no longer save capnp messages with Data type fields #385
And also trying to resolve the issue PyPI 2.2.0 source distribution missing PyCustomMessageBuilder.h #384
Background
Cap’n Proto’s C++ layer exposes Data fields as pointers into the message’s memory. Returning bytes forces an immediate copy of that buffer. To avoid that expensive copy (which is a real performance and memory bottleneck for large messages), I made it return a memoryview instead of bytes.
However, memoryview is subject to the limitation that they cannot be pickled, but in C++ this is unnecessary.
This can be resolved by modifying the message.to_dict() method, without needing change to user's code.
Please note that the changes in the test case are simply a rollback, not the introduction of any new modifications.
For the
manylinux2014issue, I added thepy_custom_message_builder.hto the binary output. Hopefully it can resolve the issue, but I cannot find a way to validate it.