python 파일 용량이 큰 파일을 읽을 경우
from functools import partial def chunked_file(fp, block_size=1024 * 1024 * 50): # 50MB return [chunk for chunk in iter(partial(fp.read, block_size), '')] def read_file(file_path): with open(file_path) as f_read: return chunked_file(f_read) # 사용방법 file_path = "/data/large_file.txt" for content in read_file(file_path): someting(content)