drachenbach drachenbach - 1 year ago 101
Python Question

Does Python cache repeatedly accessed files?

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.

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

Answer Source

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.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download