aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/heapq.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/heapq.py')
-rw-r--r--Lib/heapq.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py
index b31f4186cf6..0e3555cf911 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -468,10 +468,7 @@ def nsmallest(n, iterable, key=None):
if n == 1:
it = iter(iterable)
sentinel = object()
- if key is None:
- result = min(it, default=sentinel)
- else:
- result = min(it, default=sentinel, key=key)
+ result = min(it, default=sentinel, key=key)
return [] if result is sentinel else [result]
# When n>=size, it's faster to use sorted()
@@ -531,10 +528,7 @@ def nlargest(n, iterable, key=None):
if n == 1:
it = iter(iterable)
sentinel = object()
- if key is None:
- result = max(it, default=sentinel)
- else:
- result = max(it, default=sentinel, key=key)
+ result = max(it, default=sentinel, key=key)
return [] if result is sentinel else [result]
# When n>=size, it's faster to use sorted()