[issue44400] Propose random.randbool()

2021-06-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I would like to get opinions from Raymond and then > proceed with this issue. I concur with Steven and Serhiy and don't think this should be added. -- resolution: -> rejected stage: -> resolved status: open -> closed _

[issue44400] Propose random.randbool()

2021-06-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: As for randbool() I concur with Steven. It is too trivial and in most case you do not even need to call bool(). Alternate methods: choice((False, True)) random() < 0.5 They are less efficient than getrandbits(1), but can be easily extended to non

[issue44400] Propose random.randbool()

2021-06-12 Thread Dong-hee Na
Dong-hee Na added the comment: s / from other core-devs / from core-devs -- ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue44400] Propose random.randbool()

2021-06-12 Thread Dong-hee Na
Dong-hee Na added the comment: To explain my thought, > Not every one line expression needs to be a function in a library. > `bool(getrandbits(1))` is self-explanatory enough, Yeah, I agree with the point of view, it might be enough. But considering the popularity of the Python language and

[issue44400] Propose random.randbool()

2021-06-12 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue44400] Propose random.randbool()

2021-06-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is difficult to deprecate getrandbits() because it is one of two base methods. All Random methods call either getrandbits() or randome(). Overriding them is a way to make a new random generator. -- nosy: +serhiy.storchaka __

[issue44400] Propose random.randbool()

2021-06-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Not every one line expression needs to be a function in a library. `bool(getrandbits(1))` is self-explanatory enough, and it is doubtful that any implementation would be faster. Using getrandbits(1) to return 0 or 1 is fine; if you need a bool, call bool on

[issue44400] Propose random.randbool()

2021-06-11 Thread Dong-hee Na
New submission from Dong-hee Na : I noticed that the random library does not provide `random.randbool()`. Generating bool value is quite common in the use-case when we generated faked data (unittest, machine learning training, etc) Somebody can say write your own library but it's too common us