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.

classification
Title: cpython Lib bisect.py overflow (lo + hi) // 2 a problem?
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: David.Duffy, Dennis Sweeney
Priority: normal Keywords:

Created on 2021-07-28 01:05 by David.Duffy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg398337 - (view) Author: David Duffy (David.Duffy) Date: 2021-07-28 01:05
https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html

led me to change to lo+(lo+hi)/2 - would this affect bisect.py???
msg398338 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-07-28 01:21
This is a good idea for languages where integers are bounded, but in Python, integers can be as large as you want, so there's no reason to worry about overflow:

>>> lo = 1 * 10**100
>>> hi = 2 * 10**100
>>> (lo + hi) // 2
15000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
msg398339 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-07-28 01:25
Thanks for the concern, but I'll close this as "not a bug". Feel free to re-open if you can give an example where the current code fails.
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88918
2021-07-28 01:25:19Dennis Sweeneysetstatus: open -> closed
resolution: not a bug
messages: + msg398339

stage: resolved
2021-07-28 01:21:40Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg398338
2021-07-28 01:05:16David.Duffycreate