Python 是否缓存重复访问的文件? [英] Does Python cache repeatedly accessed files?

查看:60
本文介绍了Python 是否缓存重复访问的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 Python 是否足够智能来缓存重复访问的文件,例如使用 Pandas 读取同一个 CSV 或多次解压同一个文件时.

I was wondering if Python is smart enough enough to cache repeatedly accessed files, e.g. when reading the same CSV with pandas or unpickling the same file multiple times.

这甚至是 Python 的责任,还是操作系统应该负责?

Is this even Python's responsibility, or should the operating system take care of it?

推荐答案

不,Python 只是一种语言,它本身并没有真正做任何事情.一个特定的 Python 库可能会实现缓存,但用于打开和读取文件的标准函数不会这样做.Pandas 中的高级文件加载函数和 CSV 模块也不做任何缓存.

No, Python is just a language and doesn't really do anything on its own. A particular Python library might implement caching, but the standard functions you use to open and read files don't do so. The higher-level file-loading functions in Pandas and the CSV module don't do any caching either.

操作系统可能会自己做一些缓存,但你不能从 Python 内部控制它.

The operating system might do some caching of its own, but you can't control that from within Python.

这篇关于Python 是否缓存重复访问的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆