[pypy-issue] [issue1327] "x in deque" slow

kostia.lopuhin tracker at bugs.pypy.org
Mon Nov 19 21:32:25 CET 2012

kostia.lopuhin <kostia.lopuhin at gmail.com> added the comment:

I attached a micro benchmark that indeed shows a 5x slowdown compared to CPython 2.7.

In a branch here https://bitbucket.org/kostialopuhin/pypy/compare/deque-
in..pypy/pypy:default I implemented contains directly on deque, and it performs about 
the same on this benchmark as CPython. For comparason, deque implemented in pure 
python, that also implements __contains__ directly is 5x faster than CPython.

On irc Armin Rigo suggested that s jit driver in space.contains might help to solve 
the problem without hand-written contains, so here I just post numbers for 

$ time pypy deque_in_bench.py 
real	0m6.131s
user	0m6.112s
sys	0m0.017s

$ time python deque_in_bench.py 
real	0m1.467s
user	0m1.372s
sys	0m0.036s

$ time ~/programming/pypy/pypy/translator/goal/pypy-c-deque-in  deque_in_bench.py 

real	0m1.397s
user	0m1.323s
sys	0m0.034s

nosy: +kostia.lopuhin
status: unread -> chatting

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list