Skip to content

bpo-45316: Move private PyCode C API to internal C API #31576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2022
Merged

bpo-45316: Move private PyCode C API to internal C API #31576

merged 1 commit into from
Feb 25, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Feb 25, 2022

Rename private functions (no exported), add an underscore prefix:

  • PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange()
  • PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange()
  • PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange()

Move private functions to the internal C API:

  • _PyCode_Addr2EndLine()
  • _PyCode_Addr2EndOffset()
  • _PyCode_Addr2Offset()
  • _PyCode_InitAddressRange()
  • _PyCode_InitEndAddressRange(
  • _PyLineTable_InitAddressRange()
  • _PyLineTable_NextAddressRange()
  • _PyLineTable_PreviousAddressRange()

No longer export the following internal functions:

  • _PyCode_GetVarnames()
  • _PyCode_GetCellvars()
  • _PyCode_GetFreevars()
  • _Py_GetSpecializationStats()

Add "extern" to pycore_code.h functions to identify them more easiliy
(they are still not exported).

https://bugs.python.org/issue45316

Rename private functions (no exported), add an underscore prefix:

* PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange()
* PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange()
* PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange()

Move private functions to the internal C API:

* _PyCode_Addr2EndLine()
* _PyCode_Addr2EndOffset()
* _PyCode_Addr2Offset()
* _PyCode_InitAddressRange()
* _PyCode_InitEndAddressRange(
* _PyLineTable_InitAddressRange()
* _PyLineTable_NextAddressRange()
* _PyLineTable_PreviousAddressRange()

No longer export the following internal functions:

* _PyCode_GetVarnames()
* _PyCode_GetCellvars()
* _PyCode_GetFreevars()
* _Py_GetSpecializationStats()

Add "extern" to pycore_code.h functions to identify them more easiliy
(they are still not exported).
@vstinner
Copy link
Member Author

cc @markshannon @brandtbucher

@vstinner
Copy link
Member Author

If any of these functions must be included, please add a comment to explain why. By default, it's better to avoid exporting functions to make sure that we can remove or modify them without impacting any 3rd party extension modules. In theory, I know that the internal C API must not be used, but well, people love to do random hacks and then complain that it breaks when updating Python :-) Moreover, if there is a real use of one of these functions, maybe a clean public API should be written instead.

@vstinner vstinner merged commit 4a0c7a1 into python:main Feb 25, 2022
@vstinner vstinner deleted the pycore_code branch February 25, 2022 14:41
asvetlov pushed a commit that referenced this pull request Feb 26, 2022
Rename private functions (no exported), add an underscore prefix:

* PyLineTable_InitAddressRange() => _PyLineTable_InitAddressRange()
* PyLineTable_NextAddressRange() => _PyLineTable_NextAddressRange()
* PyLineTable_PreviousAddressRange() => _PyLineTable_PreviousAddressRange()

Move private functions to the internal C API:

* _PyCode_Addr2EndLine()
* _PyCode_Addr2EndOffset()
* _PyCode_Addr2Offset()
* _PyCode_InitAddressRange()
* _PyCode_InitEndAddressRange(
* _PyLineTable_InitAddressRange()
* _PyLineTable_NextAddressRange()
* _PyLineTable_PreviousAddressRange()

No longer export the following internal functions:

* _PyCode_GetVarnames()
* _PyCode_GetCellvars()
* _PyCode_GetFreevars()
* _Py_GetSpecializationStats()

Add "extern" to pycore_code.h functions to identify them more easiliy
(they are still not exported).
@vstinner
Copy link
Member Author

If any of these functions must be included, please add a comment to explain why.

_Py_GetSpecializationStats() is one of them: I created PR #92011.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants