Skip to content

Conversation

@skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Jan 5, 2026

This explain what happens when for negative start or stop arguments of big magnitude.

Also reference sequence term in the :mod:array docs.


📚 Documentation preview 📚: https://cpython-previews--143422.org.readthedocs.build/en/143422/library/stdtypes.html

This explain what happens when for negative start or stop
arguments of big magnitude.

Also reference sequence term in the :mod:`array` docs.
@skirpichev skirpichev requested a review from hugovk January 9, 2026 22:54
@skirpichev
Copy link
Contributor Author

CC @hugovk, per experts index (see issue thread on proposal to remove redundant methods from array docs)


This module defines an object type which can compactly represent an array of
basic values: characters, integers, floating-point numbers. Arrays are sequence
basic values: characters, integers, floating-point numbers. Arrays are :term:`sequence`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe directly say "mutable sequence" types?

Comment on lines +1098 to 1100
``len(s)``. If *i* or *j* is less than ``-len(s)``, use ``0``.
If *i* is omitted or ``None``, use ``0``. If *j* is omitted or
``None``, use ``len(s)``. If *i* is greater than or equal to *j*, the slice is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could compress this as:

If *i* or *j* is greater than ``len(s)`` (respectively, ``-len(s)``), use ``len(s)`` (respectively, ``0``). If *i* (respectively, *j*) is
omitted or ``None``, use ``0`` (respectively ``len(s)``).

However, for readers not familiar with the If X (resp. X'), then Y (resp. Y') construction, it may be very confusing. An alternative would be to have a bullet point list though it could make the paragraph vertically large. And fina alternative is to group those sentences:

   The slice of *s* from *i* to *j* is defined as the sequence of items with index *k* such that ``i <= k < j``.

   If *i* or *j* is greater than ``len(s)``, use ``len(s)``.
   If *i* or *j* is less than ``-len(s)``, use ``0``.

   If *i* is omitted or ``None``, use ``0``.
   If *j* is omitted or ``None``, use ``len(s)``.

   If *i* is greater than or equal to *j*, the slice is empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that "respectively" is confusing. And let's not compress further, dense text is harder to read and understand.

I like that final one, with bullets, and slightly re-ordered with simpler cases first:

   The slice of *s* from *i* to *j* is defined as the sequence of items with index *k* such that ``i <= k < j``.

   * If *i* is omitted or ``None``, use ``0``.
   * If *j* is omitted or ``None``, use ``len(s)``.
   * If *i* or *j* is less than ``-len(s)``, use ``0``.
   * If *i* or *j* is greater than ``len(s)``, use ``len(s)``.
   * If *i* is greater than or equal to *j*, the slice is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants