
Guido van Rossum wrote:
Guido van Rossum wrote:
I'm a little surprised. Raymond Hettinger checked in a change that makes all slices of buffer objects return strings. His comments on SF bug 546434 say that only one person replied and that they agreed returning strings was the better solution. But that's not how I read the only response to his query that I see in python-dev, from Scott Gilbert:
Interesting. I must have skipped that message.
You blink, and you find that the world has changed.
Indeed :-)
IMHO, all slices of buffer object should return buffer objects, but since all Python releases return strings, I guess this is too late to change.
That was my preference too, but Raymond disagreed and somehow tried to find support for his position :-).
Since buffer objects (of course :-) support the C-level buffer protocol, they can still be used in most places where strings are needed. But it would be incompatible. But so is Raymond's solution (because it changes buffer()[:] to also return a string).
Note that the only case where a buffer object is returned in Python 2.x (x < 3) is if you write buffer()[:], i.e. you want a copy of the buffer object.
What does a copy of a buffer object buy you?
Nothing... since you only get a new reference, not an independent copy.
It's not too late to revert Raymond's changes.
Why not try the buffer slice returns buffer logic for a few alphas, then betas, and then if noone complains the final release ? -- Marc-Andre Lemburg CEO eGenix.com Software GmbH _______________________________________________________________________ eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,... Python Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/