-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct #148676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d50838d
c54e5b4
a13a47a
54d634f
af51fd9
fe496e9
cf16b04
69c7e1a
0381b67
374ddde
869cd88
52846d1
fab34a9
6753bae
5e1281d
5cf4fcc
88b64b9
3de82a7
f24e08a
7cd717e
c7840fa
1a77688
35a4691
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,6 +264,10 @@ platform-dependent. | |
| +--------+--------------------------+--------------------+----------------+------------+ | ||
| | ``D`` | :c:expr:`double complex` | complex | 16 | \(10) | | ||
| +--------+--------------------------+--------------------+----------------+------------+ | ||
| | ``Zf`` | :c:expr:`float complex` | complex | 8 | \(10) | | ||
| +--------+--------------------------+--------------------+----------------+------------+ | ||
| | ``Zd`` | :c:expr:`double complex` | complex | 16 | \(10) | | ||
| +--------+--------------------------+--------------------+----------------+------------+ | ||
|
Comment on lines
+267
to
+270
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest leave one entry per data type with either one-letter or two-letters code. And mention an alternative in the note, perhaps with a deprecation. Technically, no new types here - just aliases.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer this decision after Python 3.15 beta1, and don't put any preference for now in the beta1. |
||
| | ``s`` | :c:expr:`char[]` | bytes | | \(9) | | ||
| +--------+--------------------------+--------------------+----------------+------------+ | ||
| | ``p`` | :c:expr:`char[]` | bytes | | \(8) | | ||
|
|
@@ -280,6 +284,9 @@ platform-dependent. | |
| .. versionchanged:: 3.14 | ||
| Added support for the ``'F'`` and ``'D'`` formats. | ||
|
|
||
| .. versionchanged:: next | ||
| Added support for the ``'Zf'`` and ``'Zd'`` formats. | ||
|
|
||
| .. seealso:: | ||
|
|
||
| The :mod:`array` and :ref:`ctypes <ctypes-fundamental-data-types>` modules, | ||
|
|
@@ -372,7 +379,7 @@ Notes: | |
| For the ``'F'`` and ``'D'`` format characters, the packed representation uses | ||
| the IEEE 754 binary32 and binary64 format for components of the complex | ||
| number, regardless of the floating-point format used by the platform. | ||
| Note that complex types (``F`` and ``D``) are available unconditionally, | ||
| Note that complex types (``F``/``Zf`` and ``D``/``Zd``) are available unconditionally, | ||
| despite complex types being an optional feature in C. | ||
| As specified in the C11 standard, each complex type is represented by a | ||
| two-element C array containing, respectively, the real and imaginary parts. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These
_type_codes were added in 3.14; wouldn't changing them break backwards compatibility?Maybe in 3.16 we can deprecate the
_type_attribute itself and replace it with something better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change on purpose and it's documented in What's New in Python 3.15 and in the ctypes documentation.
If you use
c_double_complex,c_float_complexandc_longdouble_complexof thectypesmodule, you shouldn't notice the_type_change (it just works). If you create your own types by inherit from_SimpleCData, usingF,DorGtype no longer works with this change: you have to update your code toZf,ZdandZgformats.