1

Python has a default searching function which is:

x in [x,y,z,]

Where x,y,z can be any integers or characters, but this is a default sequential search and I want to know how I can use a manual hashing search in python.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • "[x if x.getHashKeyMethod()==y.getHashKeyMethod() for x in myIterable]" will return all the objects with same hash as y from myIterable, is that it? – Ricola3D Apr 19 '13 at 16:00

1 Answers1

4

Use a set() instead:

x in {x,y,z}

This uses a hash table under the hood, so searches are O(1).

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343