Skip to content

Make PyCode_GetFirstFree a PEP-689 unstable API #115756

Description

@erlend-aasland

It was and it wasn't. We don't really want to expose it, but if we don't then Cython and other C extensions will access the internal fields directly, which is worse.

Now that we have an unstable API, it should probably be part of that.
I'd like all code object C APIs to be unstable, but it's probably too late for that.

Maybe rename it to PyUnstableCode_GetFirstFree?

Originally posted by @markshannon in #115654 (comment)

Linked PRs

Activity

  1. erlend-aasland commented on Feb 21, 2024

    @erlend-aasland
    ContributorAuthor

    PyCode_GetFirstFree was introduced in PR #100721 (first appeared in 3.12.0a4)

  2. encukou commented on Feb 21, 2024

    @encukou
    Member

    The name should be PyUnstable_Code_GetFirstFree (extra underscore).

  3. wrongnull commented on Feb 21, 2024

    @wrongnull
    Contributor

    Shouldn't this apply to PyCode_GetNumFree too?

  4. vstinner commented on Feb 22, 2024

    @vstinner
    Member

    The function is part of Python 3.12 release, and after Python 3.12, you want to downgrade the API to the unstable API in Python 3.13? It sounds too late for me, no?

  5. erlend-aasland commented on Feb 22, 2024

    @erlend-aasland
    ContributorAuthor

    The function is part of Python 3.12 release, and after Python 3.12, you want to downgrade the API to the unstable API in Python 3.13? It sounds too late for me, no?

    I'll leave that for the C API WG ;)

  6. encukou commented on Mar 4, 2024

    @encukou
    Member

    The function is part of Python 3.12 release, and after Python 3.12, you want to downgrade the API to the unstable API in Python 3.13? It sounds too late for me, no?

    Downgrading means that the public name, PyCode_GetFirstFree, will be deprecated, but will be kept until the function's signature/behaviour changes (minimum 2 releases).
    Do you think this should not be done?

  7. vstinner commented on Mar 6, 2024

    @vstinner
    Member

    Do you think this should not be done?

    I don't think that it's worth it. If later, the function becomes stable, depending on the Python version, PyCode_GetFirstFree() may be deprecated or not, it sounds unpleasant for a minor issue.

    Honestly, just elaborate the documentation to express more clearly the stability contract, no?

  8. encukou commented on Mar 6, 2024

    @encukou
    Member

    If later, the function becomes stable

    I don't think the intention is to ever make it stable. It exposes an implementation detail: free variables follow other ones in a code object.

    just elaborate the documentation to express more clearly the stability contract

    This is the way to do that.

  9. vstinner commented on Mar 6, 2024

    @vstinner
    Member
  10. added a commit that references this issue on Mar 19, 2024
  11. encukou commented on Mar 20, 2024

    @encukou
    Member

    Thank you!

  12. added a commit that references this issue on Mar 20, 2024
  13. added a commit that references this issue on Mar 25, 2024
  14. added a commit that references this issue on Apr 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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions