Raymond Hettinger added the comment:
The docs are correct as-is. This is a documented and tested behavior.
>>> from heapq import nsmallest
>>> list(nsmallest(3, ['larry', 'georg', 'raymond', 'guido', 'tim'],
key=len))
['tim', 'larry', 'georg']
The C implementation doesn't have a key-argument. That behavior gets added
downstream in pure python in Lib/heapq.py which wraps the C-function and adds
the additional behavior.
----------
assignee: -> rhettinger
nosy: +rhettinger
priority: low -> normal
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20407>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com