Skip to content

[Feature]: Implement zero-copy conversion for NumPy arrays to Image #675

@sidd-27

Description

@sidd-27

Title: Implement zero-copy conversion for NumPy arrays to Image

Description

The impl_pyarray_to_image macro currently performs a deep copy when converting Python NumPy arrays to Rust Image structs:

// TODO: we should find a way to avoid copying the data
let data = match pyarray.to_vec() { ... }

Calling to_vec() allocates new memory on the Rust heap and copies the entire image buffer. For high-resolution images or video streams, this introduces significant latency and doubles memory usage.

The goal is to resolve the TODO by implementing a mechanism (such as a custom Storage or Allocator backend) that allows the Rust Image struct to reference the existing Python memory buffer directly without taking ownership or performing a copy.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is neededtriagewait for a maintainer to approve and assign this ticket

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions