这是一个非常接近我实际用例的示例:
import skvideo.io
from smart_open import smart_open
with smart_open("s3://{}/{}".format("my_bucket", resource_key)) as f:
magic = NamedInMemoryTempFile(f, "video.vp8") # is there sth like that?
print(magic) # probably sth. like "/python/fakepath/video.vp8"
frames = skvideo.io.vread(magic) # some lib that expects a filename :/ ...
do_something_with(frames)
因此,我正在寻找一种将内容保留在内存中并避免由于性能原因而写入磁盘的方法。