[pypy-issue] Issue #2671: Set lookup is slow(ish) (pypy/pypy)

Oscar Smith issues-reply at bitbucket.org
Sun Oct 1 20:30:30 EDT 2017


New issue 2671: Set lookup is slow(ish)
https://bitbucket.org/pypy/pypy/issues/2671/set-lookup-is-slow-ish

Oscar Smith:

For not tiny strings, lookup by string or list is much faster than for set. All are faster than CPython, but it is a performance gotcha, so if it were easy to fix, that would be great. Below is reproduction code

```
#!python
t1=time()
x="abcdef"
for i in range(100000):
    for char in "abcdefghijklmnopqrstuvwxyz":
        if char not in x:
            pass
t2=time()
x={'a','b','c','d','e','f'}
for i in range(100000):
    for char in "abcdefghijklmnopqrstuvwxyz":
        if char not in x:
           pass
t3=time()

print('String Time', t2-t1)
print('Set Time', t3-t2)
```
```
String Time 0.12956809997558594
Set Time  0.6732444763183594

```




More information about the pypy-issue mailing list