gather information from various files efficiently
Keith Dart
kdart at kdart.com
Tue Dec 14 08:25:55 EST 2004
Fredrik Lundh wrote:
> ...
>>if dct.has_key(a):
>> dct[a].append(b)
>>else:
>> dct[a] = [b]
>
>
> the drawback here is that if the number of collisions are high, you end
> up doing lots of extra dictionary lookups. in that case, there are better
> ways to do this.
Sigh, this reminds me of a discussion I had at my work once... It seems
to write optimal Python code one must understand various probabilites of
your data, and code according to the likely scenario. 8-) Now, perhaps
we could write an adaptive data analyzer-code-generator... ;-)
--
\/ \/
(O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <kdart at kdart.com>
public key: ID: F3D288E4
============================================================================
More information about the Python-list
mailing list