Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-115999-thread-local-bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Nov 4, 2024
2 parents 38ff315 + 9441993 commit 338f7e5
Show file tree
Hide file tree
Showing 125 changed files with 2,110 additions and 910 deletions.
7 changes: 3 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Objects/exceptions.c @iritkatriel
**/sha* @gpshead @tiran
Modules/md5* @gpshead @tiran
**/*blake* @gpshead @tiran
Modules/_blake2/** @gpshead @tiran
Modules/_hacl/** @gpshead

# logging
Expand Down Expand Up @@ -255,8 +254,8 @@ Modules/_interp*module.c @ericsnowcurrently
Lib/test/test_interpreters/ @ericsnowcurrently

# Android
**/*Android* @mhsmith
**/*android* @mhsmith
**/*Android* @mhsmith @freakboy3742
**/*android* @mhsmith @freakboy3742

# iOS (but not termios)
**/iOS* @freakboy3742
Expand All @@ -267,7 +266,7 @@ Lib/test/test_interpreters/ @ericsnowcurrently
**/*-ios* @freakboy3742

# WebAssembly
/Tools/wasm/ @brettcannon
/Tools/wasm/ @brettcannon @freakboy3742

# SBOM
/Misc/externals.spdx.json @sethmlarson
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ concurrency:
jobs:
interpreter:
name: Interpreter (Debug)
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
- true
- false
llvm:
- 18
- 19
include:
- target: i686-pc-windows-msvc/msvc
architecture: Win32
Expand All @@ -85,19 +85,19 @@ jobs:
compiler: clang
- target: x86_64-unknown-linux-gnu/gcc
architecture: x86_64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: gcc
- target: x86_64-unknown-linux-gnu/clang
architecture: x86_64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: clang
- target: aarch64-unknown-linux-gnu/gcc
architecture: aarch64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: gcc
- target: aarch64-unknown-linux-gnu/clang
architecture: aarch64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: clang
env:
CC: ${{ matrix.compiler }}
Expand All @@ -121,10 +121,15 @@ jobs:
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
- name: Native macOS
if: runner.os == 'macOS'
run: |
brew update
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
brew install llvm@${{ matrix.llvm }}
SDKROOT="$(xcrun --show-sdk-path)" \
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
Expand Down Expand Up @@ -164,16 +169,20 @@ jobs:
jit-with-disabled-gil:
name: Free-Threaded (Debug)
needs: interpreter
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
llvm:
- 19
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build with JIT enabled and GIL disabled
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 18
export PATH="$(llvm-config-18 --bindir):$PATH"
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
./configure --enable-experimental-jit --with-pydebug --disable-gil
make all --jobs 4
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The following functions provide locale-independent string to number conversions.
If ``s`` represents a value that is too large to store in a float
(for example, ``"1e500"`` is such a string on many platforms) then
if ``overflow_exception`` is ``NULL`` return ``Py_HUGE_VAL`` (with
if ``overflow_exception`` is ``NULL`` return ``Py_INFINITY`` (with
an appropriate sign) and don't set any exception. Otherwise,
``overflow_exception`` must point to a Python exception object;
raise that exception and return ``-1.0``. In both cases, set
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ slot typedefs
+-----------------------------+-----------------------------+----------------------+
| :c:type:`newfunc` | .. line-block:: | :c:type:`PyObject` * |
| | | |
| | :c:type:`PyObject` * | |
| | :c:type:`PyTypeObject` * | |
| | :c:type:`PyObject` * | |
| | :c:type:`PyObject` * | |
+-----------------------------+-----------------------------+----------------------+
Expand Down Expand Up @@ -2647,7 +2647,7 @@ Slot Type typedefs
See :c:member:`~PyTypeObject.tp_free`.

.. c:type:: PyObject *(*newfunc)(PyObject *, PyObject *, PyObject *)
.. c:type:: PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *)
See :c:member:`~PyTypeObject.tp_new`.

Expand Down
5 changes: 1 addition & 4 deletions Doc/deprecations/pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Pending removal in Python 3.14
:meth:`~pathlib.PurePath.relative_to`: passing additional arguments is
deprecated.

* :mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader`
* :mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:!pkgutil.get_loader`
now raise :exc:`DeprecationWarning`;
use :func:`importlib.util.find_spec` instead.
(Contributed by Nikita Sobolev in :gh:`97850`.)
Expand All @@ -103,9 +103,6 @@ Pending removal in Python 3.14
if :ref:`named placeholders <sqlite3-placeholders>` are used and
*parameters* is a sequence instead of a :class:`dict`.

* date and datetime adapter, date and timestamp converter:
see the :mod:`sqlite3` documentation for suggested replacement recipes.

* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
deprecated in :pep:`626`
since 3.10 and was planned to be removed in 3.12,
Expand Down
5 changes: 3 additions & 2 deletions Doc/library/collections.abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ ABC Inherits from Abstract Methods Mi

:class:`Set` :class:`Collection` ``__contains__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
``__iter__``, ``__gt__``, ``__ge__``, ``__and__``, ``__or__``,
``__len__`` ``__sub__``, ``__xor__``, and ``isdisjoint``
``__len__`` ``__sub__``, ``__rsub__``, ``__xor__``, ``__rxor__``
and ``isdisjoint``

:class:`MutableSet` :class:`Set` ``__contains__``, Inherited :class:`Set` methods and
``__iter__``, ``clear``, ``pop``, ``remove``, ``__ior__``,
Expand All @@ -162,7 +163,7 @@ ABC Inherits from Abstract Methods Mi
``__len__``


:class:`MappingView` :class:`Sized` ``__len__``
:class:`MappingView` :class:`Sized` ``__init__``, ``__len__`` and ``__repr__``
:class:`ItemsView` :class:`MappingView`, ``__contains__``,
:class:`Set` ``__iter__``
:class:`KeysView` :class:`MappingView`, ``__contains__``,
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ iterations of the loop.

.. versionadded:: 3.13

.. opcode:: FORMAT_SPEC
.. opcode:: FORMAT_WITH_SPEC

Formats the given value with the given format spec::

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using function-call syntax::
... BLUE = 3

>>> # functional syntax
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
>>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])

Even though we can use :keyword:`class` syntax to create Enums, Enums
are not normal Python classes. See
Expand Down
7 changes: 4 additions & 3 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1293,9 +1293,10 @@ are always available. They are listed here in alphabetical order.

.. class:: object()

Return a new featureless object. :class:`object` is a base for all classes.
It has methods that are common to all instances of Python classes. This
function does not accept any arguments.
This is the ultimate base class of all other classes. It has methods
that are common to all instances of Python classes. When the constructor
is called, it returns a new featureless object. The constructor does not
accept any arguments.

.. note::

Expand Down
6 changes: 3 additions & 3 deletions Doc/library/importlib.metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ Distribution metadata
.. class:: PackageMetadata

A concrete implementation of the
`PackageMetadata protocol <https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.PackageMetadata>`_.
`PackageMetadata protocol <https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.PackageMetadata>`_.

In addition to providing the defined protocol methods and attributes, subscripting
the instance is equivalent to calling the :meth:`!get` method.
In addition to providing the defined protocol methods and attributes, subscripting
the instance is equivalent to calling the :meth:`!get` method.

Every `Distribution Package <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_
includes some metadata, which you can extract using the :func:`!metadata` function::
Expand Down
92 changes: 89 additions & 3 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,92 @@ The following functions are provided by this module. Except when explicitly
noted otherwise, all return values are floats.


==================================================== ============================================
**Number-theoretic and representation functions**
--------------------------------------------------------------------------------------------------
:func:`ceil(x) <ceil>` Ceiling of *x*, the smallest integer greater than or equal to *x*
:func:`comb(n, k) <comb>` Number of ways to choose *k* items from *n* items without repetition and without order
:func:`copysign(x, y) <copysign>` Magnitude (absolute value) of *x* with the sign of *y*
:func:`fabs(x) <fabs>` Absolute value of *x*
:func:`factorial(n) <factorial>` *n* factorial
:func:`floor (x) <floor>` Floor of *x*, the largest integer less than or equal to *x*
:func:`fma(x, y, z) <fma>` Fused multiply-add operation: ``(x * y) + z``
:func:`fmod(x, y) <fmod>` Remainder of division ``x / y``
:func:`frexp(x) <frexp>` Mantissa and exponent of *x*
:func:`fsum(iterable) <fsum>` Sum of values in the input *iterable*
:func:`gcd(*integers) <gcd>` Greatest common divisor of the integer arguments
:func:`isclose(a, b, rel_tol, abs_tol) <isclose>` Check if the values *a* and *b* are close to each other
:func:`isfinite(x) <isfinite>` Check if *x* is neither an infinity nor a NaN
:func:`isinf(x) <isinf>` Check if *x* is a positive or negative infinity
:func:`isnan(x) <isnan>` Check if *x* is a NaN (not a number)
:func:`isqrt(n) <isqrt>` Integer square root of a nonnegative integer *n*
:func:`lcm(*integers) <lcm>` Least common multiple of the integer arguments
:func:`ldexp(x, i) <ldexp>` ``x * (2**i)``, inverse of function :func:`frexp`
:func:`modf(x) <modf>` Fractional and integer parts of *x*
:func:`nextafter(x, y, steps) <nextafter>` Floating-point value *steps* steps after *x* towards *y*
:func:`perm(n, k) <perm>` Number of ways to choose *k* items from *n* items without repetition and with order
:func:`prod(iterable, start) <prod>` Product of elements in the input *iterable* with a *start* value
:func:`remainder(x, y) <remainder>` Remainder of *x* with respect to *y*
:func:`sumprod(p, q) <sumprod>` Sum of products from two iterables *p* and *q*
:func:`trunc(x) <trunc>` Integer part of *x*
:func:`ulp(x) <ulp>` Value of the least significant bit of *x*

**Power and logarithmic functions**
--------------------------------------------------------------------------------------------------
:func:`cbrt(x) <cbrt>` Cube root of *x*
:func:`exp(x) <exp>` *e* raised to the power *x*
:func:`exp2(x) <exp2>` *2* raised to the power *x*
:func:`expm1(x) <expm1>` *e* raised to the power *x*, minus 1
:func:`log(x, base) <log>` Logarithm of *x* to the given base (*e* by default)
:func:`log1p(x) <log1p>` Natural logarithm of *1+x* (base *e*)
:func:`log2(x) <log2>` Base-2 logarithm of *x*
:func:`log10(x) <log10>` Base-10 logarithm of *x*
:func:`pow(x, y) <math.pow>` *x* raised to the power *y*
:func:`sqrt(x) <sqrt>` Square root of *x*

**Trigonometric functions**
--------------------------------------------------------------------------------------------------
:func:`acos(x) <acos>` Arc cosine of *x*
:func:`asin(x) <asin>` Arc sine of *x*
:func:`atan(x) <atan>` Arc tangent of *x*
:func:`atan2(y, x) <atan2>` ``atan(y / x)``
:func:`cos(x) <cos>` Cosine of *x*
:func:`dist(p, q) <dist>` Euclidean distance between two points *p* and *q* given as an iterable of coordinates
:func:`hypot(*coordinates) <hypot>` Euclidean norm of an iterable of coordinates
:func:`sin(x) <sin>` Sine of *x*
:func:`tan(x) <tan>` Tangent of *x*

**Angular conversion**
--------------------------------------------------------------------------------------------------
:func:`degrees(x) <degrees>` Convert angle *x* from radians to degrees
:func:`radians(x) <radians>` Convert angle *x* from degrees to radians

**Hyperbolic functions**
--------------------------------------------------------------------------------------------------
:func:`acosh(x) <acosh>` Inverse hyperbolic cosine of *x*
:func:`asinh(x) <asinh>` Inverse hyperbolic sine of *x*
:func:`atanh(x) <atanh>` Inverse hyperbolic tangent of *x*
:func:`cosh(x) <cosh>` Hyperbolic cosine of *x*
:func:`sinh(x) <sinh>` Hyperbolic sine of *x*
:func:`tanh(x) <tanh>` Hyperbolic tangent of *x*

**Special functions**
--------------------------------------------------------------------------------------------------
:func:`erf(x) <erf>` `Error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
:func:`erfc(x) <erfc>` `Complementary error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
:func:`gamma(x) <gamma>` `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*
:func:`lgamma(x) <lgamma>` Natural logarithm of the absolute value of the `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*

**Constants**
--------------------------------------------------------------------------------------------------
:data:`pi` *π* = 3.141592...
:data:`e` *e* = 2.718281...
:data:`tau` *τ* = 2\ *π* = 6.283185...
:data:`inf` Positive infinity
:data:`nan` "Not a number" (NaN)
==================================================== ============================================


Number-theoretic and representation functions
---------------------------------------------

Expand Down Expand Up @@ -447,11 +533,11 @@ Power and logarithmic functions

.. function:: pow(x, y)

Return ``x`` raised to the power ``y``. Exceptional cases follow
Return *x* raised to the power *y*. Exceptional cases follow
the IEEE 754 standard as far as possible. In particular,
``pow(1.0, x)`` and ``pow(x, 0.0)`` always return ``1.0``, even
when ``x`` is a zero or a NaN. If both ``x`` and ``y`` are finite,
``x`` is negative, and ``y`` is not an integer then ``pow(x, y)``
when *x* is a zero or a NaN. If both *x* and *y* are finite,
*x* is negative, and *y* is not an integer then ``pow(x, y)``
is undefined, and raises :exc:`ValueError`.

Unlike the built-in ``**`` operator, :func:`math.pow` converts both
Expand Down
1 change: 1 addition & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3675,6 +3675,7 @@ features:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(top)

.. audit-event:: os.walk top,topdown,onerror,followlinks os.walk

Expand Down
29 changes: 29 additions & 0 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,35 @@ Reading directories
raised.


.. method:: Path.scandir()

When the path points to a directory, return an iterator of
:class:`os.DirEntry` objects corresponding to entries in the directory. The
returned iterator supports the :term:`context manager` protocol. It is
implemented using :func:`os.scandir` and gives the same guarantees.

Using :meth:`~Path.scandir` instead of :meth:`~Path.iterdir` can
significantly increase the performance of code that also needs file type or
file attribute information, because :class:`os.DirEntry` objects expose
this information if the operating system provides it when scanning a
directory.

The following example displays the names of subdirectories. The
``entry.is_dir()`` check will generally not make an additional system call::

>>> p = Path('docs')
>>> with p.scandir() as entries:
... for entry in entries:
... if entry.is_dir():
... entry.name
...
'_templates'
'_build'
'_static'

.. versionadded:: 3.14


.. method:: Path.glob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Glob the given relative *pattern* in the directory represented by this path,
Expand Down
Loading

0 comments on commit 338f7e5

Please sign in to comment.