Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ the argument list is also provided by the Python program, through the same
interface that specified the callback function. It can then be saved and used
in the same manner as the function object. In other cases, you may have to
construct a new tuple to pass as the argument list. The simplest way to do this
is to call :c:func:`Py_BuildValue`. For example, if you want to pass an integral
is to call :c:func:`Py_BuildValue`. For example, if you want to pass an integer
event code, you might use the following code::

PyObject *arglist;
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ This module defines the following constants and functions:

.. function:: get_native_id()

Return the native integral Thread ID of the current thread assigned by the kernel.
Return the native integer Thread ID of the current thread assigned by the kernel.
This is a non-negative integer.
Its value may be used to uniquely identify this particular thread system-wide
(until the thread terminates, after which the value may be recycled by the OS).
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ Decimal objects
trap is set. By default the trap is off.

.. versionchanged:: 3.6
Underscores are allowed for grouping, as with integral and floating-point
Underscores are allowed for grouping, as with integer and floating-point
literals in code.

Decimal floating point objects share many properties with the other built-in
Expand Down Expand Up @@ -1352,7 +1352,7 @@ In addition to the three supplied contexts, new contexts can be created with the
Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given.

With two arguments, compute ``x**y``. If ``x`` is negative then ``y``
must be integral. The result will be inexact unless ``y`` is integral and
must be integer. The result will be inexact unless ``y`` is integer and
the result is finite and can be expressed exactly in 'precision' digits.
The rounding mode of the context is used. Results are always correctly-rounded
in the Python version.
Expand All @@ -1368,7 +1368,7 @@ In addition to the three supplied contexts, new contexts can be created with the
With three arguments, compute ``(x**y) % modulo``. For the three argument
form, the following restrictions on the arguments hold:

- all three arguments must be integral
- all three arguments must be integer
- ``y`` must be nonnegative
- at least one of ``x`` or ``y`` must be nonzero
- ``modulo`` must be nonzero and have at most 'precision' digits
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Number-theoretic and representation functions

Return the ceiling of *x*, the smallest integer greater than or equal to *x*.
If *x* is not a float, delegates to ``x.__ceil__()``, which should return an
:class:`~numbers.Integral` value.
:class:`~numbers.Integer` value.


.. function:: comb(n, k)
Expand Down Expand Up @@ -68,18 +68,18 @@ Number-theoretic and representation functions

.. function:: factorial(x)

Return *x* factorial as an integer. Raises :exc:`ValueError` if *x* is not integral or
Return *x* factorial as an integer. Raises :exc:`ValueError` if *x* is not integer or
is negative.

.. deprecated:: 3.9
Accepting floats with integral values (like ``5.0``) is deprecated.
Accepting floats with integer values (like ``5.0``) is deprecated.


.. function:: floor(x)

Return the floor of *x*, the largest integer less than or equal to *x*.
If *x* is not a float, delegates to ``x.__floor__()``, which should return an
:class:`~numbers.Integral` value.
:class:`~numbers.Integer` value.


.. function:: fmod(x, y)
Expand Down Expand Up @@ -299,7 +299,7 @@ Number-theoretic and representation functions
.. function:: trunc(x)

Return the :class:`~numbers.Real` value *x* truncated to an
:class:`~numbers.Integral` (usually an integer). Delegates to
:class:`~numbers.Integer` (usually an integer). Delegates to
:meth:`x.__trunc__() <object.__trunc__>`.

.. function:: ulp(x)
Expand Down
22 changes: 14 additions & 8 deletions Doc/library/numbers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
================================================

.. module:: numbers
:synopsis: Numeric abstract base classes (Complex, Real, Integral, etc.).
:synopsis: Numeric abstract base classes (Complex, Real, Integer, etc.).

**Source code:** :source:`Lib/numbers.py`

Expand Down Expand Up @@ -72,13 +72,19 @@ The numeric tower
Abstract.


.. class:: Integral
.. class:: Integer

Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
defaults for :func:`float`, :attr:`~Rational.numerator`, and
:attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.

.. class:: Integral

Alias for :class:`Integer`.

.. deprecated:: 3.10


Notes for type implementors
---------------------------
Expand Down Expand Up @@ -121,25 +127,25 @@ Implementing the arithmetic operations
We want to implement the arithmetic operations so that mixed-mode
operations either call an implementation whose author knew about the
types of both arguments, or convert both to the nearest built in type
and do the operation there. For subtypes of :class:`Integral`, this
and do the operation there. For subtypes of :class:`Integer`, this
means that :meth:`__add__` and :meth:`__radd__` should be defined as::

class MyIntegral(Integral):
class MyInteger(Integer):

def __add__(self, other):
if isinstance(other, MyIntegral):
if isinstance(other, MyInteger):
return do_my_adding_stuff(self, other)
elif isinstance(other, OtherTypeIKnowAbout):
return do_my_other_adding_stuff(self, other)
else:
return NotImplemented

def __radd__(self, other):
if isinstance(other, MyIntegral):
if isinstance(other, MyInteger):
return do_my_adding_stuff(other, self)
elif isinstance(other, OtherTypeIKnowAbout):
return do_my_other_adding_stuff(other, self)
elif isinstance(other, Integral):
elif isinstance(other, Integer):
return int(other) + int(self)
elif isinstance(other, Real):
return float(other) + float(self)
Expand All @@ -151,7 +157,7 @@ means that :meth:`__add__` and :meth:`__radd__` should be defined as::

There are 5 different cases for a mixed-type operation on subclasses
of :class:`Complex`. I'll refer to all of the above code that doesn't
refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as
refer to ``MyInteger`` and ``OtherTypeIKnowAbout`` as
"boilerplate". ``a`` will be an instance of ``A``, which is a subtype
of :class:`Complex` (``a : A <: Complex``), and ``b : B <:
Complex``. I'll consider ``a + b``:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Functions for integers
``randrange(10)``. In the future, this will raise a :exc:`TypeError`.

.. deprecated:: 3.10
The exception raised for non-integral values such as ``randrange(10.5)``
The exception raised for non-integer values such as ``randrange(10.5)``
or ``randrange('10')`` will be changed from :exc:`ValueError` to
:exc:`TypeError`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ form.
This means that the two following regular expression objects that match a
decimal number are functionally equal::

a = re.compile(r"""\d + # the integral part
a = re.compile(r"""\d + # the integer part
\. # the decimal point
\d * # some fractional digits""", re.X)
b = re.compile(r"\d+\.\d*")
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,17 @@ the following operations:
+--------------------+---------------------------------------------+
| Operation | Result |
+====================+=============================================+
| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` |
| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integer` |
| x) <math.trunc>` | |
+--------------------+---------------------------------------------+
| :func:`round(x[, | *x* rounded to *n* digits, |
| n]) <round>` | rounding half to even. If *n* is |
| | omitted, it defaults to 0. |
+--------------------+---------------------------------------------+
| :func:`math.floor(\| the greatest :class:`~numbers.Integral` |
| :func:`math.floor(\| the greatest :class:`~numbers.Integer` |
| x) <math.floor>` | <= *x* |
+--------------------+---------------------------------------------+
| :func:`math.ceil(x)| the least :class:`~numbers.Integral` >= *x* |
| :func:`math.ceil(x)| the least :class:`~numbers.Integer` >= *x* |
| <math.ceil>` | |
+--------------------+---------------------------------------------+

Expand Down Expand Up @@ -449,7 +449,7 @@ Notes:
Additional Methods on Integer Types
-----------------------------------

The int type implements the :class:`numbers.Integral` :term:`abstract base
The int type implements the :class:`numbers.Integer` :term:`abstract base
class`. In addition, it provides a few more methods:

.. method:: int.bit_length()
Expand Down Expand Up @@ -585,7 +585,7 @@ class`. float also has the following additional methods.

.. method:: float.is_integer()

Return ``True`` if the float instance is finite with integral
Return ``True`` if the float instance is finite with integer
value, and ``False`` otherwise::

>>> (-2.0).is_integer()
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Notes:
format <half precision format_>`_ for more information.


A format character may be preceded by an integral repeat count. For example,
A format character may be preceded by an integer repeat count. For example,
the format string ``'4h'`` means exactly the same as ``'hhhh'``.

Whitespace characters between formats are ignored; a count and its format must
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ This module defines the following functions:

.. function:: get_native_id()

Return the native integral Thread ID of the current thread assigned by the kernel.
Return the native integer Thread ID of the current thread assigned by the kernel.
This is a non-negative integer.
Its value may be used to uniquely identify this particular thread system-wide
(until the thread terminates, after which the value may be recycled by the OS).
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/wave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Wave_write objects, as returned by :func:`.open`, have the following methods:
Set the frame rate to *n*.

.. versionchanged:: 3.2
A non-integral input to this method is rounded to the nearest
A non-integer input to this method is rounded to the nearest
integer.


Expand Down
6 changes: 3 additions & 3 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Ellipsis
Python distinguishes between integers, floating point numbers, and complex
numbers:

:class:`numbers.Integral`
:class:`numbers.Integer`
.. index:: object: integer

These represent elements from the mathematical set of integers (positive and
Expand Down Expand Up @@ -2338,7 +2338,7 @@ Emulating numeric types

The following methods can be defined to emulate numeric objects. Methods
corresponding to operations that are not supported by the particular kind of
number implemented (e.g., bitwise operations for non-integral numbers) should be
number implemented (e.g., bitwise operations for non-integer numbers) should be
left undefined.


Expand Down Expand Up @@ -2495,7 +2495,7 @@ left undefined.
Called to implement the built-in function :func:`round` and :mod:`math`
functions :func:`~math.trunc`, :func:`~math.floor` and :func:`~math.ceil`.
Unless *ndigits* is passed to :meth:`!__round__` all these methods should
return the value of the object truncated to an :class:`~numbers.Integral`
return the value of the object truncated to an :class:`~numbers.Integer`
(typically an :class:`int`).

If :meth:`__int__` is not defined then the built-in function :func:`int`
Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ The unary ``+`` (plus) operator yields its numeric argument unchanged.

The unary ``~`` (invert) operator yields the bitwise inversion of its integer
argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. It only
applies to integral numbers.
applies to integer numbers.

.. index:: exception: TypeError

Expand Down
8 changes: 4 additions & 4 deletions Doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ converted to floats. Python 2.6 adds a simple rational-number class,
:class:`Fraction` instead of :class:`Rational` to avoid
a name clash with :class:`numbers.Rational`.)

:class:`Integral` numbers derive from :class:`Rational`, and
``Integral`` numbers derive from :class:`Rational`, and
can be shifted left and right with ``<<`` and ``>>``,
combined using bitwise operations such as ``&`` and ``|``,
and can be used as array indexes and slice boundaries.
Expand All @@ -1424,7 +1424,7 @@ In Python 3.0, the PEP slightly redefines the existing builtins
:func:`round`, :func:`math.floor`, :func:`math.ceil`, and adds a new
one, :func:`math.trunc`, that's been backported to Python 2.6.
:func:`math.trunc` rounds toward zero, returning the closest
:class:`Integral` that's between the function's argument and zero.
``Integral`` that's between the function's argument and zero.

.. seealso::

Expand All @@ -1445,7 +1445,7 @@ values as a numerator and denominator forming a fraction, and can
exactly represent numbers such as ``2/3`` that floating-point numbers
can only approximate.

The :class:`Fraction` constructor takes two :class:`Integral` values
The :class:`Fraction` constructor takes two ``Integral`` values
that will be the numerator and denominator of the resulting fraction. ::

>>> from fractions import Fraction
Expand Down Expand Up @@ -2111,7 +2111,7 @@ changes, or look through the Subversion logs for all the details.
(base *e*).

* :func:`trunc` rounds a number toward zero, returning the closest
:class:`Integral` that's between the function's argument and zero.
``Integral`` that's between the function's argument and zero.
Added as part of the backport of
`PEP 3141's type hierarchy for numbers <#pep-3141>`__.

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Integers
--------

* :pep:`237`: Essentially, :class:`long` renamed to :class:`int`.
That is, there is only one built-in integral type, named
That is, there is only one built-in integer type, named
:class:`int`; but it behaves mostly like the old :class:`long` type.

* :pep:`238`: An expression like ``1/2`` returns a float. Use
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ uncaught :meth:`threading.Thread.run` exceptions are handled.
Add a new :func:`threading.get_native_id` function and
a :data:`~threading.Thread.native_id`
attribute to the :class:`threading.Thread` class. These return the native
integral Thread ID of the current thread assigned by the kernel.
integer Thread ID of the current thread assigned by the kernel.
This feature is only available on certain platforms, see
:func:`get_native_id <threading.get_native_id>` for more information.
(Contributed by Jake Tesler in :issue:`36084`.)
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ Deprecated

* Currently :func:`math.factorial` accepts :class:`float` instances with
non-negative integer values (like ``5.0``). It raises a :exc:`ValueError`
for non-integral and negative floats. It is now deprecated. In future
for non-integer and negative floats. It is now deprecated. In future
Python versions it will raise a :exc:`TypeError` for all floats.
(Contributed by Serhiy Storchaka in :issue:`37315`.)

Expand Down
4 changes: 2 additions & 2 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2);
#endif

/* Returns the result of dividing o1 by o2 giving an integral result,
/* Returns the result of dividing o1 by o2 giving an integer result,
or NULL on failure.

This is the equivalent of the Python expression: o1 // o2. */
Expand Down Expand Up @@ -522,7 +522,7 @@ PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2);
#endif

/* Returns the result of dividing o1 by o2 giving an integral result, possibly
/* Returns the result of dividing o1 by o2 giving an integer result, possibly
in-place, or NULL on failure.

This is the equivalent of the Python expression: o1 /= o2. */
Expand Down
10 changes: 5 additions & 5 deletions Include/pymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
(X) == -Py_HUGE_VAL))
#endif

/* Return whether integral type *type* is signed or not. */
/* Return whether integer type *type* is signed or not. */
#define _Py_IntegralTypeSigned(type) ((type)(-1) < 0)
/* Return the maximum value of integral type *type*. */
/* Return the maximum value of integer type *type*. */
#define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
/* Return the minimum value of integral type *type*. */
/* Return the minimum value of integer type *type*. */
#define _Py_IntegralTypeMin(type) ((_Py_IntegralTypeSigned(type)) ? -_Py_IntegralTypeMax(type) - 1 : 0)
/* Check whether *v* is in the range of integral type *type*. This is most
/* Check whether *v* is in the range of integer type *type*. This is most
* useful if *v* is floating-point, since demoting a floating-point *v* to an
* integral type that cannot represent *v*'s integral part is undefined
* integer type that cannot represent *v*'s integer part is undefined
* behavior. */
#define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))

Expand Down
Loading