Skip to content

C API for simplifying module attribute declaration #6

Description

@erlend-aasland

Some years ago, Christian created an issue, and a proposed implementation, for C API that could reduce the amount of boiler-plate code needed when implementing extension modules. Quoting the issue description:

It's currently inconvenient and sometimes error-prone to initialize module members in C. Even stdlib modules are sometimes missing error checks or have reference counting issues in error path. I propose add three helpers to deal with common cases:

  1. declaration of simple attributes (int, str, bool, float) in an array of structs
  2. creation and addition of a new type from a type spec
  3. creation and addition a new exception object

The issue and PR received some initial interest (and I remember being positive to adding these helpers), but the discussion came to a halt after Christian took a break from CPython. Can the C API WG help decide if we should add such APIs? If you suggest these APIs are worth it to implement and maintain, I can volunteer to pick up Christan's work update the PR. If you suggest this is not worth it, we can close the issue and the PR.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions