osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


Am 16.02.2012 10:54, schrieb Victor Stinner:
> Most users don't need a truly ACID write, but implement their own
> best-effort function. Instead of having a different implement in each
> project, Python can provide something better, especially when the OS
> provides low level function to implement such feature.

It's then critical how this is named, IMO (and exactly what semantics
it comprises). Calling it "atomic" when it is not is a mistake.

Also notice that one user commented that that he already implemented
something like this, and left out the issue of *permissions*. I found
that interesting, since preserving permissions might indeed a
requirement in a lot of "in-place update" use cases, but hasn't been
considered in this discussion yet.

So rather than providing a mechanism for atomic writes, I think
providing a mechanism to update a file is what people might need.

One way of providing this might be a "u" mode for open, which
updates an existing file on close (unlike "a", which appends,
and unlike "w", which truncates first).

Regards,
Martin