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
```
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue