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> &lt;<a href="mailto:guido@python.org">
guido@python.org</a>&gt; 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&#39;s a huge patch to land so close before a release. I&#39;m not sure I
<br>like the immutability API -- it won&#39;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&#39;ve removed the immutable support in the most recent patch.&nbsp; i still think it -might- be useful but isn&#39;t required and you&#39;re right that it could open a can of worms if people think it should also mean hashable.&nbsp; 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&#39;t understand the comment about using PyBUF_WRITABLE in<br>_getbuffer() -- this is only used for data we&#39;re *reading* and I don&#39;t
<br>think the GIL is even released while we&#39;re reading such things.</blockquote><div><br>that appears to be correct.&nbsp; the comment was wrong.&nbsp; 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&#39;s important to get this in the 3.0a1 release, we<br>should pair-program on it ASAP, preferable tomorrow morning.<br>Otherwise, let&#39;s do a review next week.<br><br>--Guido<br><br>On 8/29/07, Gregory P. Smith &lt;
<a href="mailto:greg@krypto.org">greg@krypto.org</a>&gt; wrote:<br>&gt; Attached is what I&#39;ve come up with so far.&nbsp;&nbsp;Only a single field is<br>&gt; added to the PyBytesObject struct.&nbsp;&nbsp;This adds support to the bytes<br>
&gt; object for PyBUF_LOCKDATA buffer API operation.&nbsp;&nbsp;bytes objects can be<br>&gt; marked temporarily read-only for use while the buffer api has handed<br>&gt; them off to something which may run without the GIL (think IO).&nbsp;&nbsp;Any
<br>&gt; attempt to modify them during that time will raise an exception as I<br>&gt; believe Martin suggested earlier.<br>&gt;<br>&gt; As an added bonus because its been discussed here, support for setting<br>&gt; a bytes object immutable has been added since its pretty trivial once
<br>&gt; the read only export support was in place.&nbsp;&nbsp;Thats not required but was<br>&gt; trivial to include.<br>&gt;<br>&gt; I&#39;d appreciate any feedback.<br>&gt;<br>&gt; My TODO list for this patch:<br>&gt;<br>&gt;&nbsp;&nbsp;0. Get feedback and make adjustments as necessary.
<br>&gt;<br>&gt;&nbsp;&nbsp;1. Deciding between PyBUF_SIMPLE and PyBUF_WRITEABLE for the internal<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; uses of the _getbuffer() function.&nbsp;&nbsp;bytesobject.c contains both readonly<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; and read-write uses of the buffers, i&#39;ll add boolean parameter for
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; that.<br>&gt;<br>&gt;&nbsp;&nbsp;2. More testing: a few tests in the test suite fail after this but the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; number was low and I haven&#39;t had time to look at why or what the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; failures were.<br>&gt;
<br>&gt;&nbsp;&nbsp;3. Exporting methods suggested in the TODO at the top of the file.<br>&gt;<br>&gt;&nbsp;&nbsp;4. Unit tests for all of the functionality this adds.<br>&gt;<br>&gt; NOTE: after these changes I had to make clean and rm -rf build before
<br>&gt; things would not segfault on import.&nbsp;&nbsp;I suspect some things (modules?)<br>&gt; were not properly recompiled after the bytesobject.h struct change<br>&gt; otherwise.<br>&gt;<br>&gt; -gps<br>&gt;<br>&gt;<br>&gt; _______________________________________________
<br>&gt; Python-3000 mailing list<br>&gt; <a href="mailto:Python-3000@python.org">Python-3000@python.org</a><br>&gt; <a href="http://mail.python.org/mailman/listinfo/python-3000">http://mail.python.org/mailman/listinfo/python-3000
</a><br>&gt; 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>&gt;<br>&gt;<br>&gt;<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>