Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
The sample() function accepts d.keys() because a keys view is registered as being an instance of collections.abc.Set. We have to do that because sample() is specifically documented as accepting sets. If we had it do over again, that functionality would likely not be supported (it implicitly the population into a tuple). For a fine-grained function like choice() that implicit population conversion would make no sense at all. For choices(), we can choose not to make that API mistake again. Thanks for the suggestion, but I am going to decline. It isn't something that we need in practice and it would add complication for near zero gain. (Also, there is no rule that all of these functions have to accept the same kinds of inputs -- different algorithms and different use cases allow for some flexibility). ---------- resolution: -> rejected stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37708> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com