input: def optimize_linear_search(arr: List[Any], x: Any) -> int:
      """ Optimize the linear search function using best practices.
      >>> optimize_linear_search([1, 2, 3, 4], 3)
      2
      >>> optimize_linear_search([1, 2, 3, 4], 5)
      -1
      """
output:     for i in range(len(arr)):
          if arr[i] == x:
              return i
      return -1