Skip to content

gh-95417: Add PyLong_FromUintptr_t and PyLong_AsUintptr_t #95446

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

Closed
wants to merge 9 commits into from

Conversation

arhadthedev
Copy link
Member

@arhadthedev arhadthedev commented Jul 29, 2022

This PR adds exports from the dll/so because all PyLong_* do so. However, if the core devs aren't against, I would prefer to transform them into inline macros (thus removing ABI churn and eliminating Misc/stable_abi.toml from the patch):

/* Include/longobject.h */

static uintptr_t
PyLong_AsUintptr_t(PyObject *vv)
{
    return (uintptr_t)PyLong_AsVoidPtr(vv);
}

static PyObject *
PyLong_FromUintptr_t(uintptr_t ival)
{
    return PyLong_FromVoidPtr((void *)ival);
}

Closes gh-95417.

cc @eryksun (who proposed to implement these functions).

@arhadthedev arhadthedev requested a review from a team as a code owner July 29, 2022 18:44
@arhadthedev
Copy link
Member Author

cc @benjaminp (from the object model interest area) because the new functions convert to/from PyLong_Type.

@arhadthedev
Copy link
Member Author

According to https://devguide.python.org/developer-workflow/c-api/#guidelines-for-adding-to-the-limited-api, addition of stable ABI requires long discussion. I'm not ready for this for the sake of a single use case so closing this PR.

@arhadthedev arhadthedev closed this Feb 5, 2023
@arhadthedev arhadthedev deleted the pylong_asuintptr_t branch February 5, 2023 05:48
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.

What way to choose to fix Warning: ULONG_PTR differs in levels of indirection from void * in AC-generated code?
2 participants