Skip to content
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

bpo-39245: Make Vectorcall public #17893

Open
wants to merge 6 commits into
base: master
from
Open

Conversation

@encukou
Copy link
Member

encukou commented Jan 7, 2020

As per PEP-590, in Python 3.9 the Vectorcall API will be public, i.e. without leading underscores.
This PR also includes some other new call API that got added together with vectorcall.

@vstinner, note that this partially reverts commit 2ff58a2 : IMO PyObject_CallNoArgs should always stay behind #ifndef Py_LIMITED_API (i.e. be in Include/cpython/).

https://bugs.python.org/issue39245

encukou added 4 commits Nov 26, 2019
Change made automatically with:

    for name in \
        PyObject_Vectorcall \
        Py_TPFLAGS_HAVE_VECTORCALL \
        PyObject_VectorcallMethod \
        PyObject_FastCallDict \
        PyVectorcall_Function \
        PyObject_CallOneArg \
        PyObject_CallMethodNoArgs \
        PyObject_CallMethodOneArg \
    ;
    do
        echo $name
        git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g"
    done
This partially reverts commit 2ff58a2
which added PyObject_CallNoArgs to the 3.9+ stable ABI. This should not
be done; there are enough other call APIs in the stable ABI to choose from.
Mark all newly public functions as added in 3.9.
Add a note about the 3.8 provisional names.
Add notes on public API.
@vstinner

This comment has been minimized.

Copy link
Member

vstinner commented Jan 7, 2020

@vstinner, note that this partially reverts commit 2ff58a2 : IMO PyObject_CallNoArgs should always stay behind #ifndef Py_LIMITED_API (i.e. be in Include/cpython/).

The problem is that Include/cpython/ doesn't work with checks on the Python limited API version:

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
/* Call a callable Python object without any arguments */
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
#endif

Include/cpython/abstract.h is not included if Py_LIMITED_API is defined!

@vstinner

This comment has been minimized.

Copy link
Member

vstinner commented Jan 7, 2020

I'm not sure that I understood your comment properly. It was decided to add PyObject_CallNoArgs() to the limited API on purpose (commit 2ff58a2, bpo-37194). Do you see a reason to exclude it from the limited API?

@encukou

This comment has been minimized.

Copy link
Member Author

encukou commented Jan 7, 2020

Hmm, I see I misunderstood the bpo-37194 conversation.
The way I read it, there are 3 layers of the C apis: limited (Py_LIMITED_API), public (cpython/) and private (internal/).
I don't think adding something to the public API necessarily means adding it to the stable ABI, especially if there are other ways of doing the same thing.

I see now that you were talking about the limited API (stable ABI) when you said "public".
Do you think PyObject_CallNoArgs should be in the stable ABI? I don't.

@ncoghlan

This comment has been minimized.

Copy link
Contributor

ncoghlan commented Jan 7, 2020

The main reasons for excluding things from the stable API/ABI is if we think they might be difficult for other implementations to provide, or if they're intrinsically exposed to ABI compatibility issues.

PyObject_CallNoArgs() doesn't suffer from either of those problems - worst case is that other implementations just need to define it as a naive wrapper around PyObject_Call()

@vstinner

This comment has been minimized.

Copy link
Member

vstinner commented Jan 7, 2020

Do you think PyObject_CallNoArgs should be in the stable ABI?

Yes, I consider that it is safe to add it to the stable ABI, since it should be trivial to implement.

Copy link
Member

vstinner left a comment

Before making the API public, I would like to see a public discussion if we should pass tstate to functions or not (change the calling convention). For subinterpreters, we will need more and more to access tstate. There are ways to get the tstate, but they may be "inefficient" when calling very frequently.

@ericsnowcurrently: What do you think?

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 8, 2020

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.