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 — Support the limited API? · Issue #183 · python/pythoncapi-compat

Support the limited API? #183

New issue
Copy link
New issue
Copy link
Closed
#184
Closed
Support the limited API?#183
#184
Copy link

Description

@ngoldbaum
ngoldbaum
opened on Oct 3, 2026
Issue body actions

pythoncapi-compat/tests/test_pythoncapi_compat_cext.c

Lines 11 to 13 in ba68139

#ifdef Py_LIMITED_API
# error "Py_LIMITED_API is not supported"
#endif
seems to indicate that adding shims for the limited API is currently out of scope for the project.

I'm curious if there's any interest in adding support here. I'd particularly like to avoid adding extensive shims to NumPy to work around issues like in numpy/numpy#32864.

Reacted by Pratham Hole

Activity

  1. vstinner
    added 2 commits that reference this issue on Oct 4, 2026

    Add support for the limited C API (Py_LIMITED_API)

    This issue will close once commit 51310e1 is merged into the 'main' branch.
    51310e1

    Add support for the limited C API (Py_LIMITED_API)

    This issue will close once commit 7aefdb2 is merged into the 'main' branch.
    7aefdb2
  2. vstinner commented on Oct 4, 2026

    @vstinner
    vstinner
    on Oct 4, 2026
    Member
    More actions

    I wrote #184 to add support for the limited C API.

  3. vstinner
    added a commit that references this issue on Oct 5, 2026

    Add support for the limited C API (Py_LIMITED_API) (#184)

    This issue will close once commit cb1eadf is merged into the 'main' branch.
    cb1eadf
  4. vstinner
    closed this as completedin #184on Oct 5, 2026
  5. vstinner commented on Oct 5, 2026

    @vstinner
    vstinner
    on Oct 5, 2026
    Member
    More actions

    It's now implemented in the main branch.

  6. vstinner commented on Oct 7, 2026

    @vstinner
    vstinner
    on Oct 7, 2026
    Member
    More actions

    @ngoldbaum: I just merged Py_SETREF()/Py_XSETREF() into Python 3.16: python/cpython@ec14f81. Do you expect that pythoncapi-compat provides new limited C API functions to older Python versions? It sounds somehow to go against limited C API, no? I expect Py_SETREF()/Py_XSETREF() to be only available in Python 3.16 limited C API, even if pythoncapi-compat. Well, I'm not sure. What do you think?

  7. ngoldbaum commented on Oct 7, 2026

    @ngoldbaum
    ngoldbaum
    on Oct 7, 2026
    ContributorAuthor
    More actions

    It sounds someone to go against limited C API, no?

    I think it goes with the intention of this repo, which allows people to adopt idioms that are added in future Python versions. It's a bad idea to use those idioms if it hasn't been added in a future version but once it has, it makes sense to use internal details to implement backward compatibility shims.

    Of course that may be difficult in practice for most things in the limited API because it will require new ABI surface. In this case, though, we can provide a shim. So I would say why not allow that?

    Without support here, NumPy would add a shim somewhere internally in NumPy that only NumPy uses and may be buggy. IMO it's better to centralize compat shims here as much as possible.

    Reacted by Pratham Hole
  8. vstinner commented on Oct 7, 2026

    @vstinner
    vstinner
    on Oct 7, 2026
    Member
    More actions

    @ngoldbaum: Hum. Supporting the limited C API on old Python versions is tricky to get it right, because of the stable ABI. I suggest to work on a case by case basis to add new limited C API to old Python versions. Py_SETREF() / Py_XSETREF() is special since it doesn't call (new) Python functions in its implementation, but only memcpy() which comes from the C library. So for these two macros, I think that it's safe to add them to old Python versions.

    I created #187 to add Py_SETREF/Py_XSETREF to old limited C API versions.

    Three years ago, I created https://github.com/vstinner/deadparrot experimental project: a shared library providing old and new Python C API functions to support all Python versions. But I didn't go far, and no one adopted it. The pythoncapi-compat "header file" approach seems to fit well developers needs and it's convenient to use (just include the header file, you're done).

    Reacted by Pratham Hole
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

    No labels
    No labels

    Projects

    No projects

      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.