[Python-Dev] PEP 3188: Implementation Questions

Thomas Heller theller at ctypes.org
Fri Feb 26 08:32:07 CET 2010


Meador Inge schrieb:
> Hi All,
> 
> Recently some discussion began in the issue 3132 thread (
> http://bugs.python.org/issue3132) regarding
> implementation of the new struct string syntax for PEP 3118.  Mark Dickinson
> suggested that I bring the discussion on over to Python Dev.  Below is a
> summary
> of the questions\comments from the thread.
> 
> Unpacking a long-double
> ===================
> 
> 1. Should this return a Decimal object or a ctypes 'long double'?
> 2. Using ctypes 'long double' is easier to implement, but precision is
>     lost when needing to do arithmetic, since the value for cytpes 'long
> double'
>     is converted to a Python float.
> 3. Using Decimal keeps the desired precision, but the implementation would
>     be non-trivial and architecture specific (unless we just picked a
>     fixed number of bytes regardless of the architecture).
> 4. What representation should be used for standard size and alignment?
>     IEEE 754 extended double precision?

A variant of 2. would be to unpack into a ctypes 'long double',
and extend the ctypes 'long double' type to retrive the value as
Decimal instance, in addition to the default conversion into a
Python float.

-- 
Thanks,
Thomas



More information about the Python-Dev mailing list