IMAP2IMAP Synchronization -- iis [Was: Re: iis: comparsion of two lists]

Matej Cepl cepl.m at neu.edu
Sun Apr 28 07:52:27 EDT 2002


On Sun, Apr 28, 2002 at 07:22:06AM +0000, Alex Martelli wrote:
> the first assignment is useless.  Not an issue of performance, but of
> Occam's razor: entities must not be multiplied needlessly, and a
> statement that is totally useless is is a good candidate for pruning.

OK, I recant, these needless assignements will go. Thanks.
 
> My favorite would be to forego the hard-to-read lambda for a named
> function (the name injection is inevitable in 1.5.2 or 2.0):
> 
> def not_in_loc_old(m, loc_old=loc_old): return m not in loc_old
> erase = filter(not_in_loc_old, proc_old)

OK, that's much more sane, you are correct.

> It's silly to use two operators in expressions such as
>         not (x in y)
> when a single operator called not in suffices:
>         x not in y

Thanks, I did not know it.

> likely to produce the speed bottleneck unless the lists involved
> are very, VERY small.

Probably up to 100 elements each?

> For membership checking, prepare, not lists, but dictionaries,
> and (in 1.5.2 and up to 2.1) use has_key.

Great idea.

> By modestly increasing elegance, we should also get substantial
> increases in performance unless your sets are all tiny (in which
> case performance doesn't matter all that much).  Try -- performance
> issues are always to be checked by measurement.

Thanks a lot, that's what I was exactly interested in.

Matej

-- 
Matej Cepl, cepl.m at neu.edu
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
 
How many Bavarian Illuminati does it take to screw in
a lightbulb?
Three: one to screw it in, and one to confuse the issue.




More information about the Python-list mailing list