def __copy__(self):
"""
Clone the iterator include states
"""
# https://docs.python.org/2/library/itertools.html#itertools.tee
# tee is not that helpful here, and it will also occupy a lot of memory
# self._file_handler, new_iter = itertools.tee(self._file_handler)
new_iter = FileIterator(self._file_path, self._type, **self._kwargs)
if self._line_count > 0:
for _ in new_iter:
if new_iter._line_count == self._line_count:
break
return new_iter
评论列表
文章目录