title: Comparing two large lists to find element pairs that meet a condition in python
body: <p>I have two large lists of numbers (maybe a million elements each). I would like to compare both of them element-wise to identify element pairs that have a difference of less than 0.5. I know two nested for loops is not an option. Is there any quick way to do this using sets or zip?</p>
  
  <p>For eg. if my lists are <code>list1 = [1,2,3,4]</code> and <code>list2 = [3,4,5,6]</code> and the condition is difference of 1, then the solution would have the pairs arranged in a list [element from <code>list1</code>, element from <code>list2</code>, difference]. The solution would be <code>[[2,3,1],[3,3,0],[3,4,1],[4,3,1],[4,4,0],[4,5,1]]</code></p>
  
  <p>Thanks</p>