[Python-Dev] The buffer() function (original) (raw)
James Y Knight foom at fuhm.net
Thu Jul 13 20:36:59 CEST 2006
- Previous message: [Python-Dev] The buffer() function
- Next message: [Python-Dev] Community buildbots (was Re: User's complaints)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] The buffer() function
- Next message: [Python-Dev] Community buildbots (was Re: User's complaints)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]