[Numpy-discussion] restricting object arrays to a single Python type
Geoffrey Irving
irving at naml.us
Tue Jul 16 19:44:37 EDT 2013
Is there a standard way of creating an object array restricted to a
particular python type? I want a safe way of sending arrays of
objects back and forth between Python and C++, and it'd be great if I
could use numpy arrays on the Python side instead of creating a new
type.
For example, I might have a C++ class Force which is simultaneously a
valid Python extension type (also named "Force"). I'd like to be able
to switch between Array<Force> on the C++ side and a suitable numpy
array on the Python side, while preventing Python from ever storing an
object with different type (say, a tuple) in the array. Note that
Array<Force> has the memory representation of an array of PyObject*'s.
Thanks,
Geoffrey
More information about the NumPy-Discussion
mailing list