A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-July/067371.html below:

[Python-Dev] The buffer() function

[Python-Dev] The buffer() functionJames Y Knight foom at fuhm.net
Thu Jul 13 20:36:59 CEST 2006
On Jul 13, 2006, at 12:52 PM, Thomas Heller wrote:

> IIUC, the buffer object was broken some time ago, but I think it has
> been fixed.  Can the 'status' of the buffer function be changed?
> To quote the next question from the OP:
>
>   "Is buffer safe to use?  Is there an alternative?"
>
> My thinking is that it *is* safe to use, and that there is
> no alternative (but imo also no alternative is needed).

I believe it's safe, except when used on an array.array object.  
However, that's not buffer's fault, but rather a bug in the array class.

The buffer interface requires that, as long as a reference to a  
python object is alive, pointers into its buffer will not become  
invalidated. Array breaks that guarantee.

To fix this, array ought to make a sub-object that this guarantee  
_does_ hold for. And when it needs more storage, simply make a new  
sub-object with more storage. Then, the buffer's reference would be  
to the refcounted sub-object, and thus the associated memory wouldn't  
go away until the buffer was done with it.

James
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4