[issue6778] False positives given through bisect module (binary search)

kaashif report at bugs.python.org
Mon Aug 24 22:59:18 CEST 2009


New submission from kaashif <musharraf.azeem at gmail.com>:

I tried Python's bisect module on a large word list (words.txt contained
in http://www.greenteapress.com/thinkpython/swampy/swampy.1.1.zip)

If I search for something like 'musefully', 'museful' will come up as a
match. Maybe that's a feature... but seems to me like a bug.

Too much optimization going on here it seems, to such an extent that
false positives are given.

Here's the code I tried:

import bisect

fin = open('words.txt')
t = []

for line in fin:
    t.append(line.strip())

print(bisect.bisect(t,'musefully'))

----------
components: Extension Modules
files: words.txt
messages: 91940
nosy: kaashif
severity: normal
status: open
title: False positives given through bisect module (binary search)
type: behavior
versions: Python 3.1
Added file: http://bugs.python.org/file14780/words.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6778>
_______________________________________


More information about the Python-bugs-list mailing list