Skip to content

gh-95417: Add PyLong_FromUintptr_t and PyLong_AsUintptr_t - #95446

Closed
arhadthedev wants to merge 9 commits into
python:mainfrom
arhadthedev:pylong_asuintptr_t
Closed

gh-95417: Add PyLong_FromUintptr_t and PyLong_AsUintptr_t#95446
arhadthedev wants to merge 9 commits into
python:mainfrom
arhadthedev:pylong_asuintptr_t

Conversation

@arhadthedev

@arhadthedevarhadthedev commented Jul 29, 2022

Copy link
Copy Markdown
Member

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 */staticuintptr_tPyLong_AsUintptr_t(PyObject *vv)
{
return (uintptr_t)PyLong_AsVoidPtr(vv);
}
static PyObject *
PyLong_FromUintptr_t(uintptr_t ival)
{
returnPyLong_FromVoidPtr((void *)ival);
}

Closesgh-95417.

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

@arhadthedev

Copy link
Copy Markdown
MemberAuthor

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

@arhadthedev

Copy link
Copy Markdown
MemberAuthor

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 deleted the pylong_asuintptr_t branch February 5, 2023 05:48
Sign up for freeto 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

@arhadthedev@bedevere-bot