
July 31, 2020
9:14 p.m.
On Sat, Aug 1, 2020 at 10:04 AM Wes Turner <wes.turner@gmail.com> wrote:
Actually, I think the reverse traversal case is the worst case because: it's not possible to use negative subscripts with islice (because that would require making a full copy).
This doesn't work:
islice(dict.keys(), -1, -5)
Reverse traversal did work in Python 2 but was foregone when making .keys() a view in Python 3 in order to avoid lulling users into making usually unnecessary copies.
dict is reversible now. You can do `islice(dict, 0, 5)`. -- Inada Naoki <songofacandy@gmail.com>