cache length in iterating list