[Python-Dev] best place for an atomic file API

Nick Coghlan ncoghlan at gmail.com
Thu Feb 16 03:45:55 CET 2012


On Thu, Feb 16, 2012 at 11:49 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> No, I have no objection to that implementation. I'm pointing that out
> only because the nature of the functionality implies I'd expect to find
> it within the ‘os’ module hierarchy.

The (very) rough rule of thumb is that the os module handles
abstracting away cross-platform differences in implementation details,
while the higher level shutil algorithms can be largely platform
independent by using the shared abstractions in the os module layer.
In this case, os.replace() is the cross platform abstraction, while
the atomic file context manager is just a particular use case for that
new feature.

(MvL complained in the tracker issue about a lack of concrete use
cases, but I think fixing race conditions when overwriting bytecode
files in importlib and the existing distutils/packaging use cases
cover that)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list