Skip to content

Commit b8351c1

Browse files
committed
Deploying to gh-pages from @ d423925 🚀
1 parent 1018d11 commit b8351c1

File tree

598 files changed

+1526
-776
lines changed

Some content is hidden

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

598 files changed

+1526
-776
lines changed

_sources/c-api/datetime.rst.txt

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,42 @@ DateTime Objects
88
Various date and time objects are supplied by the :mod:`datetime` module.
99
Before using any of these functions, the header file :file:`datetime.h` must be
1010
included in your source (note that this is not included by :file:`Python.h`),
11-
and the macro :c:macro:`!PyDateTime_IMPORT` must be invoked, usually as part of
11+
and the macro :c:macro:`PyDateTime_IMPORT` must be invoked, usually as part of
1212
the module initialisation function. The macro puts a pointer to a C structure
13-
into a static variable, :c:data:`!PyDateTimeAPI`, that is used by the following
13+
into a static variable, :c:data:`PyDateTimeAPI`, that is used by the following
1414
macros.
1515

16+
.. c:macro:: PyDateTime_IMPORT()
17+
18+
Import the datetime C API.
19+
20+
On success, populate the :c:var:`PyDateTimeAPI` pointer.
21+
On failure, set :c:var:`PyDateTimeAPI` to ``NULL`` and set an exception.
22+
The caller must check if an error occurred via :c:func:`PyErr_Occurred`:
23+
24+
.. code-block::
25+
26+
PyDateTime_IMPORT;
27+
if (PyErr_Occurred()) { /* cleanup */ }
28+
29+
.. warning::
30+
31+
This is not compatible with subinterpreters.
32+
33+
.. c:type:: PyDateTime_CAPI
34+
35+
Structure containing the fields for the datetime C API.
36+
37+
The fields of this structure are private and subject to change.
38+
39+
Do not use this directly; prefer ``PyDateTime_*`` APIs instead.
40+
41+
.. c:var:: PyDateTime_CAPI *PyDateTimeAPI
42+
43+
Dynamically allocated object containing the datetime C API.
44+
45+
This variable is only available once :c:macro:`PyDateTime_IMPORT` succeeds.
46+
1647
.. c:type:: PyDateTime_Date
1748
1849
This subtype of :c:type:`PyObject` represents a Python date object.
@@ -325,3 +356,16 @@ Macros for the convenience of modules implementing the DB API:
325356
326357
Create and return a new :class:`datetime.date` object given an argument
327358
tuple suitable for passing to :meth:`datetime.date.fromtimestamp`.
359+
360+
361+
Internal data
362+
-------------
363+
364+
The following symbols are exposed by the C API but should be considered
365+
internal-only.
366+
367+
.. c:macro:: PyDateTime_CAPSULE_NAME
368+
369+
Name of the datetime capsule to pass to :c:func:`PyCapsule_Import`.
370+
371+
Internal usage only. Use :c:macro:`PyDateTime_IMPORT` instead.

_sources/c-api/dict.rst.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,92 @@ Dictionary View Objects
477477
478478
Return true if *op* is an instance of a dictionary items view. This function
479479
always succeeds.
480+
481+
482+
Ordered Dictionaries
483+
^^^^^^^^^^^^^^^^^^^^
484+
485+
Python's C API provides interface for :class:`collections.OrderedDict` from C.
486+
Since Python 3.7, dictionaries are ordered by default, so there is usually
487+
little need for these functions; prefer ``PyDict*`` where possible.
488+
489+
490+
.. c:var:: PyTypeObject PyODict_Type
491+
492+
Type object for ordered dictionaries. This is the same object as
493+
:class:`collections.OrderedDict` in the Python layer.
494+
495+
496+
.. c:function:: int PyODict_Check(PyObject *od)
497+
498+
Return true if *od* is an ordered dictionary object or an instance of a
499+
subtype of the :class:`~collections.OrderedDict` type. This function
500+
always succeeds.
501+
502+
503+
.. c:function:: int PyODict_CheckExact(PyObject *od)
504+
505+
Return true if *od* is an ordered dictionary object, but not an instance of
506+
a subtype of the :class:`~collections.OrderedDict` type.
507+
This function always succeeds.
508+
509+
510+
.. c:var:: PyTypeObject PyODictKeys_Type
511+
512+
Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries.
513+
514+
515+
.. c:var:: PyTypeObject PyODictValues_Type
516+
517+
Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries.
518+
519+
520+
.. c:var:: PyTypeObject PyODictItems_Type
521+
522+
Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries.
523+
524+
525+
.. c:function:: PyObject *PyODict_New(void)
526+
527+
Return a new empty ordered dictionary, or ``NULL`` on failure.
528+
529+
This is analogous to :c:func:`PyDict_New`.
530+
531+
532+
.. c:function:: int PyODict_SetItem(PyObject *od, PyObject *key, PyObject *value)
533+
534+
Insert *value* into the ordered dictionary *od* with a key of *key*.
535+
Return ``0`` on success or ``-1`` with an exception set on failure.
536+
537+
This is analogous to :c:func:`PyDict_SetItem`.
538+
539+
540+
.. c:function:: int PyODict_DelItem(PyObject *od, PyObject *key)
541+
542+
Remove the entry in the ordered dictionary *od* with key *key*.
543+
Return ``0`` on success or ``-1`` with an exception set on failure.
544+
545+
This is analogous to :c:func:`PyDict_DelItem`.
546+
547+
548+
These are :term:`soft deprecated` aliases to ``PyDict`` APIs:
549+
550+
551+
.. list-table::
552+
:widths: auto
553+
:header-rows: 1
554+
555+
* * ``PyODict``
556+
* ``PyDict``
557+
* * .. c:macro:: PyODict_GetItem(od, key)
558+
* :c:func:`PyDict_GetItem`
559+
* * .. c:macro:: PyODict_GetItemWithError(od, key)
560+
* :c:func:`PyDict_GetItemWithError`
561+
* * .. c:macro:: PyODict_GetItemString(od, key)
562+
* :c:func:`PyDict_GetItemString`
563+
* * .. c:macro:: PyODict_Contains(od, key)
564+
* :c:func:`PyDict_Contains`
565+
* * .. c:macro:: PyODict_Size(od)
566+
* :c:func:`PyDict_Size`
567+
* * .. c:macro:: PyODict_SIZE(od)
568+
* :c:func:`PyDict_GET_SIZE`

_sources/c-api/float.rst.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ Floating-Point Objects
9696
the C11 standard ``<math.h>`` header.
9797
9898
99+
.. c:macro:: Py_HUGE_VAL
100+
101+
Equivalent to :c:macro:`!INFINITY`.
102+
103+
.. deprecated:: 3.14
104+
The macro is :term:`soft deprecated`.
105+
106+
99107
.. c:macro:: Py_MATH_E
100108
101109
The definition (accurate for a :c:expr:`double` type) of the :data:`math.e` constant.
@@ -140,6 +148,34 @@ Floating-Point Objects
140148
return PyFloat_FromDouble(copysign(INFINITY, sign));
141149
142150
151+
.. c:macro:: Py_IS_FINITE(X)
152+
153+
Return ``1`` if the given floating-point number *X* is finite,
154+
that is, it is normal, subnormal or zero, but not infinite or NaN.
155+
Return ``0`` otherwise.
156+
157+
.. deprecated:: 3.14
158+
The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead.
159+
160+
161+
.. c:macro:: Py_IS_INFINITY(X)
162+
163+
Return ``1`` if the given floating-point number *X* is positive or negative
164+
infinity. Return ``0`` otherwise.
165+
166+
.. deprecated:: 3.14
167+
The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead.
168+
169+
170+
.. c:macro:: Py_IS_NAN(X)
171+
172+
Return ``1`` if the given floating-point number *X* is a not-a-number (NaN)
173+
value. Return ``0`` otherwise.
174+
175+
.. deprecated:: 3.14
176+
The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead.
177+
178+
143179
Pack and Unpack functions
144180
-------------------------
145181

_sources/c-api/gen.rst.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,41 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`.
4444
with ``__name__`` and ``__qualname__`` set to *name* and *qualname*.
4545
A reference to *frame* is stolen by this function. The *frame* argument
4646
must not be ``NULL``.
47+
48+
.. c:function:: PyCodeObject* PyGen_GetCode(PyGenObject *gen)
49+
50+
Return a new :term:`strong reference` to the code object wrapped by *gen*.
51+
This function always succeeds.
52+
53+
54+
Asynchronous Generator Objects
55+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56+
57+
.. seealso::
58+
:pep:`525`
59+
60+
.. c:var:: PyTypeObject PyAsyncGen_Type
61+
62+
The type object corresponding to asynchronous generator objects. This is
63+
available as :class:`types.AsyncGeneratorType` in the Python layer.
64+
65+
.. versionadded:: 3.6
66+
67+
.. c:function:: PyObject *PyAsyncGen_New(PyFrameObject *frame, PyObject *name, PyObject *qualname)
68+
69+
Create a new asynchronous generator wrapping *frame*, with ``__name__`` and
70+
``__qualname__`` set to *name* and *qualname*. *frame* is stolen by this
71+
function and must not be ``NULL``.
72+
73+
On success, this function returns a :term:`strong reference` to the
74+
new asynchronous generator. On failure, this function returns ``NULL``
75+
with an exception set.
76+
77+
.. versionadded:: 3.6
78+
79+
.. c:function:: int PyAsyncGen_CheckExact(PyObject *op)
80+
81+
Return true if *op* is an asynchronous generator object, false otherwise.
82+
This function always succeeds.
83+
84+
.. versionadded:: 3.6

_sources/c-api/init.rst.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,25 @@ pointer and a void pointer argument.
20192019
This function now always schedules *func* to be run in the main
20202020
interpreter.
20212021
2022+
2023+
.. c:function:: int Py_MakePendingCalls(void)
2024+
2025+
Execute all pending calls. This is usually executed automatically by the
2026+
interpreter.
2027+
2028+
This function returns ``0`` on success, and returns ``-1`` with an exception
2029+
set on failure.
2030+
2031+
If this is not called in the main thread of the main
2032+
interpreter, this function does nothing and returns ``0``.
2033+
The caller must hold an :term:`attached thread state`.
2034+
2035+
.. versionadded:: 3.1
2036+
2037+
.. versionchanged:: 3.12
2038+
This function only runs pending calls in the main interpreter.
2039+
2040+
20222041
.. _profiling:
20232042
20242043
Profiling and Tracing

_sources/c-api/intro.rst.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ complete listing.
171171
Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
172172
command line (see :c:member:`PyConfig.use_environment`).
173173

174+
.. c:macro:: Py_LOCAL(type)
175+
176+
Declare a function returning the specified *type* using a fast-calling
177+
qualifier for functions that are local to the current file.
178+
Semantically, this is equivalent to ``static type``.
179+
180+
.. c:macro:: Py_LOCAL_INLINE(type)
181+
182+
Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function
183+
be inlined.
184+
174185
.. c:macro:: Py_MAX(x, y)
175186
176187
Return the maximum value between ``x`` and ``y``.
@@ -183,6 +194,14 @@ complete listing.
183194

184195
.. versionadded:: 3.6
185196

197+
.. c:macro:: Py_MEMCPY(dest, src, n)
198+
199+
This is a :term:`soft deprecated` alias to :c:func:`!memcpy`.
200+
Use :c:func:`!memcpy` directly instead.
201+
202+
.. deprecated:: 3.14
203+
The macro is :term:`soft deprecated`.
204+
186205
.. c:macro:: Py_MIN(x, y)
187206
188207
Return the minimum value between ``x`` and ``y``.

_sources/c-api/iterator.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Other Iterator Objects
108108
.. c:var:: PyTypeObject PyDictRevIterValue_Type
109109
.. c:var:: PyTypeObject PyDictIterItem_Type
110110
.. c:var:: PyTypeObject PyDictRevIterItem_Type
111+
.. c:var:: PyTypeObject PyODictIter_Type
111112
112113
Type objects for iterators of various built-in objects.
113114

_sources/c-api/structures.rst.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,12 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
698698
entry indicates an offset from the subclass-specific data, rather than
699699
from ``PyObject``.
700700
701-
Can only be used as part of :c:member:`Py_tp_members <PyTypeObject.tp_members>`
701+
Can only be used as part of the :c:data:`Py_tp_members`
702702
:c:type:`slot <PyType_Slot>` when creating a class using negative
703703
:c:member:`~PyType_Spec.basicsize`.
704704
It is mandatory in that case.
705-
706-
This flag is only used in :c:type:`PyType_Slot`.
707-
When setting :c:member:`~PyTypeObject.tp_members` during
708-
class creation, Python clears it and sets
705+
When setting :c:member:`~PyTypeObject.tp_members` from the slot during
706+
class creation, Python clears the flag and sets
709707
:c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct.
710708
711709
.. index::

_sources/c-api/type.rst.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ The following functions and structs are used to create
383383
384384
The *bases* argument can be used to specify base classes; it can either
385385
be only one class or a tuple of classes.
386-
If *bases* is ``NULL``, the *Py_tp_bases* slot is used instead.
387-
If that also is ``NULL``, the *Py_tp_base* slot is used instead.
386+
If *bases* is ``NULL``, the :c:data:`Py_tp_bases` slot is used instead.
387+
If that also is ``NULL``, the :c:data:`Py_tp_base` slot is used instead.
388388
If that also is ``NULL``, the new type derives from :class:`object`.
389389
390390
The *module* argument can be used to record the module in which the new
@@ -590,9 +590,9 @@ The following functions and structs are used to create
590590
:c:type:`PyAsyncMethods` with an added ``Py_`` prefix.
591591
For example, use:
592592
593-
* ``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`
594-
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
595-
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
593+
* :c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`
594+
* :c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`
595+
* :c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`
596596
597597
An additional slot is supported that does not correspond to a
598598
:c:type:`!PyTypeObject` struct field:
@@ -611,7 +611,7 @@ The following functions and structs are used to create
611611
612612
If it is not possible to switch to a ``MANAGED`` flag (for example,
613613
for vectorcall or to support Python older than 3.12), specify the
614-
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
614+
offset in :c:data:`Py_tp_members`.
615615
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
616616
for details.
617617
@@ -639,7 +639,7 @@ The following functions and structs are used to create
639639
640640
.. versionchanged:: 3.14
641641
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
642-
using ``Py_tp_vectorcall``. See the field's documentation
642+
using :c:data:`Py_tp_vectorcall`. See the field's documentation
643643
for details.
644644
645645
.. c:member:: void *pfunc
@@ -649,7 +649,7 @@ The following functions and structs are used to create
649649
650650
*pfunc* values may not be ``NULL``, except for the following slots:
651651
652-
* ``Py_tp_doc``
652+
* :c:data:`Py_tp_doc`
653653
* :c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC`
654654
rather than ``NULL``)
655655

_sources/c-api/typeobj.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2258,7 +2258,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
22582258
This field should be set to ``NULL`` and treated as read-only.
22592259
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.
22602260

2261-
For dynamically created classes, the ``Py_tp_bases``
2261+
For dynamically created classes, the :c:data:`Py_tp_bases`
22622262
:c:type:`slot <PyType_Slot>` can be used instead of the *bases* argument
22632263
of :c:func:`PyType_FromSpecWithBases`.
22642264
The argument form is preferred.

0 commit comments

Comments
 (0)