From: Travis O. <oli...@ie...> - 2006-08-14 18:01:51
|
Travis Oliphant wrote: > However, you can use the ndarray creation function itself to do what you > want: > > a = ndarray(shape=(2,2), dtype=int32, buffer=str, order='F') > > This will use the memory of the string as the new array memory. > Incidentally, the new array will be read-only. But, you can fix this in two ways: 1) a.flags.writeable = True --- This is a cheat that avoids the extra copy on pickle-load and let's you use strings as writeable buffers. Don't abuse it. It will disappear once Python 3k has a proper bytes type. 2) a = a.copy() -Travis |