Skip to content

Make PyImath array objects use the buffer protocol #367

Open
@tbttfox

Description

@tbttfox

I think the python imath *Array objects should implement the python buffer protocol to allow for fast IO.

Right now all we have is imathnumpy, which is a not-even-half-implemented module that requires the numpy library to use. And numpy isn't always available (I'm looking at you, Windows Maya). This means that any data IO must go through python lists to make portable code. This can be between 20x and 100x slower than imathnumpy depending on implementation.

The python buffer protocol is strided. So since FixedArray already stores the data contiguous+strides, and the Imath classes are contiguous (at least at first glance), it seems it would be straightforward to build and read memoryview(for Python 3 compatibility) objects through some added methods.

Then imathnumpy could be removed/deprecated, because numpy supports reading directly from python buffers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature RequestA suggested change or addition of functionality to the library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions