This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: binary formats for marshalling floats
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: mwh Nosy List: mwh, tim.peters
Priority: normal Keywords: patch

Created on 2005-04-11 19:50 by mwh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
marshal-binary-float.diff mwh, 2005-04-11 19:50 mwh patch #2
marshal-binary-float-2.diff mwh, 2005-04-12 17:24 *this* is patch 2!
marshal-binary-float-3.diff mwh, 2005-04-14 07:53 mwh patch #3
Messages (5)
msg48195 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-04-11 19:50
This patch makes marshal.c use a binary format for floats when 
version > 1 using _PyFloat_Pack8, _PyFloat_Unpack8 (as 
suggested on python-dev).

It doesn't actually update the default version yet, so you have to be 
explicit about it:

>>> marshal.dumps(1.0, 2) 
'g\x00\x00\x00\x00\x00\x00\xf0?'

This almost certainly falls in the realm of platform-depedent accident 
-- what does frexp do with special values? -- but on my system:

>>> inf = 1e308*1e308
>>> inf
inf
>>> marshal.dumps(inf, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: unmarshallable object

msg48196 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-04-11 20:10
Logged In: YES 
user_id=31435

Yes, C89 says nothing about what frexp() does in the 
presence of infinities, NaNs or signed zeroes.  That's why 
whether pickling/unpickling (proto >= 1), or struct 
packing/unpacking (std mode), such things appears to work-- 
or how it fails --have always been platform-dependent 
accidents,
msg48197 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-04-12 17:24
Logged In: YES 
user_id=6656

New patch.  This attacks error handling in unmarshalling code objects to 
be more likely to reflect the real reason unmarshalling fails, and updates 
the default marshal version to 2.

Combined with my float packing changes this gives us a much more 
coherent float marshalling/unmarshalling story.
msg48198 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-04-14 07:53
Logged In: YES 
user_id=6656

New patch.  Main difference is updating MAGIC.
msg48199 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-06-03 14:53
Logged In: YES 
user_id=6656

Checked this in as:

Include/marshal.h revision: 2.15
Python/marshal.c revision: 1.83
Python/import.c revision: 2.242
Lib/test/test_marshal.py revision: 1.9
Misc/NEWS revision: 1.1297
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41846
2005-04-11 19:50:33mwhcreate