On Jul 4, 2005, at 1:29 AM, Mario Ruggier wrote: > Hi, > > would there be a better way to check if a btree contains a given > key, that would be better than doing: > > key in btree.keys() > > What seems costly is the underlying btree.iterkeys() that loops > over the items... and maybe this is what would need to be modified. > > Is this operation an inevitably expensive one? > Use "key in btree" instead of "key in btree.keys()" The BTree.__contains__() method does a fast search, without the full iteration of keys.