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 — gh-106320: Remove private _PyLong_IsCompact() function by vstinner · Pull Request #108742 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Sep 1, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Move the private _PyLong_IsCompact() and _PyLong_CompactValue() functions to the internal C API (pycore_long.h). Public PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue() functions can be used instead.

Remove "const" qualifier from PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue() parameter type.

  • Issue: C API: Remove private C API functions (move them to the internal C API) #106320

📚 Documentation preview 📚: https://cpython-previews--108742.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added the skip news label Sep 1, 2023
@bedevere-bot bedevere-bot mentioned this pull request Sep 1, 2023
C API: Remove private C API functions (move them to the internal C API) #106320
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Sep 1, 2023
@vstinner

vstinner commented Sep 1, 2023

Copy link
Copy Markdown
Member Author

With this change, PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue() become regular opaque function calls. They are no longer implemented as static inline functions. That's needed to be able remove the 2 associated static inline functions from the public C API.

Remove "const" qualifier from PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue() parameter type.

When I tried to use the const qualified in the public C API in the past, I had issues :-( I prefer to avoid it. For the internal C API with static inline functions, that's fine.

See:

  • Const correctness capi-workgroup/problems#38
  • [C API] Avoid "const PyObject*" type #91768
  • gh-91768: C API no longer use "const PyObject*" type #91769
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
pythongh-106320: Remove private _PyLong_IsCompact() function
c6be6f8
Move the private _PyLong_IsCompact() and _PyLong_CompactValue()
functions to the internal C API (pycore_long.h). Public
PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue()
functions can be used instead.

Remove "const" qualifier from PyUnstable_Long_IsCompact() and
PyUnstable_Long_CompactValue() parameter type.
@vstinner
vstinner force-pushed the remove_pylong_iscompat branch from 1969769 to c6be6f8 Compare September 1, 2023 07:15
@vstinner vstinner added the needs backport to 3.12 only security fixes label Sep 1, 2023
@vstinner

vstinner commented Sep 1, 2023

Copy link
Copy Markdown
Member Author

@gvanrossum @markshannon: Are the private _PyLong_IsCompact() and _PyLong_CompactValue() functions exposed by <Python.h> on purpose? Or are you are ok to move them to the internal C API?

I don't know the impact on performance. I'm more in favor of hiding implementation details.

If these functions are moved to the internal C API, are you ok to also make this change in Python 3.12?

Remove "const" qualifier from PyUnstable_Long_IsCompact() and PyUnstable_Long_CompactValue() parameter type.

I don't have a strong opinion on that, I'm also fine with keeping const if you prefer :-) It's just that in the past, I tried to use const in the public C API and "I got issues".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Sep 1, 2023

Copy link
Copy Markdown
Member

Please don’t touch these. They are meant to be exported.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Sep 1, 2023

Copy link
Copy Markdown
Member

Also it’s too late for 3.12.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 1, 2023

Copy link
Copy Markdown
Member Author

Please don’t touch these. They are meant to be exported.

Ok, let's keep them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Sep 1, 2023
@vstinner
vstinner deleted the remove_pylong_iscompat branch September 1, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review needs backport to 3.12 only security fixes skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vstinner @gvanrossum @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.