Skip to content

[C API] Move private PyCode and PyOptimizer API to the internal C API #120642

Description

@vstinner

The private PyCode and PyOptimizer APIs use "unnamed structs/unions" which are not allowed in ISO C99: see #120293.

I propose to move private PyCode and PyOptimizer APIs to the internal C API.

6 PyUnstable optimizer functions are moved to the internal C API:

  • PyUnstable_Replace_Executor()
  • PyUnstable_SetOptimizer()
  • PyUnstable_GetOptimizer()
  • PyUnstable_GetExecutor()
  • PyUnstable_Optimizer_NewCounter()
  • PyUnstable_Optimizer_NewUOpOptimizer()

Linked PRs

Activity

  1. added a commit that references this issue on Jun 17, 2024
  2. ronaldoussoren commented on Jun 17, 2024

    @ronaldoussoren
    Contributor

    These functions were added in #104584, and may be intended as an API used by other JITs as well (possibly with some changes).

  3. vstinner commented on Jun 17, 2024

    @vstinner
    MemberAuthor

    These functions were added in #104584, and may be intended as an API used by other JITs as well (possibly with some changes).

    These functions are still exported, but the few other JITs would have to update their code to include pycore_optimizer.h. Is it ok?

  4. ronaldoussoren commented on Jun 19, 2024

    @ronaldoussoren
    Contributor

    These functions were added in #104584, and may be intended as an API used by other JITs as well (possibly with some changes).

    These functions are still exported, but the few other JITs would have to update their code to include pycore_optimizer.h. Is it ok?

    I don't know. @markshannon added these function and may have an opinion on this.

  5. vstinner commented on Jun 20, 2024

    @vstinner
    MemberAuthor

    @iritkatriel @brandtbucher @Fidget-Spinner: Do you know anyone using these unstable functions outside Python itself? They were added to Python 3.13. I propose to move them to <pycore_optimizer.h>. In short, are you ok with #120643 ?

    I prefer to move private APIs to the internal C API, and the API is causing C99 compatibility issues in strict mode (pedantic).

  6. Fidget-Spinner commented on Jun 20, 2024

    @Fidget-Spinner
    Member

    From what I am aware of, I don't know anyone using these APIs outside of Python itself. However, they are meant to be used as unstable APIs, so not sure where they are supposed to go normally?

  7. markshannon commented on Jun 20, 2024

    @markshannon
    Member

    I think it is fine to remove them, as no one is using this API.
    If there is interest in the future for plug in optimizers, we would probably want to offer a quite different API that allowed plugins to add additional passes, rather replace the whole of tier 2.

  8. vstinner commented on Jun 20, 2024

    @vstinner
    MemberAuthor

    I think it is fine to remove them, as no one is using this API.

    Oh ok. I updated my PR to remove the 6 PyUnstable functions from the public C API. Most of them have to be kept for tests, but I renamed them and moved them to the internal C API.

  9. added 4 commits that reference this issue on Jun 26, 2024
  10. added a commit that references this issue on Jun 30, 2024
  11. added a commit that references this issue on Jul 11, 2024
  12. added 2 commits that reference this issue on Jul 12, 2024
  13. added a commit that references this issue on Jul 13, 2024
  14. added a commit that references this issue on Jul 13, 2024
  15. added 2 commits that reference this issue on Jul 17, 2024
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