MRAB wrote:
On 16/08/2012 17:13, Ethan Furman wrote:
Currently there are:
.index(data) --> returns index of data in Index, or raises error
.query(string) --> brute force search, returns all matching records
.search(match) --> binary search through table, returns all matching
records
'index' and 'query' are supported by Tables, Lists, and Indexes; search
(and now index_search) are only supported on Indexes.
What exactly is the difference between .index and .index_search with
the default arguments?
.index requires a data structure that can be compared to a record
(another record, a dictionary with the same field/key names, or a
list/tuple with values in the same order as the fields). It returns the
index or raises NotFoundError. It is brute force.
.index_search requires match criteria (a tuple with the desired values
in the same order as the key). It returns the index or raises
NotFoundError (unless nearest is True -- then the value returned is
where the match should be). It is binary search.
So the only similarity is that they both return a number or raise
NotFoundError. What they use for the search and how they perform the
search are both completely different.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list