Florent Guillaume wrote at 2005-7-8 20:36 +0200:
>The RAMCacheManager does a costly pseudo-pickling of the objects it
>stores to compute their size, but that information is only used in
>the statistics screen.
I replaced it by the following code:
try: from cPickle import Pickler, HIGHEST_PROTOCOL
except: from pickle import Pickler, HIGHEST_PROTOCOL
Represents a cached value.
def __init__(self, index, data, view_name):
# This is a protective barrier that hopefully prevents
# us from caching something that might result in memory
# leaks. It's also convenient for determining the
# approximate memory usage of the cache entry.
# DM 2004-11-29: this code causes excessive time.
# Note also that it does not prevent us from
# caching objects with references to persistent objects
# When we do, nasty persistency errors are likely
# to occur ("shouldn't load data while connection is closed").
#self.size = len(dumps(index)) + len(dumps(data))
sizer = _ByteCounter()
pickler = Pickler(sizer, HIGHEST_PROTOCOL)
self.size = sizer.getCount()
'''auxiliary file like class which just counts the bytes written.'''
_count = 0
def write(self, bytes):
self._count += len(bytes)
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -