on writing a while loop for rolling two dice

Chris Angelico rosuav at gmail.com
Sun Aug 29 06:24:23 EDT 2021


On Sun, Aug 29, 2021 at 8:14 PM dn via Python-list
<python-list at python.org> wrote:
> Efficiency:
> - wonder how max( d ) == min( d ) compares for speed with the set() type
> constructor?

That may or may not be an improvement.

> - alternately len( d ) < 2?
> - or len( d ) - 1 coerced to a boolean by the if?

Neither of these will make any notable improvement. The work is done
in constructing the set, and then you're taking the length. How you do
the comparison afterwards is irrelevant.

ChrisA


More information about the Python-list mailing list