A new version is attached; cleaned up and simplified based on your original comments.<br><br><div><span class="gmail_quote">On 8/29/07, <b class="gmail_sendername">Guido van Rossum</b> <<a href="mailto:guido@python.org">
guido@python.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">That's a huge patch to land so close before a release. I'm not sure I
<br>like the immutability API -- it won't be useful unless we add a hash<br>method, and then we have all sorts of difficulties again -- the<br>distinction between a hashable and an unhashable object should be made<br>
by type, not by value (tuples containing unhashable values<br>notwithstanding).</blockquote><div><br>ok i've removed the immutable support in the most recent patch. i still think it -might- be useful but isn't required and you're right that it could open a can of worms if people think it should also mean hashable. immutable bytes may be best implemented as a subclass if its ever wanted.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I don't understand the comment about using PyBUF_WRITABLE in<br>_getbuffer() -- this is only used for data we're *reading* and I don't
<br>think the GIL is even released while we're reading such things.</blockquote><div><br>that appears to be correct. the comment was wrong. fixed.<br></div><br>-gps<br><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you think it's important to get this in the 3.0a1 release, we<br>should pair-program on it ASAP, preferable tomorrow morning.<br>Otherwise, let's do a review next week.<br><br>--Guido<br><br>On 8/29/07, Gregory P. Smith <
<a href="mailto:greg@krypto.org">greg@krypto.org</a>> wrote:<br>> Attached is what I've come up with so far. Only a single field is<br>> added to the PyBytesObject struct. This adds support to the bytes<br>
> object for PyBUF_LOCKDATA buffer API operation. bytes objects can be<br>> marked temporarily read-only for use while the buffer api has handed<br>> them off to something which may run without the GIL (think IO). Any
<br>> attempt to modify them during that time will raise an exception as I<br>> believe Martin suggested earlier.<br>><br>> As an added bonus because its been discussed here, support for setting<br>> a bytes object immutable has been added since its pretty trivial once
<br>> the read only export support was in place. Thats not required but was<br>> trivial to include.<br>><br>> I'd appreciate any feedback.<br>><br>> My TODO list for this patch:<br>><br>> 0. Get feedback and make adjustments as necessary.
<br>><br>> 1. Deciding between PyBUF_SIMPLE and PyBUF_WRITEABLE for the internal<br>> uses of the _getbuffer() function. bytesobject.c contains both readonly<br>> and read-write uses of the buffers, i'll add boolean parameter for
<br>> that.<br>><br>> 2. More testing: a few tests in the test suite fail after this but the<br>> number was low and I haven't had time to look at why or what the<br>> failures were.<br>>
<br>> 3. Exporting methods suggested in the TODO at the top of the file.<br>><br>> 4. Unit tests for all of the functionality this adds.<br>><br>> NOTE: after these changes I had to make clean and rm -rf build before
<br>> things would not segfault on import. I suspect some things (modules?)<br>> were not properly recompiled after the bytesobject.h struct change<br>> otherwise.<br>><br>> -gps<br>><br>><br>> _______________________________________________
<br>> Python-3000 mailing list<br>> <a href="mailto:Python-3000@python.org">Python-3000@python.org</a><br>> <a href="http://mail.python.org/mailman/listinfo/python-3000">http://mail.python.org/mailman/listinfo/python-3000
</a><br>> Unsubscribe: <a href="http://mail.python.org/mailman/options/python-3000/guido%40python.org">http://mail.python.org/mailman/options/python-3000/guido%40python.org</a><br>><br>><br>><br><br><br>--<br>
--Guido van Rossum (home page: <a href="http://www.python.org/~guido/">http://www.python.org/~guido/</a>)<br></blockquote></div><br>