Optimize function similiar to dict.update() but adds common values

Gregory Piñero gregpinero at gmail.com
Thu Dec 15 00:14:10 EST 2005


OK, I ran Peter's add_freq3 and it ran four times on really large
dictionaries in about 3000 seconds.  So I'd say that at a minimum
that's ten times faster than my original function since it ran all
last night and didn't finish.

Much obliged, Peter!

-Greg


On 12/14/05, Gregory Piñero <gregpinero at gmail.com> wrote:
> Yes, that makes sense.  I can't wait to run it tonight.  Sorry I can't
> give you the running time of my original function as it never finished
> :-(
>
> I'll report back the running time of the new function though, assuming
> it finishes ;-)
>
> Thanks again,
>
> -Greg
>
>
> On 12/14/05, Peter Otten <__peter__ at web.de> wrote:
> > Gregory Piñero wrote:
> >
> > > Here's a question about your functions.  if I only look at the keys in
> > > freq2 then won't I miss any keys that are in freq1 and not in freq2?
> >
> > No. As I start with a copy of freq1, all keys  of freq1 are already there.
> > There is probably a loop involved, but it in Python's underlying C
> > implementation, which is a bit faster.
> >
> > What is left to do is to (1) add key and value for the 20% of freq2 that are
> > not in freq1, and to (2) increase the value for the 80% where the key
> > occurs in both freq1 and freq2. This is done by the for-loop.
> >
> > Peter
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> Gregory Piñero
> Chief Innovation Officer
> Blended Technologies
> (www.blendedtechnologies.com)
>


--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)



More information about the Python-list mailing list