
On Sat, Aug 1, 2020 at 8:14 AM Christopher Barker <pythonchb@gmail.com> wrote:
If that's all we've come up with in this lengthy thread, it's probably not worth it -- after all, both of those can be efficiently accomplished with a little help from itertools.islice and/or next().
100% agree.
But I think we all agree that those tools are less newbie-friendly -- but they should be learned at some point, so maybe that's OK (and there is always the wrap it with a list approach, which is pretty newbie friendly)
I don't agree with it. It is somewhat newbie-frindly, but somewhat newbie unfriendly. Newbie will use random.sample(d.items()) or get-by-index without knowing it is O(n) even when they can create a list once and use it repeatedly. When people learn islice, they will learn it is not O(1) operation too. If dict views support direct indexing, it is very difficult to notice it is O(n) operation. They just think "Oh Python is fucking slow!". So it is newbie-unfriendly at some point. Regards, -- Inada Naoki <songofacandy@gmail.com>