Skip to content

Commit 4cd6c98

Browse files
committed
Deploying to gh-pages from @ 30fd37f 🚀
1 parent ea42bef commit 4cd6c98

File tree

593 files changed

+5121
-4514
lines changed

Some content is hidden

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

593 files changed

+5121
-4514
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: f87e8867697d38f9afc2009f0655d1bc
3+
config: d6751eade72bed0b8f7a3e9e8373c012
44
tags: b5e2c454ba7771976391ed0cecdde553

_sources/c-api/intro.rst.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,35 @@ complete listing.
127127

128128
.. versionadded:: 3.3
129129

130+
.. c:macro:: Py_ALIGNED(num)
131+
132+
Specify alignment to *num* bytes on compilers that support it.
133+
134+
Consider using the C11 standard ``_Alignas`` specifier over this macro.
135+
136+
.. c:macro:: Py_ARITHMETIC_RIGHT_SHIFT(type, integer, positions)
137+
138+
Similar to ``integer >> positions``, but forces sign extension, as the C
139+
standard does not define whether a right-shift of a signed integer will
140+
perform sign extension or a zero-fill.
141+
142+
*integer* should be any signed integer type.
143+
*positions* is the number of positions to shift to the right.
144+
145+
Both *integer* and *positions* can be evaluated more than once;
146+
consequently, avoid directly passing a function call or some other
147+
operation with side-effects to this macro. Instead, store the result as a
148+
variable and then pass it.
149+
150+
*type* is unused and only kept for backwards compatibility. Historically,
151+
*type* was used to cast *integer*.
152+
153+
.. versionchanged:: 3.1
154+
155+
This macro is now valid for all signed integer types, not just those for
156+
which ``unsigned type`` is legal. As a result, *type* is no longer
157+
used.
158+
130159
.. c:macro:: Py_ALWAYS_INLINE
131160
132161
Ask the compiler to always inline a static inline function. The compiler can
@@ -149,6 +178,15 @@ complete listing.
149178

150179
.. versionadded:: 3.11
151180

181+
.. c:macro:: Py_CAN_START_THREADS
182+
183+
If this macro is defined, then the current system is able to start threads.
184+
185+
Currently, all systems supported by CPython (per :pep:`11`), with the
186+
exception of some WebAssembly platforms, support starting threads.
187+
188+
.. versionadded:: 3.13
189+
152190
.. c:macro:: Py_CHARMASK(c)
153191
154192
Argument must be a character or an integer in the range [-128, 127] or [0,
@@ -166,11 +204,35 @@ complete listing.
166204
.. versionchanged:: 3.8
167205
MSVC support was added.
168206

207+
.. c:macro:: Py_FORCE_EXPANSION(X)
208+
209+
This is equivalent to ``X``, which is useful for token-pasting in
210+
macros, as macro expansions in *X* are forcefully evaluated by the
211+
preprocessor.
212+
213+
.. c:macro:: Py_GCC_ATTRIBUTE(name)
214+
215+
Use a GCC attribute *name*, hiding it from compilers that don't support GCC
216+
attributes (such as MSVC).
217+
218+
This expands to ``__attribute__((name))`` on a GCC compiler, and expands
219+
to nothing on compilers that don't support GCC attributes.
220+
169221
.. c:macro:: Py_GETENV(s)
170222
171223
Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
172224
command line (see :c:member:`PyConfig.use_environment`).
173225

226+
.. c:macro:: Py_LL(number)
227+
228+
Use *number* as a ``long long`` integer literal.
229+
230+
This usally expands to *number* followed by ``LL``, but will expand to some
231+
compiler-specific suffixes (such as ``I64``) on older compilers.
232+
233+
In modern versions of Python, this macro is not very useful, as C99 and
234+
later require the ``LL`` suffix to be valid for an integer.
235+
174236
.. c:macro:: Py_LOCAL(type)
175237
176238
Declare a function returning the specified *type* using a fast-calling
@@ -228,13 +290,37 @@ complete listing.
228290

229291
.. versionadded:: 3.11
230292

293+
.. c:macro:: Py_SAFE_DOWNCAST(value, larger, smaller)
294+
295+
Cast *value* to type *smaller* from type *larger*, validating that no
296+
information was lost.
297+
298+
On release builds of Python, this is roughly equivalent to
299+
``(smaller) value`` (in C++, ``static_cast<smaller>(value)`` will be
300+
used instead).
301+
302+
On debug builds (implying that :c:macro:`Py_DEBUG` is defined), this asserts
303+
that no information was lost with the cast from *larger* to *smaller*.
304+
305+
*value*, *larger*, and *smaller* may all be evaluated more than once in the
306+
expression; consequently, do not pass an expression with side-effects directly to
307+
this macro.
308+
231309
.. c:macro:: Py_STRINGIFY(x)
232310
233311
Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns
234312
``"123"``.
235313

236314
.. versionadded:: 3.4
237315

316+
.. c:macro:: Py_ULL(number)
317+
318+
Similar to :c:macro:`Py_LL`, but *number* will be an ``unsigned long long``
319+
literal instead. This is done by appending ``U`` to the result of ``Py_LL``.
320+
321+
In modern versions of Python, this macro is not very useful, as C99 and
322+
later require the ``ULL``/``LLU`` suffixes to be valid for an integer.
323+
238324
.. c:macro:: Py_UNREACHABLE()
239325
240326
Use this when you have a code path that cannot be reached by design.
@@ -375,6 +461,16 @@ complete listing.
375461
This macro is intended for defining CPython's C API itself;
376462
extension modules should not use it for their own symbols.
377463

464+
.. c:macro:: Py_VA_COPY
465+
466+
This is a :term:`soft deprecated` alias to the C99-standard ``va_copy``
467+
function.
468+
469+
Historically, this would use a compiler-specific method to copy a ``va_list``.
470+
471+
.. versionchanged:: 3.6
472+
This is now an alias to ``va_copy``.
473+
378474

379475
.. _api-objects:
380476

_sources/c-api/object.rst.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,10 @@ Object Protocol
667667
668668
:c:func:`PyUnstable_EnableTryIncRef` must have been called
669669
earlier on *obj* or this function may spuriously return ``0`` in the
670-
:term:`free threading` build.
670+
:term:`free-threaded build`.
671671
672672
This function is logically equivalent to the following C code, except that
673-
it behaves atomically in the :term:`free threading` build::
673+
it behaves atomically in the :term:`free-threaded build`::
674674
675675
if (Py_REFCNT(op) > 0) {
676676
Py_INCREF(op);
@@ -747,10 +747,10 @@ Object Protocol
747747
On GIL-enabled builds, this function is equivalent to
748748
:c:expr:`Py_REFCNT(op) == 1`.
749749
750-
On a :term:`free threaded <free threading>` build, this checks if *op*'s
750+
On a :term:`free-threaded build`, this checks if *op*'s
751751
:term:`reference count` is equal to one and additionally checks if *op*
752752
is only used by this thread. :c:expr:`Py_REFCNT(op) == 1` is **not**
753-
thread-safe on free threaded builds; prefer this function.
753+
thread-safe on free-threaded builds; prefer this function.
754754
755755
The caller must hold an :term:`attached thread state`, despite the fact
756756
that this function doesn't call into the Python interpreter. This function

_sources/c-api/refcounting.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ of Python objects.
2525
2626
.. note::
2727
28-
On :term:`free threaded <free threading>` builds of Python, returning 1
28+
On :term:`free-threaded builds <free-threaded build>` of Python, returning 1
2929
isn't sufficient to determine if it's safe to treat *o* as having no
3030
access by other threads. Use :c:func:`PyUnstable_Object_IsUniquelyReferenced`
3131
for that instead.

_sources/glossary.rst.txt

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ Glossary
160160
On most builds of Python, having an attached thread state implies that the
161161
caller holds the :term:`GIL` for the current interpreter, so only
162162
one OS thread can have an attached thread state at a given moment. In
163-
:term:`free-threaded <free threading>` builds of Python, threads can concurrently
164-
hold an attached thread state, allowing for true parallelism of the bytecode
165-
interpreter.
163+
:term:`free-threaded builds <free-threaded build>` of Python, threads can
164+
concurrently hold an attached thread state, allowing for true parallelism of
165+
the bytecode interpreter.
166166

167167
attribute
168168
A value associated with an object which is usually referenced by name
@@ -580,6 +580,13 @@ Glossary
580580
the :term:`global interpreter lock` which allows only one thread to
581581
execute Python bytecode at a time. See :pep:`703`.
582582

583+
free-threaded build
584+
585+
A build of :term:`CPython` that supports :term:`free threading`,
586+
configured using the :option:`--disable-gil` option before compilation.
587+
588+
See :ref:`freethreading-python-howto`.
589+
583590
free variable
584591
Formally, as defined in the :ref:`language execution model <bind_names>`, a free
585592
variable is any variable used in a namespace which is not a local variable in that
@@ -779,6 +786,19 @@ Glossary
779786
An object that both finds and loads a module; both a
780787
:term:`finder` and :term:`loader` object.
781788

789+
index
790+
A numeric value that represents the position of an element in
791+
a :term:`sequence`.
792+
793+
In Python, indexing starts at zero.
794+
For example, ``things[0]`` names the *first* element of ``things``;
795+
``things[1]`` names the second one.
796+
797+
In some contexts, Python allows negative indexes for counting from the
798+
end of a sequence, and indexing using :term:`slices <slice>`.
799+
800+
See also :term:`subscript`.
801+
782802
interactive
783803
Python has an interactive interpreter which means you can enter
784804
statements and expressions at the interpreter prompt, immediately
@@ -856,6 +876,9 @@ Glossary
856876
CPython does not guarantee :term:`thread-safe` behavior of iterator
857877
operations.
858878

879+
key
880+
A value that identifies an entry in a :term:`mapping`.
881+
See also :term:`subscript`.
859882

860883
key function
861884
A key function or collation function is a callable that returns a value
@@ -1410,10 +1433,11 @@ Glossary
14101433
chosen based on the type of a single argument.
14111434

14121435
slice
1413-
An object usually containing a portion of a :term:`sequence`. A slice is
1414-
created using the subscript notation, ``[]`` with colons between numbers
1415-
when several are given, such as in ``variable_name[1:3:5]``. The bracket
1416-
(subscript) notation uses :class:`slice` objects internally.
1436+
An object of type :class:`slice`, used to describe a portion of
1437+
a :term:`sequence`.
1438+
A slice object is created when using the :ref:`slicing <slicings>` form
1439+
of :ref:`subscript notation <subscriptions>`, with colons inside square
1440+
brackets, such as in ``variable_name[1:3:5]``.
14171441

14181442
soft deprecated
14191443
A soft deprecated API should not be used in new code,
@@ -1471,6 +1495,14 @@ Glossary
14711495

14721496
See also :term:`borrowed reference`.
14731497

1498+
subscript
1499+
The expression in square brackets of a
1500+
:ref:`subscription expression <subscriptions>`, for example,
1501+
the ``3`` in ``items[3]``.
1502+
Usually used to select an element of a container.
1503+
Also called a :term:`key` when subscripting a :term:`mapping`,
1504+
or an :term:`index` when subscripting a :term:`sequence`.
1505+
14741506
synchronization primitive
14751507
A basic building block for coordinating (synchronizing) the execution of
14761508
multiple threads to ensure :term:`thread-safe` access to shared resources.

_sources/howto/logging-cookbook.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ messages should not. Here's how you can achieve this::
229229
# tell the handler to use this format
230230
console.setFormatter(formatter)
231231
# add the handler to the root logger
232-
logging.getLogger('').addHandler(console)
232+
logging.getLogger().addHandler(console)
233233

234234
# Now, we can log to the root logger, or any other logger. First the root...
235235
logging.info('Jackdaws love my big sphinx of quartz.')
@@ -650,7 +650,7 @@ the receiving end. A simple way of doing this is attaching a
650650

651651
import logging, logging.handlers
652652

653-
rootLogger = logging.getLogger('')
653+
rootLogger = logging.getLogger()
654654
rootLogger.setLevel(logging.DEBUG)
655655
socketHandler = logging.handlers.SocketHandler('localhost',
656656
logging.handlers.DEFAULT_TCP_LOGGING_PORT)

_sources/library/ctypes.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ invalid non-\ ``NULL`` pointers would crash Python)::
896896
Thread safety without the GIL
897897
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
898898

899-
From Python 3.13 onward, the :term:`GIL` can be disabled on :term:`free threaded <free threading>` builds.
899+
From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-threaded build`.
900900
In ctypes, reads and writes to a single object concurrently is safe, but not across multiple objects:
901901

902902
.. code-block:: pycon

_sources/library/functions.rst.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,19 +1843,19 @@ are always available. They are listed here in alphabetical order.
18431843
``range(start, stop, step)``. The *start* and *step* arguments default to
18441844
``None``.
18451845

1846-
Slice objects have read-only data attributes :attr:`!start`,
1847-
:attr:`!stop`, and :attr:`!step` which merely return the argument
1848-
values (or their default). They have no other explicit functionality;
1849-
however, they are used by NumPy and other third-party packages.
1846+
Slice objects are also generated when :ref:`slicing syntax <slicings>`
1847+
is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``.
1848+
1849+
See :func:`itertools.islice` for an alternate version that returns an
1850+
:term:`iterator`.
18501851

18511852
.. attribute:: slice.start
1852-
.. attribute:: slice.stop
1853-
.. attribute:: slice.step
1853+
slice.stop
1854+
slice.step
18541855

1855-
Slice objects are also generated when extended indexing syntax is used. For
1856-
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
1857-
:func:`itertools.islice` for an alternate version that returns an
1858-
:term:`iterator`.
1856+
These read-only attributes are set to the argument values
1857+
(or their default). They have no other explicit functionality;
1858+
however, they are used by NumPy and other third-party packages.
18591859

18601860
.. versionchanged:: 3.12
18611861
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`,

0 commit comments

Comments
 (0)