News for hackers. Stuff that matters.
Re:Python 2.7.4 Released by hosay123 on Saturday April 06, 2013 @08:06PM (#5505554)
After years, better integration between the old and new buffer interfaces was finally sneaked in as a bug fix. You can now call `memoryview(some_buffer)` and it'll DTRT. The whole buffers situation is a depressing mess.
Re:Python 2.7.4 Released by pekk on Sunday April 07, 2013 @03:07AM (#5506380)
Since you have been voted to the top of the thread for this comment, can you be more concrete on your complaint?
Re:Python 2.7.4 Released by masklinn on Sunday April 07, 2013 @05:00AM (#5506574)
See http://bugs.python.org/issue10211

Basically, Python has the "buffer" object which is a 0-copy view of some memory area (lets an object expose itself as a bytes array of sorts). It's always been plagued with a number of issues.

In Python 3, `buffer` was removed and replaced with `memoryview`, which was backported to Python 2.7. But in said Python 2.7, `buffer` and `memoryview` both exist and fill very similar need so e.g. older libraries will likely return a buffer which newer code will want to use as a memoryview. No such luck, they're not compatible.

2.7.4 fixes that so you can get a memoryview from a buffer.

Re:Python 2.7.4 Released by cbsmith on Sunday April 07, 2013 @03:58AM (#5506468)
I too would like more details on this. 2.7.3 already had memoryview objects IIRC, though I found them almost as frustrating to work with as the 2.6.x world of not having them. What really changed in 2.7.4?
Re:Python 2.7.4 Released by masklinn on Sunday April 07, 2013 @04:55AM (#5506566)
In 2.7.3, you can create a buffer which is the "old" buffer interface: http://docs.python.org/2/library/functions.html#buffer

And you can create a memoryview which is the "new" and more flexible buffer interface: http://docs.python.org/2/library/stdtypes.html#typememoryvie...

You can get a buffer of a string:

    >>> buffer("foo")
    <read-only buffer for 0x1005a5ee0, size -1, offset 0 at 0x10054f270>
and a view of a string:

    >>> memoryview("foo")
    <memory at 0x100574d60>
but when you get this unhelpful and really stupid result:

    >>> memoryview(buffer("foo"))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: cannot make memory view because object does not have the buffer interface
2.7.4 fixed this so it actually works and you can get a memoryview out of an old buffer.
Re:Python 2.7.4 Released by cbsmith on Sunday April 07, 2013 @11:40PM (#5509882)
Awesome, that was precisely the kind of annoyance I remember.
Re:Python 2.7.4 Released by chubot on Sunday April 07, 2013 @12:41AM (#5506131)
I haven't played around with it, but how did it get to be a mess? As I recall it has historically been for NumPy.