[MERGE] LRUCache changes

John Arbash Meinel john at arbash-meinel.com
Tue Dec 9 22:36:54 GMT 2008


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

Vincent Ladeuil wrote:
>>>>>> "jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
> 
> <snip/>
>     jam> +    def __init__(self, max_cache=100, after_cleanup_count=None,
>     jam> +                 after_cleanup_size=symbol_versioning.DEPRECATED_PARAMETER):
>     jam> +        if symbol_versioning.deprecated_passed(after_cleanup_size):
>     jam> +            symbol_versioning.warn('LRUCache.__init__(after_cleanup_size) was'
>     jam> +                                   ' deprecated in 1.11. Use'
>     jam> +                                   ' after_cleanup_count instead.',
>     jam> +                                   DeprecationWarning)
> 
> 
> I know we don't have a deprecated_parameter() handy, but may be
> you can still use deprecated_in() and more importantly (1, 11) ?
> Or just define one_eleven and use it ?
> 
> That will make future cleanups easier.
> 
> Are you sure you want to use symbol_versioning.warn (which relies
> on 'from warnings import warn' in symbol_versioning) ?
> 
> BB: approve
> 
>     Vincent
> 

Attached is a small update. While working on the FIFOCache code, I
realized that we were going to be wasting memory filling the cleanup
dictionary with None.

This is a simple patch to make the overhead of supporting cleanup
functions minimal if you aren't actually using it. Earlier tests showed
that a dict itself has an overhead of 8x or 16x the number of keys for
its hash table. (4 bytes per pointer, and a preferred density of 1/2 or
1/4th depending on how many keys are stored.)

I don't think this will make a world of difference, but it is a pretty
trivial fix.

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

iEYEARECAAYFAkk+8wYACgkQJdeBCYSNAAN70ACfSOsQhArpMjfOxBm8s2Nwxrq7
9dcAn1hfoqXzWXrPPqN458CEaPpi5wGx
=3vvC
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lru_cache2.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20081209/9b83cd0a/attachment.diff 


More information about the bazaar mailing list