This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Christian.Kleineidam, NeilGirdhar, aisaac, davin, dkorchem, madison.may, mark.dickinson, pitrou, python-dev, rhettinger, serhiy.storchaka, tim.peters, westley.martinez, xksteven
Date 2016-09-07.23:08:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473289704.6.0.561918901856.issue18844@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2016-09-07 23:08:24rhettingersetrecipients: + 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:24rhettingersetmessageid: <1473289704.6.0.561918901856.issue18844@psf.upfronthosting.co.za>
2016-09-07 23:08:24rhettingerlinkissue18844 messages
2016-09-07 23:08:24rhettingercreate