Skip to content

Commit 26b51be

Browse files
committed
StdlibRationales.rst: add explanation why sorted() is not lazy
1 parent 762dd11 commit 26b51be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/StdlibRationales.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ the first three functions being lazy is the right default, since usually the
165165
result is immediately consumed by for-in, so we don't want to allocate memory
166166
for it.
167167

168+
Note that neither of the two ``sorted()`` methods (neither one that accepts a
169+
custom comparator closure, nor one that uses the ``Comparable`` conformace)
170+
can't be lazy, becasue the lazy version would be less efficient than the eager
171+
one.
172+
168173
A different design that was rejected is to preserve consistency with other
169174
strict functions by making these methods strict, but then client code needs to
170175
call an API with a different name, say ``lazyEnumerate()`` to opt into

0 commit comments

Comments
 (0)