Updates for v2 buffer #128
Open
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 provides updates to the SWIG wrapper to enable use of the v2 buffer, once merged in micro-manager/mmCoreAndDevices#570. These changes should provide the same performance benefits described there.
I tried to keep these changes minimal. In particular one difference from my changes to java SWIG wrapper is that I did not make higher level classes analogous to TaggedImagePointer and LazyJSONObject. Ad advantage to doing something like this is that unlike Java, the pymmcore has the additional opportunity for creating direct, zero-copy views into the v2 buffer. For example, here's how to use the SWIG wrapped objects for pointer-based image handling now:
An additional wrapping object should be able to avoid the copy in
pixels = buffer_data_pointer.getData()
, and instead return some numpy-array like object that is read-only and has a release method (or handles this automatically when garbage collected -- though that is probably less reliable).I'm not sure what the most desirable way to handle this is, so I'll defer to you @marktsuchida @tlambert03
The functions needed to implement it are already enabled:
Tests for this new API can be found here:
I'm not sure how the pymmcore version numbering works so I'll leave that to you.