[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-28 Thread Willi Richert
Willi Richert added the comment: No particular reason, besides that it is ripped off of pop(). Your solution (omitting "register") gives the same performance. Looks cleaner, of course. The patch tries to provide a clean way of "for x in some_set: break", as explained a

[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-27 Thread Willi Richert
Willi Richert added the comment: added tests for get() to test_set.py -- ___ Python tracker <http://bugs.python.org/issue7212> ___ ___ Python-bugs-list mailin

[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-27 Thread Willi Richert
Changes by Willi Richert : Added file: http://bugs.python.org/file15211/setobject_get.patch ___ Python tracker <http://bugs.python.org/issue7212> ___ ___ Python-bug

[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-27 Thread Willi Richert
Changes by Willi Richert : Removed file: http://bugs.python.org/file15207/setobject_get.patch ___ Python tracker <http://bugs.python.org/issue7212> ___ ___ Python-bug

[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-26 Thread Willi Richert
New submission from Willi Richert : Sometimes, a non-removing pop() is needed. In current Python versions, it can achieved by one of the following ways: 1. x = some_set.pop() some_set.add(x) 2. for x in some_set: break 3. x = iter(some_set).next() More native and clean would