Travis Oliphant wrote:
> Tim Hochberg wrote:
>   
>> Francesc Altet wrote:
>>   
>> It's not that the it's being built from ndarray, it's that the buffer 
>> that you are passing it is read only. 
>>     
> This is correct.
>   
>> In fact, I'd argue that allowing 
>> the writeable flag to be set to True in this case is actually a bug. 
>>   
>>     
> It's actually intentional.  Strings used as buffers are allowed to be 
> writeable.  This is an explicit design decision to allow pickles to load 
> without making 2 copies of the memory.   The pickled string that Python 
> creates is used as the actual memory for loaded arrays.
>
> Now, I suppose it would be possible to still allow this but be more 
> finnicky about when a string-used-as-the-memory can be set writeable 
> (i.e. we are the only reference to it).  But, this would be a fragile 
> solution as well. 
>
> My inclination is to just warn users not to use strings as buffers 
> unless they know what they are doing.  The fact that it is read-only by 
> default is enough of a guard against "accidentally" altering a string 
> you didn't want to alter.
>   
That makes sense.

Someday, when string/unicode => bytes/string, we'll be able to use the 
bytes type for this and it'll be much cleaner. But not for a while I 
imagine.

-tim



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to