Re: [Numpy-discussion] Array interface
Magnus Lie Hetland wrote:
- Does the description of __array_data__ mean that the discussed bytes type is no longer needed? (If we can use buffers, that sounds very good to me.)
We can use the buffer object, now and it works as far as it goes. But, there are very important reasons for the creation of a good bytes object. Probably, THE most important reason for the bytes object is Pickle support without always making an intermediate string (and the accompanying copy that is involved). Right now, a string is the only way to Pickle array data. A bytes object would allow a way to Pickle without making a copy. -Travis
Travis Oliphant wrote:
Right now, a string is the only way to Pickle array data. A bytes object would allow a way to Pickle without making a copy.
So could the new array protocol allow us to make a Python String from an array without copying? That could be pretty handy. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
Chris Barker <Chris.Barker@noaa.gov>:
Travis Oliphant wrote:
Right now, a string is the only way to Pickle array data. A bytes object would allow a way to Pickle without making a copy.
So could the new array protocol allow us to make a Python String from an array without copying? That could be pretty handy.
Or treat a string as an array... Yay! :)
-Chris
-- Magnus Lie Hetland Fall seven times, stand up eight http://hetland.org [Japanese proverb]
Travis Oliphant <oliphant@ee.byu.edu>:
Magnus Lie Hetland wrote:
- Does the description of __array_data__ mean that the discussed bytes type is no longer needed? (If we can use buffers, that sounds very good to me.)
We can use the buffer object, now and it works as far as it goes. But, there are very important reasons for the creation of a good bytes object.
Probably, THE most important reason for the bytes object is Pickle support without always making an intermediate string (and the accompanying copy that is involved). Right now, a string is the only way to Pickle array data. A bytes object would allow a way to Pickle without making a copy.
Ah. Very good argument, of course. But, as I understand it, the protocol as it stands could work with buffers until we get bytes objects?
-Travis
-- Magnus Lie Hetland Fall seven times, stand up eight http://hetland.org [Japanese proverb]
participants (3)
-
Chris Barker -
Magnus Lie Hetland -
Travis Oliphant