Rev 4184: Use slots for LRUCache and LRUSizeCache. in lp:///~jameinel/bzr/lru_cache_linked_lst
John Arbash Meinel
john at arbash-meinel.com
Mon Mar 23 01:39:05 GMT 2009
At lp:///~jameinel/bzr/lru_cache_linked_lst
------------------------------------------------------------
revno: 4184
revision-id: john at arbash-meinel.com-20090323013900-sap3qf9wr54yh9r8
parent: john at arbash-meinel.com-20090322193045-te9xf2ufvsnq09fl
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: lru_cache_linked_lst
timestamp: Sun 2009-03-22 20:39:00 -0500
message:
Use slots for LRUCache and LRUSizeCache.
-------------- next part --------------
=== modified file 'bzrlib/lru_cache.py'
--- a/bzrlib/lru_cache.py 2009-03-22 19:30:45 +0000
+++ b/bzrlib/lru_cache.py 2009-03-23 01:39:00 +0000
@@ -24,7 +24,7 @@
class _LRUNode(object):
"""This maintains the linked-list which is the lru internals."""
- __slots__ = ('prev', 'next', 'key', 'value', 'cleanup', 'size')
+ __slots__ = ('prev', 'next', 'value', 'key', 'cleanup', 'size')
def __init__(self, key, value, cleanup=None):
self.prev = None
@@ -60,6 +60,9 @@
class LRUCache(object):
"""A class which manages a cache of entries, removing unused ones."""
+ __slots__ = ('_cache', '_most_recently_used', '_last_recently_used',
+ '_max_cache', '_after_cleanup_count')
+
def __init__(self, max_cache=100, after_cleanup_count=None,
after_cleanup_size=symbol_versioning.DEPRECATED_PARAMETER):
if symbol_versioning.deprecated_passed(after_cleanup_size):
@@ -279,6 +282,9 @@
The values that are added must support len(value).
"""
+ __slots__ = ('_value_size', '_compute_size', '_max_size',
+ '_after_cleanup_size')
+
def __init__(self, max_size=1024*1024, after_cleanup_size=None,
compute_size=None):
"""Create a new LRUSizeCache.
More information about the bazaar-commits
mailing list