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 — [C API] Add explicit support for Cython to the C API · Issue #89410 · python/cpython

[C API] Add explicit support for Cython to the C API #89410

New issue
Copy link
New issue
Copy link
Open
Open
[C API] Add explicit support for Cython to the C API#89410
Copy link
Labels
topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

@markshannon
markshannon
opened on Sep 20, 2021
Issue body actions
BPO 45247
Nosy @scoder, @vstinner, @markshannon, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-09-20.10:59:47.125>
labels = ['expert-C-API', 'type-feature']
title = '[C API] Add explicit support for Cython to the C API'
updated_at = <Date 2022-02-23.15:21:36.827>
user = 'https://github.com/markshannon'

bugs.python.org fields:

activity = <Date 2022-02-23.15:21:36.827>
actor = 'vstinner'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['C API']
creation = <Date 2021-09-20.10:59:47.125>
creator = 'Mark.Shannon'
dependencies = []
files = []
hgrepos = []
issue_num = 45247
keywords = []
message_count = 7.0
messages = ['402224', '403812', '403819', '403821', '403823', '403894', '413804']
nosy_count = 4.0
nosy_names = ['scoder', 'vstinner', 'Mark.Shannon', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue45247'
versions = []

Activity

  1. markshannon commented on Sep 20, 2021

    @markshannon
    markshannon
    on Sep 20, 2021
    MemberAuthor
    More actions

    As the C API has evolved it has grown features in an ad-hoc way, driven by the needs to whoever has bothered to add the code.

    Maybe we should be a bit more principled about this. Specifically we should make sure that there is a well defined interface between CPython and the other major components of the Python ecosystem.
    The obvious places to start are with Cython and Numpy.

    This issue deals specifically with Cython. I will leave it to someone who know more about Numpy to open an issue for Numpy.

    Matching Cython issue: cython/cython#4382

    This issue is an attempt to stop the annual occurrence of bugs like https://bugs.python.org/issue43760#msg393401

  2. markshannon
    added
    topic-C-API
    type-featureA feature request or enhancementA feature request or enhancement
    on Sep 20, 2021
  3. vstinner commented on Oct 13, 2021

    @vstinner
    vstinner
    on Oct 13, 2021
    Member
    More actions

    We need to add C API to abstract access to structures used by Cython:

    • bpo-39947: PyThreadState
    • bpo-40421: PyFrameObject
  4. vstinner
    changed the title [-]Add explicit support for Cython to the C API.[/-] [+][C API] Add explicit support for Cython to the C API[/+] on Oct 13, 2021
  5. markshannon commented on Oct 13, 2021

    @markshannon
    markshannon
    on Oct 13, 2021
    MemberAuthor
    More actions

    I disagree. All that is doing is locking in the current poor interface.

    We do need to extend the C API for these uses, yes. But we need an API that addresses Cython's needs directly and at a higher level.

    For example, Cython often wants to insert a frame into the call stack for debugging and introspection.

    Rather than have Cython laboriously create a Python frame with fake code object, etc., it would make much more sense for us to offer an API to insert a "native" frame into the stack and update the line number.

    E.g. something like:

    int PushNativeFrame(const char *filename);
    void PopNativeFrame(void);
    int CurrentNativeFrame_SetLineNumber(int lineno);

    We might even want to use such an API ourselves in some modules.

  6. vstinner commented on Oct 13, 2021

    @vstinner
    vstinner
    on Oct 13, 2021
    Member
    More actions

    Rather than have Cython laboriously create a Python frame with fake code object, etc., it would make much more sense for us to offer an API to insert a "native" frame into the stack and update the line number.

    I agree with that.

  7. serhiy-storchaka commented on Oct 13, 2021

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 13, 2021
    Member
    More actions

    I agree with Mark. Instead of exposing internal details in low-level API we should add more high-level API to satisfy concrete needs. It will give us more freedom of changing internals in future.

  8. vstinner commented on Oct 14, 2021

    @vstinner
    vstinner
    on Oct 14, 2021
    Member
    More actions

    My first attempt: Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing()
    #28542

    It adds an abstraction on accesses to PyThreadState.tracing and PyThreadState.cframe.use_tracing members.

  9. vstinner commented on Feb 23, 2022

    @vstinner
    vstinner
    on Feb 23, 2022
    Member
    More actions

    I created bpo-46836: "[C API] Move PyFrameObject to the internal C API".

  10. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  11. vstinner commented on Dec 20, 2023

    @vstinner
    vstinner
    on Dec 20, 2023
    Member
    More actions

    I closed #107076 as a duplicate of this issue.

  12. vstinner commented on Oct 9, 2025

    @vstinner
    vstinner
    on Oct 9, 2025
    Member
    More actions

    See also:

    • Provide a C API for introspectable frames for Cython and similar tools #90063
    • Add PyFrame_SetLineNumber() for Cython #118720
    • Cython cannot use "pycore_frame.h" in Py3.14a4 #130931
  13. vstinner commented on Oct 9, 2025

    @vstinner
    vstinner
    on Oct 9, 2025
    Member
    More actions

    @da-woods created a list of Python internals used by Cython in 2022: cython/cython#4635

  14. vstinner
    marked C API: Cython 3.0 uses private functions removed in Python 3.13 (numpy 1.25.1 fails to build) #107076 as a duplicate of this issue on Oct 15, 2025
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

    topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

    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.