code: def cdx_reverse(cdx_iter, limit):
      
      # optimize for single last
      if limit == 1:
          last = None
  
          for cdx in cdx_iter:
              last = cdx
  
          if not last:
              return
          yield last
  
      reverse_cdxs = deque(maxlen=limit)
  
      for cdx in cdx_iter:
          reverse_cdxs.appendleft(cdx)
  
      for cdx in reverse_cdxs:
          yield cdx
docs: return cdx records in reverse order.