summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc_data
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pydoc_data')
-rw-r--r--Lib/pydoc_data/topics.py153
1 files changed, 139 insertions, 14 deletions
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index c290f95..e2d3a51 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,4 +1,4 @@
-# Autogenerated by Sphinx on Tue Jan 13 12:26:49 2026
+# Autogenerated by Sphinx on Wed Jan 14 16:41:25 2026
# as part of the release process.
topics = {
@@ -867,7 +867,8 @@ Notes on using *__slots__*:
* "TypeError" will be raised if *__slots__* other than *__dict__* and
*__weakref__* are defined for a class derived from a ""variable-
- length" built-in type" such as "int", "bytes", and "tuple".
+ length" built-in type" such as "int", "bytes", and "type", except
+ "tuple".
* Any non-string *iterable* may be assigned to *__slots__*.
@@ -889,7 +890,8 @@ Notes on using *__slots__*:
attribute will be an empty iterator.
Changed in version 3.15: Allowed defining the *__dict__* and
-*__weakref__* *__slots__* for any class.
+*__weakref__* *__slots__* for any class. Allowed defining any
+*__slots__* for a class derived from "tuple".
''',
'attribute-references': r'''Attribute references
********************
@@ -9011,7 +9013,8 @@ Notes on using *__slots__*:
* "TypeError" will be raised if *__slots__* other than *__dict__* and
*__weakref__* are defined for a class derived from a ""variable-
- length" built-in type" such as "int", "bytes", and "tuple".
+ length" built-in type" such as "int", "bytes", and "type", except
+ "tuple".
* Any non-string *iterable* may be assigned to *__slots__*.
@@ -9033,7 +9036,8 @@ Notes on using *__slots__*:
attribute will be an empty iterator.
Changed in version 3.15: Allowed defining the *__dict__* and
-*__weakref__* *__slots__* for any class.
+*__weakref__* *__slots__* for any class. Allowed defining any
+*__slots__* for a class derived from "tuple".
Customizing class creation
@@ -10062,7 +10066,12 @@ str.casefold()
it is intended to remove all case distinctions in a string. For
example, the German lowercase letter "'ß'" is equivalent to ""ss"".
Since it is already lowercase, "lower()" would do nothing to "'ß'";
- "casefold()" converts it to ""ss"".
+ "casefold()" converts it to ""ss"". For example:
+
+ >>> 'straße'.lower()
+ 'straße'
+ >>> 'straße'.casefold()
+ 'strasse'
The casefolding algorithm is described in section 3.13.3 ‘Default
Case Folding’ of the Unicode Standard.
@@ -10251,7 +10260,16 @@ str.format_map(mapping, /)
str.index(sub[, start[, end]])
Like "find()", but raise "ValueError" when the substring is not
- found.
+ found. For example:
+
+ >>> 'spam, spam, spam'.index('eggs')
+ Traceback (most recent call last):
+ File "<python-input-0>", line 1, in <module>
+ 'spam, spam, spam'.index('eggs')
+ ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
+ ValueError: substring not found
+
+ See also "rindex()".
str.isalnum()
@@ -10380,6 +10398,13 @@ str.isprintable()
plus the ASCII space 0x20. Nonprintable characters are those in
group Separator or Other (Z or C), except the ASCII space.
+ For example:
+
+ >>> ''.isprintable(), ' '.isprintable()
+ (True, True)
+ >>> '\t'.isprintable(), '\n'.isprintable()
+ (False, False)
+
str.isspace()
Return "True" if there are only whitespace characters in the string
@@ -10459,7 +10484,10 @@ str.ljust(width, fillchar=' ', /)
str.lower()
Return a copy of the string with all the cased characters [4]
- converted to lowercase.
+ converted to lowercase. For example:
+
+ >>> 'Lower Method Example'.lower()
+ 'lower method example'
The lowercasing algorithm used is described in section 3.13.2
‘Default Case Conversion’ of the Unicode Standard.
@@ -10523,6 +10551,8 @@ str.removeprefix(prefix, /)
Added in version 3.9.
+ See also "removesuffix()" and "startswith()".
+
str.removesuffix(suffix, /)
If the string ends with the *suffix* string and that *suffix* is
@@ -10536,12 +10566,19 @@ str.removesuffix(suffix, /)
Added in version 3.9.
+ See also "removeprefix()" and "endswith()".
+
str.replace(old, new, /, count=-1)
Return a copy of the string with all occurrences of substring *old*
replaced by *new*. If *count* is given, only the first *count*
occurrences are replaced. If *count* is not specified or "-1", then
- all occurrences are replaced.
+ all occurrences are replaced. For example:
+
+ >>> 'spam, spam, spam'.replace('spam', 'eggs')
+ 'eggs, eggs, eggs'
+ >>> 'spam, spam, spam'.replace('spam', 'eggs', 1)
+ 'eggs, spam, spam'
Changed in version 3.13: *count* is now supported as a keyword
argument.
@@ -10551,7 +10588,14 @@ str.rfind(sub[, start[, end]])
Return the highest index in the string where substring *sub* is
found, such that *sub* is contained within "s[start:end]".
Optional arguments *start* and *end* are interpreted as in slice
- notation. Return "-1" on failure.
+ notation. Return "-1" on failure. For example:
+
+ >>> 'spam, spam, spam'.rfind('sp')
+ 12
+ >>> 'spam, spam, spam'.rfind('sp', 0, 10)
+ 6
+
+ See also "find()" and "rindex()".
str.rindex(sub[, start[, end]])
@@ -13009,6 +13053,10 @@ Slice objects
Slice objects are used to represent slices for "__getitem__()"
methods. They are also created by the built-in "slice()" function.
+Added in version 3.15: The "slice()" type now supports subscription.
+For example, "slice[float]" may be used in type annotations to
+indicate a slice containing "float" objects.
+
Special read-only attributes: "start" is the lower bound; "stop" is
the upper bound; "step" is the step value; each is "None" if omitted.
These attributes can have any type.
@@ -13624,10 +13672,17 @@ Notes:
note that "-0" is still "0".
4. 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* 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.
+ 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.
5. The slice of *s* from *i* to *j* with step *k* is defined as the
sequence of items with index "x = i + n*k" such that "0 <= n <
@@ -13892,6 +13947,76 @@ class list(iterable=(), /)
empty for the duration, and raises "ValueError" if it can detect
that the list has been mutated during a sort.
+Thread safety: Reading a single element from a "list" is *atomic*:
+
+ lst[i] # list.__getitem__
+
+The following methods traverse the list and use *atomic* reads of each
+item to perform their function. That means that they may return
+results affected by concurrent modifications:
+
+ item in lst
+ lst.index(item)
+ lst.count(item)
+
+All of the above methods/operations are also lock-free. They do not
+block concurrent modifications. Other operations that hold a lock will
+not block these from observing intermediate states.All other
+operations from here on block using the per-object lock.Writing a
+single item via "lst[i] = x" is safe to call from multiple threads and
+will not corrupt the list.The following operations return new objects
+and appear *atomic* to other threads:
+
+ lst1 + lst2 # concatenates two lists into a new list
+ x * lst # repeats lst x times into a new list
+ lst.copy() # returns a shallow copy of the list
+
+Methods that only operate on a single elements with no shifting
+required are *atomic*:
+
+ lst.append(x) # append to the end of the list, no shifting required
+ lst.pop() # pop element from the end of the list, no shifting required
+
+The "clear()" method is also *atomic*. Other threads cannot observe
+elements being removed.The "sort()" method is not *atomic*. Other
+threads cannot observe intermediate states during sorting, but the
+list appears empty for the duration of the sort.The following
+operations may allow lock-free operations to observe intermediate
+states since they modify multiple elements in place:
+
+ lst.insert(idx, item) # shifts elements
+ lst.pop(idx) # idx not at the end of the list, shifts elements
+ lst *= x # copies elements in place
+
+The "remove()" method may allow concurrent modifications since element
+comparison may execute arbitrary Python code (via
+"__eq__()")."extend()" is safe to call from multiple threads.
+However, its guarantees depend on the iterable passed to it. If it is
+a "list", a "tuple", a "set", a "frozenset", a "dict" or a dictionary
+view object (but not their subclasses), the "extend" operation is safe
+from concurrent modifications to the iterable. Otherwise, an iterator
+is created which can be concurrently modified by another thread. The
+same applies to inplace concatenation of a list with other iterables
+when using "lst += iterable".Similarly, assigning to a list slice with
+"lst[i:j] = iterable" is safe to call from multiple threads, but
+"iterable" is only locked when it is also a "list" (but not its
+subclasses).Operations that involve multiple accesses, as well as
+iteration, are never atomic. For example:
+
+ # NOT atomic: read-modify-write
+ lst[i] = lst[i] + 1
+
+ # NOT atomic: check-then-act
+ if lst:
+ item = lst.pop()
+
+ # NOT thread-safe: iteration while modifying
+ for item in lst:
+ process(item) # another thread may modify lst
+
+Consider external synchronization when sharing "list" instances across
+threads. See Python support for free threading for more information.
+
Tuples
======