[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-bugs-list
Subject:    [issue37708] Harmonize random.choice(s) behavior with random.sample on iterators
From:       Raymond Hettinger <report () bugs ! python ! org>
Date:       2019-07-31 23:59:17
Message-ID: 1564617557.88.0.108835534751.issue37708 () roundup ! psfhosted ! org
[Download RAW message or body]


Raymond Hettinger <raymond.hettinger@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 <report@bugs.python.org>
<https://bugs.python.org/issue37708>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/python-bugs-list%40marc.info



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic