[Python-Dev] PEP 3188: Implementation Questions (original) (raw)
Meador Inge meadori at gmail.com
Fri Feb 26 05:51:13 CET 2010
- Previous message: [Python-Dev] __file__
- Next message: [Python-Dev] PEP 3188: Implementation Questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Should this return a Decimal object or a ctypes 'long double'?
- 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.
- 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).
- What representation should be used for standard size and alignment? IEEE 754 extended double precision?
Pointers
- What is a specific pointer? For example, is '&d' is a pointer to a double?
- How would unpacking a pointer to a Python Object work out? Given an address how would the appropriate object to be unpacked be determined?
- Can pointers be nested, e.g. '&&d' ?
- For the 'X{}' format (pointer to a function), is this supposed to mean a Python function or a C function?
String Syntax
The syntax seems to have transcended verbal description. I think we need to put forth a grammar. There are also some questions regarding nesting levels and mixing specifiers that could perhaps be answered more clearly by having a grammar:
- What nesting level can structures have? Arbitrary?
- The new array syntax claims "multi-dimensional array of whatever follows". Truly whatever? Arrays of structures? Arrays of pointers?
- How do array specifiers and pointer specifiers mix? For example, would '(2, 2)&d' be a two-by-two array of pointers to doubles? What about '&(2, 2)d'? Is this a pointer to an two-by-two array of doubles?
An example grammar is contained in a diff against the PEP attached to this mail. NOTE: I am not actually submitting a patch against the PEP. This was just the clearest way to present the example grammar.
Use Cases
- What are the real world use cases for these struct string extensions? These should be fleshed out and documented.
-- Meador -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20100225/f272c6d1/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: pep-3118.diff Type: application/octet-stream Size: 7378 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20100225/f272c6d1/attachment.obj>
- Previous message: [Python-Dev] __file__
- Next message: [Python-Dev] PEP 3188: Implementation Questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]