Message3971
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 |
|
Date |
User |
Action |
Args |
2008-12-19 22:17:55 | pekka.klarck | set | recipients:
+ pekka.klarck |
2008-12-19 22:17:54 | pekka.klarck | set | messageid: <1229725074.91.0.411369776101.issue1212@psf.upfronthosting.co.za> |
2008-12-19 22:17:54 | pekka.klarck | link | issue1212 messages |
2008-12-19 22:17:54 | pekka.klarck | create | |
|