Skip to content

Commit c534f67

Browse files
committed
Merge branch 'master' into pep585
2 parents d4a372b + d68e0a8 commit c534f67

File tree

245 files changed

+2839
-2256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+2839
-2256
lines changed

Doc/c-api/call.rst

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,11 @@ To call an object, use :c:func:`PyObject_Call` or other
3535
The Vectorcall Protocol
3636
-----------------------
3737

38-
.. versionadded:: 3.8
38+
.. versionadded:: 3.9
3939

4040
The vectorcall protocol was introduced in :pep:`590` as an additional protocol
4141
for making calls more efficient.
4242

43-
.. warning::
44-
45-
The vectorcall API is provisional and expected to become public in
46-
Python 3.9, with a different names and, possibly, changed semantics.
47-
If you use the it, plan for updating your code for Python 3.9.
48-
4943
As rule of thumb, CPython will prefer the vectorcall for internal calls
5044
if the callable supports it. However, this is not a hard rule.
5145
Additionally, some third-party extensions use *tp_call* directly
@@ -69,7 +63,7 @@ the arguments to an args tuple and kwargs dict anyway, then there is no point
6963
in implementing vectorcall.
7064

7165
Classes can implement the vectorcall protocol by enabling the
72-
:const:`_Py_TPFLAGS_HAVE_VECTORCALL` flag and setting
66+
:const:`Py_TPFLAGS_HAVE_VECTORCALL` flag and setting
7367
:c:member:`~PyTypeObject.tp_vectorcall_offset` to the offset inside the
7468
object structure where a *vectorcallfunc* appears.
7569
This is a pointer to a function with the following signature:
@@ -97,7 +91,7 @@ This is a pointer to a function with the following signature:
9791
argument 1 (not 0) in the allocated vector.
9892
The callee must restore the value of ``args[-1]`` before returning.
9993

100-
For :c:func:`_PyObject_VectorcallMethod`, this flag means instead that
94+
For :c:func:`PyObject_VectorcallMethod`, this flag means instead that
10195
``args[0]`` may be changed.
10296

10397
Whenever they can do so cheaply (without additional allocation), callers
@@ -107,7 +101,20 @@ This is a pointer to a function with the following signature:
107101

108102
To call an object that implements vectorcall, use a :ref:`call API <capi-call>`
109103
function as with any other callable.
110-
:c:func:`_PyObject_Vectorcall` will usually be most efficient.
104+
:c:func:`PyObject_Vectorcall` will usually be most efficient.
105+
106+
107+
.. note::
108+
109+
In CPython 3.8, the vectorcall API and related functions were available
110+
provisionally under names with a leading underscore:
111+
``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``,
112+
``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``,
113+
``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``,
114+
``_PyObject_CallMethodOneArg``.
115+
Additionally, ``PyObject_VectorcallDict`` was available as
116+
``_PyObject_FastCallDict``.
117+
The old names are still defined as aliases of the new, non-underscored names.
111118

112119

113120
Recursion Control
@@ -137,17 +144,21 @@ Vectorcall Support API
137144
However, the function ``PyVectorcall_NARGS`` should be used to allow
138145
for future extensions.
139146
147+
This function is not part of the `limited API <stable>`_.
148+
140149
.. versionadded:: 3.8
141150
142-
.. c:function:: vectorcallfunc _PyVectorcall_Function(PyObject *op)
151+
.. c:function:: vectorcallfunc PyVectorcall_Function(PyObject *op)
143152
144153
If *op* does not support the vectorcall protocol (either because the type
145154
does not or because the specific instance does not), return *NULL*.
146155
Otherwise, return the vectorcall function pointer stored in *op*.
147156
This function never raises an exception.
148157
149158
This is mostly useful to check whether or not *op* supports vectorcall,
150-
which can be done by checking ``_PyVectorcall_Function(op) != NULL``.
159+
which can be done by checking ``PyVectorcall_Function(op) != NULL``.
160+
161+
This function is not part of the `limited API <stable>`_.
151162
152163
.. versionadded:: 3.8
153164
@@ -158,9 +169,11 @@ Vectorcall Support API
158169
159170
This is a specialized function, intended to be put in the
160171
:c:member:`~PyTypeObject.tp_call` slot or be used in an implementation of ``tp_call``.
161-
It does not check the :const:`_Py_TPFLAGS_HAVE_VECTORCALL` flag
172+
It does not check the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag
162173
and it does not fall back to ``tp_call``.
163174
175+
This function is not part of the `limited API <stable>`_.
176+
164177
.. versionadded:: 3.8
165178
166179
@@ -185,7 +198,7 @@ please see individual documentation for details.
185198
+------------------------------------------+------------------+--------------------+---------------+
186199
| :c:func:`PyObject_CallNoArgs` | ``PyObject *`` | --- | --- |
187200
+------------------------------------------+------------------+--------------------+---------------+
188-
| :c:func:`_PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- |
201+
| :c:func:`PyObject_CallOneArg` | ``PyObject *`` | 1 object | --- |
189202
+------------------------------------------+------------------+--------------------+---------------+
190203
| :c:func:`PyObject_CallObject` | ``PyObject *`` | tuple/``NULL`` | --- |
191204
+------------------------------------------+------------------+--------------------+---------------+
@@ -197,15 +210,15 @@ please see individual documentation for details.
197210
+------------------------------------------+------------------+--------------------+---------------+
198211
| :c:func:`PyObject_CallMethodObjArgs` | obj + name | variadic | --- |
199212
+------------------------------------------+------------------+--------------------+---------------+
200-
| :c:func:`_PyObject_CallMethodNoArgs` | obj + name | --- | --- |
213+
| :c:func:`PyObject_CallMethodNoArgs` | obj + name | --- | --- |
201214
+------------------------------------------+------------------+--------------------+---------------+
202-
| :c:func:`_PyObject_CallMethodOneArg` | obj + name | 1 object | --- |
215+
| :c:func:`PyObject_CallMethodOneArg` | obj + name | 1 object | --- |
203216
+------------------------------------------+------------------+--------------------+---------------+
204-
| :c:func:`_PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall |
217+
| :c:func:`PyObject_Vectorcall` | ``PyObject *`` | vectorcall | vectorcall |
205218
+------------------------------------------+------------------+--------------------+---------------+
206-
| :c:func:`_PyObject_FastCallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` |
219+
| :c:func:`PyObject_VectorcallDict` | ``PyObject *`` | vectorcall | dict/``NULL`` |
207220
+------------------------------------------+------------------+--------------------+---------------+
208-
| :c:func:`_PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall |
221+
| :c:func:`PyObject_VectorcallMethod` | arg + name | vectorcall | vectorcall |
209222
+------------------------------------------+------------------+--------------------+---------------+
210223
211224
@@ -235,14 +248,16 @@ please see individual documentation for details.
235248
.. versionadded:: 3.9
236249
237250
238-
.. c:function:: PyObject* _PyObject_CallOneArg(PyObject *callable, PyObject *arg)
251+
.. c:function:: PyObject* PyObject_CallOneArg(PyObject *callable, PyObject *arg)
239252
240253
Call a callable Python object *callable* with exactly 1 positional argument
241254
*arg* and no keyword arguments.
242255
243256
Return the result of the call on success, or raise an exception and return
244257
*NULL* on failure.
245258
259+
This function is not part of the `limited API <stable>`_.
260+
246261
.. versionadded:: 3.9
247262
248263
@@ -320,18 +335,20 @@ please see individual documentation for details.
320335
*NULL* on failure.
321336
322337
323-
.. c:function:: PyObject* _PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name)
338+
.. c:function:: PyObject* PyObject_CallMethodNoArgs(PyObject *obj, PyObject *name)
324339
325340
Call a method of the Python object *obj* without arguments,
326341
where the name of the method is given as a Python string object in *name*.
327342
328343
Return the result of the call on success, or raise an exception and return
329344
*NULL* on failure.
330345
346+
This function is not part of the `limited API <stable>`_.
347+
331348
.. versionadded:: 3.9
332349
333350
334-
.. c:function:: PyObject* _PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg)
351+
.. c:function:: PyObject* PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg)
335352
336353
Call a method of the Python object *obj* with a single positional argument
337354
*arg*, where the name of the method is given as a Python string object in
@@ -340,10 +357,12 @@ please see individual documentation for details.
340357
Return the result of the call on success, or raise an exception and return
341358
*NULL* on failure.
342359
360+
This function is not part of the `limited API <stable>`_.
361+
343362
.. versionadded:: 3.9
344363
345364
346-
.. c:function:: PyObject* _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
365+
.. c:function:: PyObject* PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
347366
348367
Call a callable Python object *callable*.
349368
The arguments are the same as for :c:type:`vectorcallfunc`.
@@ -353,15 +372,11 @@ please see individual documentation for details.
353372
Return the result of the call on success, or raise an exception and return
354373
*NULL* on failure.
355374
356-
.. note::
357-
358-
This function is provisional and expected to become public in Python 3.9,
359-
with a different name and, possibly, changed semantics.
360-
If you use the function, plan for updating your code for Python 3.9.
375+
This function is not part of the `limited API <stable>`_.
361376
362-
.. versionadded:: 3.8
377+
.. versionadded:: 3.9
363378
364-
.. c:function:: PyObject* _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
379+
.. c:function:: PyObject* PyObject_VectorcallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
365380
366381
Call *callable* with positional arguments passed exactly as in the vectorcall_ protocol,
367382
but with keyword arguments passed as a dictionary *kwdict*.
@@ -373,15 +388,11 @@ please see individual documentation for details.
373388
already has a dictionary ready to use for the keyword arguments,
374389
but not a tuple for the positional arguments.
375390
376-
.. note::
391+
This function is not part of the `limited API <stable>`_.
377392
378-
This function is provisional and expected to become public in Python 3.9,
379-
with a different name and, possibly, changed semantics.
380-
If you use the function, plan for updating your code for Python 3.9.
381-
382-
.. versionadded:: 3.8
393+
.. versionadded:: 3.9
383394
384-
.. c:function:: PyObject* _PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames)
395+
.. c:function:: PyObject* PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames)
385396
386397
Call a method using the vectorcall calling convention. The name of the method
387398
is given as a Python string *name*. The object whose method is called is
@@ -390,7 +401,7 @@ please see individual documentation for details.
390401
*nargsf* is the number of positional arguments including *args[0]*,
391402
plus :const:`PY_VECTORCALL_ARGUMENTS_OFFSET` if the value of ``args[0]`` may
392403
temporarily be changed. Keyword arguments can be passed just like in
393-
:c:func:`_PyObject_Vectorcall`.
404+
:c:func:`PyObject_Vectorcall`.
394405
395406
If the object has the :const:`Py_TPFLAGS_METHOD_DESCRIPTOR` feature,
396407
this will call the unbound method object with the full
@@ -399,6 +410,8 @@ please see individual documentation for details.
399410
Return the result of the call on success, or raise an exception and return
400411
*NULL* on failure.
401412
413+
This function is not part of the `limited API <stable>`_.
414+
402415
.. versionadded:: 3.9
403416
404417

Doc/c-api/init.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
10481048
Reset all information in a thread state object. The global interpreter lock
10491049
must be held.
10501050
1051+
.. versionchanged:: 3.9
1052+
This function now calls the :c:member:`PyThreadState.on_delete` callback.
1053+
Previously, that happened in :c:func:`PyThreadState_Delete`.
1054+
10511055
10521056
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
10531057
@@ -1110,7 +1114,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
11101114
.. c:function:: void PyEval_AcquireThread(PyThreadState *tstate)
11111115
11121116
Acquire the global interpreter lock and set the current thread state to
1113-
*tstate*, which should not be ``NULL``. The lock must have been created earlier.
1117+
*tstate*, which must not be ``NULL``. The lock must have been created earlier.
11141118
If this thread already has the lock, deadlock ensues.
11151119
11161120
.. note::

Doc/c-api/init_config.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -627,14 +627,6 @@ PyConfig
627627
628628
``python3 -m MODULE`` argument. Used by :c:func:`Py_RunMain`.
629629
630-
.. c:member:: int show_alloc_count
631-
632-
Show allocation counts at exit?
633-
634-
Set to 1 by :option:`-X showalloccount <-X>` command line option.
635-
636-
Need a special Python build with ``COUNT_ALLOCS`` macro defined.
637-
638630
.. c:member:: int show_ref_count
639631
640632
Show total reference count at exit?
@@ -702,6 +694,10 @@ arguments are stripped from ``argv``: see :ref:`Command Line Arguments
702694
The ``xoptions`` options are parsed to set other options: see :option:`-X`
703695
option.
704696
697+
.. versionchanged:: 3.9
698+
699+
The ``show_alloc_count`` field has been removed.
700+
705701
706702
Initialization with PyConfig
707703
----------------------------

Doc/c-api/structures.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ the definition of all other Python objects.
7070
(((PyObject*)(o))->ob_type)
7171

7272

73+
.. c:function:: void Py_SET_TYPE(PyObject *o, PyTypeObject *type)
74+
75+
Set the object *o* type to *type*.
76+
77+
.. versionadded:: 3.9
78+
79+
7380
.. c:macro:: Py_REFCNT(o)
7481
7582
This macro is used to access the :attr:`ob_refcnt` member of a Python
@@ -79,6 +86,13 @@ the definition of all other Python objects.
7986
(((PyObject*)(o))->ob_refcnt)
8087
8188
89+
.. c:function:: void Py_SET_REFCNT(PyObject *o, Py_ssize_t refcnt)
90+
91+
Set the object *o* reference counter to *refcnt*.
92+
93+
.. versionadded:: 3.9
94+
95+
8296
.. c:macro:: Py_SIZE(o)
8397
8498
This macro is used to access the :attr:`ob_size` member of a Python object.
@@ -87,6 +101,13 @@ the definition of all other Python objects.
87101
(((PyVarObject*)(o))->ob_size)
88102
89103
104+
.. c:function:: void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size)
105+
106+
Set the object *o* size of *size*.
107+
108+
.. versionadded:: 3.9
109+
110+
90111
.. c:macro:: PyObject_HEAD_INIT(type)
91112
92113
This is a macro which expands to initialization values for a new

Doc/c-api/type.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ Type Objects
2121

2222
.. c:function:: int PyType_Check(PyObject *o)
2323
24-
Return true if the object *o* is a type object, including instances of types
25-
derived from the standard type object. Return false in all other cases.
24+
Return non-zero if the object *o* is a type object, including instances of
25+
types derived from the standard type object. Return 0 in all other cases.
2626
2727
2828
.. c:function:: int PyType_CheckExact(PyObject *o)
2929
30-
Return true if the object *o* is a type object, but not a subtype of the
31-
standard type object. Return false in all other cases.
30+
Return non-zero if the object *o* is a type object, but not a subtype of the
31+
standard type object. Return 0 in all other cases.
3232
3333
3434
.. c:function:: unsigned int PyType_ClearCache()
@@ -57,8 +57,8 @@ Type Objects
5757
5858
.. c:function:: int PyType_HasFeature(PyTypeObject *o, int feature)
5959
60-
Return true if the type object *o* sets the feature *feature*. Type features
61-
are denoted by single bit flags.
60+
Return non-zero if the type object *o* sets the feature *feature*.
61+
Type features are denoted by single bit flags.
6262
6363
6464
.. c:function:: int PyType_IS_GC(PyTypeObject *o)

0 commit comments

Comments
 (0)