[Python-3000] A request to keep dict.setdefault() in 3.0
Fred L. Drake, Jr.
fdrake at acm.org
Tue Jul 10 05:20:01 CEST 2007
On Monday 09 July 2007, Greg Ewing wrote:
> Isn't it rather dangerous to rely on any built-in
> Python operations to be atomic? They might happen
> to be, but I don't think there's any guarantee
> they will stay that way.
My limited recollection is that setdefault() was all about it being atomic;
otherwise there's no benefit to building it in C. The documentation sadly
omits mentioning this very important property of setdefault(), however.
If the atomicity isn't promised, then there's no benefit, and writing a helper
in Python would be fine. However, as we've seen in this discussion, that's
critical to many users of the method. Without it, most users would have to
add a C (or whatever) function that did the same task and made the atomicity
IMHO, it's better to have a single shared implementation with this promise;
that makes it easier to recognize when reading unfamiliar code.
Fred L. Drake, Jr. <fdrake at acm.org>
More information about the Python-3000