A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20120316/2f56f07c/attachment.html below:

<p>OK, how about using encoding=bytes (yes, the type object!)? Or &#39;bytes&#39; ?</p>
<p>--Guido van Rossum (sent from Android phone)</p>
<div class="gmail_quote">On Mar 16, 2012 2:19 PM, &quot;Merlijn van Deen&quot; &lt;<a href="mailto:valhallasw@arctus.nl">valhallasw@arctus.nl</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Guido,<br>
<br>
Let me start with thanking you for your long reply. It has clarified<br>
some points to me, but I am still not certain about some others. I<br>
hope I can clarify why I&#39;m confused about this issue in the following.<br>
<br>
First of all, let me clarify that I wrote my original mail not as &#39;the<br>
guy who wants to serialize stuff&#39; but as &#39;the guy who wonders what the<br>
best way to implement it in python is&#39;. Of course, &#39;not&#39; is a<br>
reasonable answer to that question.<br>
<br>
On 13 March 2012 23:08, Guido van Rossum &lt;<a href="mailto:guido@python.org">guido@python.org</a>&gt; wrote:<br>
&gt; That was probably written before Python 3. Python 3 also dropped the<br>
&gt; long-term backwards compatibilities for the language and stdlib. I am<br>
&gt; certainly fine with adding a warning to the docs that this guarantee<br>
&gt; does not apply to the Python 2/3 boundary. But I don&#39;t think we should<br>
&gt; map 8-bit str instances from Python 2 to bytes in Python 3.<br>
<br>
Yes, backwards compatibility was dropped, but the current pickle<br>
module tries to work around this by using a module mapping [1] and<br>
aids in loading 8-bit str instances by asking for an encoding [2].<br>
Last, but not least, we can /write/ old version pickles, for which<br>
the same module mapping is used, but in reverse. As such, the module<br>
suggests in many ways that it should be possible to interchange<br>
pickles between python 2 and python 3.<br>
<br>
&gt; My snipe was mostly in reference to the many other things that can go<br>
&gt; wrong with pickled data as your environment evolves (...)<br>
I understand your point. However, my interpretation of this issue<br>
always was &#39;if you only pickle built-in types, you&#39;ll be fine&#39; - which<br>
is apparently wrong.<br>
<br>
<br>
Essentially - my point is this: considering the pickle module is<br>
already using several compatibility tricks and considering I am not<br>
the only one who would like to read binary data from a pickle in<br>
python 3 - even though it might not be the &#39;right&#39; way to do it - what<br>
is there /against/ adding the possibility?<br>
<br>
Last but not least, this is what people are now doing instead: [1]<br>
    s = pickle.load(f, encoding=&#39;latin1&#39;)<br>
    b = s.encode(&#39;latin1&#39;)<br>
    print(zlib.decompress(b))<br>
<br>
Which hurts my eyes.<br>
<br>
In any case - again, thanks for taking the time to respond. I hope I<br>
somewhat clarified why I was/am somewhat confused on the issue, and<br>
the reasons why I think that it is still a good idea ;-)<br>
<br>
Best,<br>
Merlijn<br>
<br>
[1] <a href="http://hg.python.org/cpython/file/8b2668e60aef/Lib/_compat_pickle.py" target="_blank">http://hg.python.org/cpython/file/8b2668e60aef/Lib/_compat_pickle.py</a><br>
[2] <a href="http://docs.python.org/dev/library/pickle.html#module-interface" target="_blank">http://docs.python.org/dev/library/pickle.html#module-interface</a><br>
[3] <a href="http://stackoverflow.com/questions/4281619/unpicking-data-pickled-in-python-2-5-in-python-3-1-then-uncompressing-with-zlib" target="_blank">http://stackoverflow.com/questions/4281619/unpicking-data-pickled-in-python-2-5-in-python-3-1-then-uncompressing-with-zlib</a><br>

</blockquote></div>



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4