Message274907
There isn't really an option to return a generator because it conflicts the rest of the module that uses lists elsewhere and that allows state to be saved and restored before and after any function call. One of the design reviewers also said that the generator form would harder for students to use.
I left the text in the examples section unchanged because it is still valid (showing how to make a cumulative distribution and how to build a fast alternative for the special case of small integer weights). Before the 3.6 release, I expect to expand this section to provide recipes for a MCMC application (using choices() with a passed-in CDF) and some other examples suggested by the design reviewers.
The optimization hacks in the other patch don't seem worth it. The current code is readable and runs fast (the principal steps are all C functions). |
|
Date |
User |
Action |
Args |
2016-09-07 23:08:24 | rhettinger | set | recipients:
+ rhettinger, tim.peters, mark.dickinson, pitrou, aisaac, westley.martinez, python-dev, serhiy.storchaka, NeilGirdhar, madison.may, dkorchem, Christian.Kleineidam, davin, xksteven |
2016-09-07 23:08:24 | rhettinger | set | messageid: <1473289704.6.0.561918901856.issue18844@psf.upfronthosting.co.za> |
2016-09-07 23:08:24 | rhettinger | link | issue18844 messages |
2016-09-07 23:08:24 | rhettinger | create | |
|