A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-February/097966.html below:

[Python-Dev] PEP 3188: Implementation Questions

[Python-Dev] PEP 3188: Implementation QuestionsGlenn Linderman v+python at g.nevcal.com
Fri Feb 26 06:12:23 CET 2010
On approximately 2/25/2010 8:51 PM, came the following characters from 
the keyboard of Meador Inge:
> 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?

Because of 2 (lossy, dependency), and 3 (non-trivial, architecture 
specific), neither choice in 1 seems appropriate.

Because of the nature of floats, because the need for manipulation may 
vary between applications, and because the required precision may vary 
between applications, I would recommend adding a 
"CLongDoubleStructWrapper" class (a better name would be welcome), which 
would copy the architecture-specific byte-stream and preserve it.  If 
converted back to a struct, it would be lossless.  If manipulation is 
required, the class could have converters to Python float (lossy), and 
Decimal of user-specifiable precision (punt the precision question to 
the application developer, who should know the needs of the application, 
and the expected platforms).

It might be reasonable to handle double and float similarly, at least as 
an option.  On the other hand, if there can be options, perhaps they 
could be given when supplying the struct string syntax.... except the 
application may only wish to manipulate a few of the long double values, 
and converting the others would be wasteful.

-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking

More information about the Python-Dev mailing list

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