[Python-ideas] set.add() return value

Bruce Leban bruce at leapyear.org
Wed Feb 18 00:17:12 CET 2009


On Tue, Feb 17, 2009 at 3:01 PM, Steven D'Aprano <steve at pearwood.info>wrote:

>
> I think that test_and_add is naturally two operations, not one, and forcing
> it to be one operation will just lead to confusion.


There is one scenario where testing membership and adding a new member *is*
a single operation: multiple threads.

That's a good reason to *not* support a test/change operation in regular
sets as it may lead people to think (falsely) that it provide some kind of
concurrency protection.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090217/246fba8e/attachment.html>


More information about the Python-ideas mailing list