Skip to content

ability to produce Cow<[_]> instead of Vec<_> #27

@ExpHP

Description

@ExpHP

If you want to get e.g. &[f64] from an NPY file, you currently need to call NpyData::to_vec, but chances are that opened files are created at memory addresses with pretty big alignment, and the internal data of the NPY is most likely such that the data will already be aligned to any reasonable size.

Should also check endianness of course.

We could have an unsafe trait to allow NpyData to produce Cow for a type, using Cow::Borrowed whenever the data is already sufficiently aligned. (It should be unsafe because it will need to transmute a byte slice, which has all sorts of safety implications...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions