First shot at some_set.get()
23 Oct
2009
23 Oct
'09
6:23 a.m.
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
5269
Age (days ago)
5270
Last active (days ago)
10 comments
9 participants
participants (9)
-
"Martin v. Löwis"
-
geremy condra
-
Guido van Rossum
-
Nick Coghlan
-
Oleg Broytman
-
Stephen J. Turnbull
-
Steven D'Aprano
-
Willi Richert
-
Yuvgoog Greenle