On Nov 2, 2006, at 8:04 PM, Greg Ewing wrote:
>
> I think the datatype object should almost certainly
> be immutable. Since it's separated from the data
> it's describing, it's possible for one datatype
> object to describe multiple chunks of data. So
> you wouldn't want to mutate one in case it's being
> used for something else that you don't know about.
I only mentioned that the datatype object would be mutable at C level
because changing the object instead of deleting and creating a new
one could be a valid optimization in situations where the object is
know not to be shared.
My main concern was that in ctypes the size of an array is a part of
the datatype object and this seems to be redundant if used for the
buffer protocol. Buffer protocol already reports the size of the
buffer as a return value of bf_get*buffer methods.
In another post, Greg Ewing wrote:
> > numpy.array(array.array('d',[1,2,3]))
> >
> > and leave-out the buffer object all together.
> I think the buffer object in his example was just a
> placeholder for "some arbitrary object that supports
> the buffer interface", not necessarily another NumPy
> array.
Yes, thanks. In fact numpy.array(array.array('d',[1,2,3])) already
works in numpy (I think because numpy knows about the standard
library array type). In my example, I wanted to use an object that
supports buffer protocol and little else.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com