Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d50838dc54e5b4a13a47a54d634faf51fd9fe496e9cf16b0469c7e1a0381b67374ddde869cd8852846d1fab34a96753bae5e1281d5cf4fcc88b64b93de82a7f24e08a7cd717ec7840fa1a7768835a4691File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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. MemberAuthor 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. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.