[Python-3000] A request to keep dict.setdefault() in 3.0 (original) (raw)
Fred L. Drake, Jr. fdrake at acm.org
Tue Jul 10 05:20:01 CEST 2007
- Previous message: [Python-3000] A request to keep dict.setdefault() in 3.0
- Next message: [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 promise.
IMHO, it's better to have a single shared implementation with this promise; that makes it easier to recognize when reading unfamiliar code.
-Fred
-- Fred L. Drake, Jr.
- Previous message: [Python-3000] A request to keep dict.setdefault() in 3.0
- Next message: [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]