[issue18844] allow weights in random.choice
Serhiy Storchaka
report at bugs.python.org
Wed Aug 6 19:27:00 CEST 2014
Serhiy Storchaka added the comment:
"Roulette Wheel 2" has twice slower initializations than "Roulette Wheel", but then generates every new item twice faster.
It is possible to implement hybrid generator, which yields first item using "Roulette Wheel", and then rescales cumulative_dist and continues with "Roulette Wheel 2". It will be so fast as "Roulette Wheel" for generating only one item and so fast as "Roulette Wheel 2" for generating multiple items.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18844>
_______________________________________
More information about the Python-bugs-list
mailing list