Skip to content

Phase 7: Zero-copy numpy array via capsule ownership#8

Merged
ALJainProjects merged 1 commit into
mainfrom
phase7/performance-polish
Feb 9, 2026
Merged

Phase 7: Zero-copy numpy array via capsule ownership#8
ALJainProjects merged 1 commit into
mainfrom
phase7/performance-polish

Conversation

@ALJainProjects
Copy link
Copy Markdown
Owner

Summary

  • Add imagedata_to_numpy_zerocopy() that transfers ImageData ownership to a Python capsule instead of copying pixel data
  • When a transform produces an output ImageData, the numpy array now directly references the existing buffer with the capsule preventing premature deallocation
  • Used in Transform.apply() binding — eliminates one memcpy per transform call from Python
  • The existing imagedata_to_numpy() is kept for cases where the source must outlive the array

Test plan

  • Existing transform Python tests exercise the apply() path
  • Verify no memory leaks via valgrind/ASAN on transform benchmark

…transfer

Add imagedata_to_numpy_zerocopy() that transfers ImageData ownership to
a Python capsule instead of copying pixel data. When a transform produces
an output ImageData, the numpy array now directly references the existing
buffer with the capsule preventing premature deallocation.

Used in Transform.apply() binding — eliminates one memcpy per transform
call from Python. The existing imagedata_to_numpy() is kept for cases
where the source must outlive the array.
@ALJainProjects ALJainProjects merged commit 97b5e09 into main Feb 9, 2026
7 checks passed
@ALJainProjects ALJainProjects deleted the phase7/performance-polish branch February 9, 2026 00:51
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.

1 participant