GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support for numpy buffer format `Zf` and `Zd` · Issue #148675 · python/cpython

Add support for numpy buffer format Zf and Zd #148675

New issue
Copy link
New issue
Copy link
Closed
Closed
Add support for numpy buffer format Zf and Zd#148675
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@vstinner
vstinner
opened on Apr 17, 2026
Issue body actions
  • Python 3.14 added D and F formats to the ctypes and struct module
  • Python 3.15 adds D and F formats to the array module and to memoryview

The D and F formats were chosen for compatibility with numpy. Problem: in fact, numpy uses buffer formats Zd and Zf. Example:

>>> import numpy as np
>>> memoryview(np.array([1, 2, 3], dtype='F')).format
'Zf'
>>> memoryview(np.array([1, 2, 3], dtype='D')).format
'Zd'

So I propose adding support for Zd and Zf formats in array, ctypes, memoryview and struct. It requires changing the code expecting a single character to now accept a string (Zd and Zf have 2 characters!).

Linked PRs

  • gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct #148676
  • gh-148675: Revert GH-146237 and GH-146241 #148674
  • gh-148675: Remove F and D formats from array and memoryview #149368
  • gh-148675: Optimize arraydescr structure: use char[3] #149455
  • gh-148675: Use a string for ctypes cparam tag #149778
  • gh-148675: Reuse typecodes for array.array() error message #149779
  • [3.15] gh-148675: Use a string for ctypes cparam tag (GH-149778) #149869

Activity

Next
  1. vstinner
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Apr 17, 2026
  2. vstinner
    added 2 commits that reference this issue on Apr 17, 2026

    pythongh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct

    fcd568f

    pythongh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct

    d50838d
  3. vstinner commented on Apr 17, 2026

    @vstinner
    vstinner
    on Apr 17, 2026
    MemberAuthor
    More actions

    This issue was escalated to the Steering Council: Decide buffer protocol format string for complex numbers.

  4. skirpichev commented on Apr 17, 2026

    @skirpichev
    skirpichev
    on Apr 17, 2026
    Member
    More actions

    The D and F formats were chosen for #132827. Problem: in fact, numpy uses buffer formats Zd and Zf.

    In fact, numpy uses both. So, 'F'/'D' codes does make sense for the ctypes module, at least. If SC approves the compatibility break - we can change buffer formats to Zd/Zf in the ctypes module.

    So I propose adding support for Zd and Zf formats in array, ctypes, memoryview and struct. It requires changing the code expecting a single character to now accept a string (Zd and Zf have 2 characters!).

    I think it's better to revert changes for array and memoryview (#148674) and leave problem for a new champion, who will make a PEP with a proper extension of the struct format string for new types.

    Reacted by Petr Viktorin
  5. StanFromIreland
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 17, 2026
  6. encukou
    added
    release-blocker
    on May 4, 2026
  7. github-project-automation
    added this to Release and Deferred blockers 🚫on May 4, 2026
  8. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on May 4, 2026
  9. vstinner
    added 2 commits that reference this issue on May 4, 2026

    gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct (#1…

    6e6f905

    pythongh-148675: Remove F and D formats from array and memoryview

    80fe449
  10. encukou
    added a commit that references this issue on May 4, 2026

    gh-148675: Remove F and D formats from array and memoryview (GH-149368)

    5dd5c8b
  11. hugovk commented on May 4, 2026

    @hugovk
    hugovk
    on May 4, 2026
    Member
    More actions

    Are we all done here for 3.15?

  12. encukou commented on May 5, 2026

    @encukou
    encukou
    on May 5, 2026
    Member
    More actions

    For b1, yes. The Steering Council will need to discuss this, later.

    Reacted by Hugo van Kemenade
  13. encukou
    removed
    release-blocker
    on May 5, 2026
  14. 9 remaining items

  15. scoder
    added 4 commits that reference this issue on May 7, 2026

    Warn about C API/ABI instability in array.array docs (GH-7669)

    df942af

    Adapt array module declarations Python 3.15 changes (GH-7659)

    8885de1

    Adapt array module declarations Python 3.15 changes (GH-7659)

    a470483

    Warn about C API/ABI instability in array.array docs (GH-7669)

    d234073
  16. vstinner
    added 4 commits that reference this issue on May 13, 2026

    pythongh-148675: Use a string for ctypes cparam tag

    f40bea4

    gh-148675: Reuse typecodes for array.array() error message (#149779)

    a8ef467

    gh-148675: Use a string for ctypes cparam tag (#149778)

    3ecca22

    [3.15] gh-148675: Use a string for ctypes cparam tag (GH-149778) (#14…

    cc624f7
  17. vstinner commented on May 18, 2026

    @vstinner
    vstinner
    on May 18, 2026
    MemberAuthor
    More actions

    Add support for numpy buffer format Zf and Zd

    The initial issue has been implemented. For further work, please open new issue. I close this one.

  18. vstinner
    closed this as completedon May 18, 2026
  19. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on May 18, 2026
  20. serge-sans-paille
    added 4 commits that reference this issue on May 30, 2026

    Fix typing of array.typecodes for Python 3.15

    1c51239

    Fix typing of array.typecodes for Python 3.15

    800028b

    Fix typing of array.typecodes for Python 3.15

    abbfde1

    Fix typing of array.typecodes for Python 3.15

    1165bb0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.