0

I have a list of tuples (example below) and need to find the index of an item. At present I am using list.index() but given the size of dataset and frequency of use its proving slow. Is there a more efficient solution?

Dataset example: The data I am using is a tuple of locations

[(21, 31, 30), (20, 30, 29), (20, 30, 31), (20, 30, 30)......]

Thank you

Lloyd Rayner
  • 1,009
  • 2
  • 7
  • 10
  • Your usage of `index` suggests that the tuples are unique. Why not use a dict then? In other words, *why* do you need the index? what significance does it have? – DeepSpace Dec 17 '19 at 11:54
  • 1
    this answer works for you : https://stackoverflow.com/a/53303488/6451573 (tuples are hashable so they can be keys) – Jean-François Fabre Dec 17 '19 at 11:54

0 Answers0