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 <[EMAIL PROTECTED]>
public key: ID: F3D288E4
============================================================================
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to