Bug report
Bug description:
(
)
This line is ran even when the error case happens, which is unnecessary work. There is no disadvantage to moving the check upwards as the check is ran every time.
The check:
try: c = 0.5 if mode is None else (mode - low) / (high - low) except ZeroDivisionError: return low
CPython versions tested on:
3.13
Operating systems tested on:
No response
Bug report
Bug description:
(
cpython/Lib/random.py
Line 525 in ac8ba0c
This line is ran even when the error case happens, which is unnecessary work. There is no disadvantage to moving the check upwards as the check is ran every time.
The check:
try: c = 0.5 if mode is None else (mode - low) / (high - low) except ZeroDivisionError: return lowCPython versions tested on:
3.13
Operating systems tested on:
No response