[Python-ideas] set.add could return True or False

Raymond Hettinger raymond.hettinger at gmail.com
Wed Mar 14 20:48:17 CET 2012

On Mar 14, 2012, at 11:34 AM, Matt Joiner wrote:

> There's still a performance cost in looking up the already present value a second time.

The performance cost is near zero.  The relevant memory accesses with be in cache (which make accessing them almost free).

Besides, the price you pay for storing and testing the boolean value isn't free either.  

Thinking like a C programmer won't help you in the optimization game with sets.
And, it's certainly not worth complexifying the API.


P.S.  There have been previous threads on this same subject and they've all ended with rejecting the proposal.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120314/40c62d45/attachment.html>

More information about the Python-ideas mailing list