https://github.com/python/cpython/commit/444ebaf16e5d358d4c32011eb8b6ca14858719a0
commit: 444ebaf16e5d358d4c32011eb8b6ca14858719a0
branch: main
author: Oleksandr Kravets <[email protected]>
committer: rhettinger <[email protected]>
date: 2025-09-18T00:52:46-05:00
summary:
Remove unnecessary slice in heapq.py (gh-139087)
files:
M Lib/heapq.py
diff --git a/Lib/heapq.py b/Lib/heapq.py
index 17f62dd2d5839b..f944376bcd291f 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -494,7 +494,7 @@ def nsmallest(n, iterable, key=None):
pass
else:
if n >= size:
- return sorted(iterable, key=key)[:n]
+ return sorted(iterable, key=key)
# When key is none, use simpler decoration
if key is None:
@@ -554,7 +554,7 @@ def nlargest(n, iterable, key=None):
pass
else:
if n >= size:
- return sorted(iterable, key=key, reverse=True)[:n]
+ return sorted(iterable, key=key, reverse=True)
# When key is none, use simpler decoration
if key is None:
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]