def load(filename): with open(filename, "rb") as f: unpickler = pickle._Unpickler(f) while True: try: yield unpickler.load() except EOFError: break