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

SourceForge.net noreply at sourceforge.net
Thu Apr 14 09:53:37 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

Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Nobody/Anonymous (nobody)
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-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