Hi, here is the first shot to provide a faster means of retrieving an arbitrary element from a set without removing it. The times for ========================= from timeit import * stat1 = "for i in xrange(100): iter(s).next()" stat2 = "for i in xrange(100): s.get()" for stat in [stat1, stat2]: t = Timer(stat, setup="s=set(range(10000))") # outside the try/except try: print t.timeit(number=1000) except: t.print_exc() ========================= are stat1: 0.0451760292053 stat2: 0.0148510932922 The patch is attached. Feel free to criticize. I would love to see something like that in the standard Python interpreter. Regards, wr -------------- next part -------------- A non-text attachment was scrubbed... Name: setobject_get.patch Type: text/x-patch Size: 2211 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20091023/1e025bce/attachment.bin>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4