New submission from Sergey Litvinov:

Bisection algorithms use
mid = (lo+hi)//2

Textbook formula is
mid = (hi-lo)//2 + lo

See
http://en.wikipedia.org/w/index.php?title=Binary_search_algorithm&oldid=634658510#Arithmetic

For "vanilla" lists and integers it is not a problem but one can run
into troubles with user defined types.

----------
components: Library (Lib)
messages: 232286
nosy: Sergey.Litvinov
priority: normal
severity: normal
status: open
title: Unnecessary big intermediate result in Lib/bisect.py
type: behavior
versions: Python 2.7, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23007>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to