Skip to content

Commit a893080

Browse files
StanFromIrelandnedbatdg-pb
committed
Try to simplify footnote
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com> Co-authored-by: dgpb <3577712+dg-pb@users.noreply.github.com>
1 parent 4d223f1 commit a893080

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Doc/library/time-complexity.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ the buffer instead of moving the remaining bytes, and is amortized *O*\ (1).
207207
* - Substring search (``x in s``, ``s.find(x)``, ``s.index(x)``)
208208
- *O*\ (*n*)
209209
* - Reverse substring search (``s.rfind(x)``, ``s.rindex(x)``) [10]_
210-
- *O*\ (*nk*)
210+
- *O*\ (*n* × len(*x*))
211211
* - Encode or decode
212212
- *O*\ (*n*)
213213
* - Iteration
@@ -308,12 +308,12 @@ Notes
308308
See the :ref:`note on concatenating immutable sequences
309309
<typesseq-repeated-concatenation>` for alternatives.
310310
311-
.. [10] *k* is the length of the substring searched for. Forward searches use
312-
algorithms with a linear worst case, described in
313-
:source:`Objects/stringlib/stringlib_find_two_way_notes.txt`. Reverse
314-
searches use a simpler algorithm, which is *O*\ (*n*) on typical input but
315-
has no linear worst case. ``s.rpartition(x)`` and ``s.rsplit(x)`` search
316-
backwards too.
311+
.. [10] This is the worst case. Reverse searches are *O*\ (*n*) on typical
312+
input. Forward searches instead use a more elaborate algorithm with a
313+
linear worst case, described in
314+
:source:`Objects/stringlib/stringlib_find_two_way_notes.txt`.
315+
``s.rpartition(x)`` and ``s.rsplit(x)`` search backwards too, with the same
316+
complexity.
317317
318318
.. [11] Assuming :class:`int` or :class:`bool` arguments. For other types,
319319
the range is searched like any other sequence in *O*\ (*n*) time.

0 commit comments

Comments
 (0)