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

Guido van Rossum guido at python.org
Wed Feb 18 04:12:05 CET 2009

On Tue, Feb 17, 2009 at 6:58 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Bruce Leban wrote:
>> 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.
> Well, perhaps it should provide concurrency protection.
> If it's implemented in C with the GIL held, it probably
> wouldn't be hard to make that guarantee.

That may depend on whether the hash or equality test is implemented in Python.

Also, I've heard of lock-free thread-safe dict implementations in Java
where it may not be so easy to decide whether you actually inserted
something or not -- and it may or may not be there when you look for
it again.

All in all, I am now siding with Raymond -- let's leave well enough
alone. Hopefully we can now retire this thread, I don't think there's
much more that can be said that hasn't been said already.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-ideas mailing list