[Patches] [ python-Patches-1180995 ] binary formats for marshalling floats

SourceForge.net noreply at sourceforge.net
Fri Jun 3 16:53:30 CEST 2005


Patches item #1180995, was opened at 2005-04-11 20:50
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1180995&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Michael Hudson (mwh)
>Assigned to: Michael Hudson (mwh)
Summary: binary formats for marshalling floats

Initial Comment:
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



----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2005-06-03 15:53

Message:
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


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2005-04-14 08:53

Message:
Logged In: YES 
user_id=6656

New patch.  Main difference is updating MAGIC.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2005-04-12 18:24

Message:
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.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2005-04-11 21:10

Message:
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,

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1180995&group_id=5470


More information about the Patches mailing list