From: Pekka L. <re...@bu...> - 2008-12-19 22:18:00
|
New submission from Pekka Laukkanen <pe...@ik...>: On Jython it is much faster to test is an item in a dictionary with 'has_key' method than using 'in' keyword. The latter is normally preferred because it is more idiomatic Python and also faster on CPython. The attached example demonstrates this problem. When I execute it on my system I got following results. $ jython --version && jython in_vs_haskey.py Jython 2.2 on java has_key_test dict 0.7 in_test dict 1.573 has_key_test UserDict 1.224 in_test UserDict 2.313 $ python --version && python in_vs_haskey.py Python 2.5.1 has_key_test dict 0.243 in_test dict 0.146 has_key_test UserDict 0.504 in_test UserDict 0.529 ---------- files: in_vs_haskey.py messages: 3971 nosy: laukpe severity: normal status: open title: 'x' in dictionary much slower than dictionary.has_key('x') Added file: http://bugs.jython.org/file590/in_vs_haskey.py _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue1212> _______________________________________ |