[Python-Dev] First shot at some_set.get() (original) (raw)
Willi Richert w.richert at gmx.net
Fri Oct 23 12:23:08 CEST 2009
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Next message: [Python-Dev] First shot at some_set.get()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Previous message: [Python-Dev] Retrieve an arbitrary element from a set without removing it
- Next message: [Python-Dev] First shot at some_set.get()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]