This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients Allan Haldane, mark.dickinson, martin.panter, meador.inge, skrah
Date 2017-12-27.14:27:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514384828.58.0.213398074469.issue26746@psf.upfronthosting.co.za>
In-reply-to
Content
I have just worked on PEP-3118 ==> Datashape translation and I have
encountered many issues similar to the ones in the PR referenced by
Allan.

It seems to me that we should simplify the PEP-3118 struct syntax as much 
as possible in order to remove any ambiguities.


I think generally that numpy's approach is the best for data interchange, so I
would propose this modified struct syntax for PEP-3118:


1) Padding is always explicit and exact, also for natively aligned types.

2) Padding is only allowed in struct fields.

3) Trailing padding is explicit.

4) If no padding is present in a struct, it is assumed to be packed with
alignment 1 for the entire struct.

5) The tuple syntax "bxL" is not supported, only the T{} syntax with
explicit field names.

6) Repetition "10s" is only allowed for bytes. "10f" is a tuple (not
supported), an array of 10 floats would be (10)f.

7) Modifiers (@, =, <, >, !) are only given for primitive data types,
not for entire structs or types.

8) Implementations are free to reject any padding that would not arise
naturally by specifying alignment or packing constraints (like gcc does 
with attributes).


Here is my implementation with a grammar:

  https://github.com/plures/ndtypes/blob/master/libndtypes/compat/bpgrammar.y

Some tests against numpy:

  https://github.com/plures/xnd/blob/master/python/test_xnd.py#L1509


I think the best way forward would be to tweak the above grammar so that
it covers everything that numpy can export.
History
Date User Action Args
2017-12-27 14:27:08skrahsetrecipients: + skrah, mark.dickinson, meador.inge, martin.panter, Allan Haldane
2017-12-27 14:27:08skrahsetmessageid: <1514384828.58.0.213398074469.issue26746@psf.upfronthosting.co.za>
2017-12-27 14:27:08skrahlinkissue26746 messages
2017-12-27 14:27:08skrahcreate