Fast Dictionary Access
Thomas Lehmann
Iris-und-Thomas-Lehmann at T-Online.de
Sat Jun 27 05:47:48 EDT 2009
Hi!
In C++, programming STL you will use the insert method which always
provides a position and a flag which indicates whether the position
results from a new insertion or an exisiting element. Idea is to have
one search only.
<code>
if data.has_key(key):
value = data[key]
</code>
But this does mean (does it?) that the dictionary is searched two
times! If so, can somebody show me how to do this in one step?
More information about the Python-list
mailing list