A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-October/093228.html below:

[Python-Dev] First shot at some_set.get()

[Python-Dev] First shot at some_set.get() [Python-Dev] First shot at some_set.get()Willi Richert w.richert at gmx.net
Fri Oct 23 12:23:08 CEST 2009
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>
More information about the Python-Dev mailing list

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