[MERGE] FIFOCache and FIFOSizeCache

John Arbash Meinel john at arbash-meinel.com
Tue Dec 9 23:41:43 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> On Tue, 2008-12-09 at 16:54 -0600, John Arbash Meinel wrote:
>> That would optimize for the case where you are replacing items, rather
>> than optimizing for the case where add is called when the item is not
>> present.
> 
> Well, I wasn't trying to change the optimisation at all.
> 
>> It is hard to say what the most common case is, but I would guess that
>> most caches are only used for things that won't actually mutate, so I
>> would rather optimize for that case.
>>
>> Or are you just trying to change the semantics of "del fifo[foo]" into
>> "fifo.discard(foo)" [which doesn't raise if foo doesn't exist]?
> 
> if moved into __delitem__ I was expecting
> 
> if key not in self:
>     raise KeyError(key)
> ...
> 
>> I'm willing to change it, but I think I have it written the correct
>> way.
> 
> It just seems duplicative.
> 
> -Rob
> 

Writing it this way allows us to not have to raise and then catch
KeyError in the common case that key is not in self. I'm presuming that
it is a more common case than key is in self which wouldn't raise the
exception.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk/AjcACgkQJdeBCYSNAANcRgCfbkx8T7xziFdaKon8LOzTMo/b
eeYAni8JRJV6JfisyqRJMhSYmXZlakjX
=N+9G
-----END PGP SIGNATURE-----



More information about the bazaar mailing list