-ν
KX;c       sQ  d  Z  d k Z d k Z d Z d g e Z d e Z d Z d Z d Z	 d f  d	     YZ
 [
 d
 f  d     YZ e   Z d f  d     YZ e d j o΄e d d d d Z d Z xd od Ge Ge i Ge i Ge i Ge i i   GHe d Z e i d d  e i d  e i d  e i d d  e i d  e i d d  e i d d  e i d  e i d  e i d d  e i d d d  e i d  e i d  e i d  e i d d  e i d d  e i d d  e i d d  e i e d  e i e d d  e i e d d  e i e  q· Wn d S(   sΰ    Cache - Generic cache implementation

    Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
Ni   i   i   i   i   i    s   _modinitc      s}   t  Z d  k Z e d d e  Z xW e e  D]I \ Z Z e	 e i
 e  d d  e e <e o e Gd Ge e GHn q. WRS(   Ni    i   f1.0i    s
   . weight =(   s   __name__s
   __module__s   maths   franges   MAXLOCALITYs   ls   iranges   is   factors   ints   exps   _weightss   _debug(    (    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   _modinit s   	 !s	   NotCachedc      s   t  Z d  Z d   Z e Z RS(   sp    A singleton that can be used in conjunction with the .get()
        method of Cache. It behaves like None.
    c    s   d Sd  S(   Ni    (    (   s   self(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   __nonzero__) s    (   s   __name__s
   __module__s   __doc__s   __nonzero__s   __len__(    (    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys	   NotCached$ s    	s   Cachec      s   t  Z d  Z e Z e Z e Z d d d d  Z e e	 d  Z
 d   Z e e d  Z e e d  Z e Z e Z d	   Z e Z RS(
   s$   Tunable cache implementation

        The following parameters influence the cache behaviour:
        - max_cachesize:        the cache will be cut smaller when this limit
                                is reached
        - max_elementsize:      elements with size greate than this limit
                                will not be cached
        - locality:             these many elements will be looked at in
                                the hit statistics to determine how important
                                a specific entry is
    iΘ   i   i2   c    s|   | |  _  | |  _ | t j o t d t  n | |  _ d |  _ d |  _ d |  _ d |  _	 h  |  _
 g  |  _ g  |  _ d  S(   Ns   locality must be <= %ii    (   s   max_cachesizes   selfs   max_elementsizes   localitys   MAXLOCALITYs
   ValueErrors	   cachesizes   cutss   missess   hitss   datas   put_historys   get_history(   s   selfs   max_cachesizes   max_elementsizes   locality(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   __init__D s    									c    s  t  o	 d GHn |  i }
 h  } | i } |  i } xU |  i |  i D]B }	 | |	  o qC n y | |	 | |	 <Wn t
 j
 o n XqC Wt |  }
 t  o d G|
 GHn |
 | |  i | j o*h  } t } | i } xU t |  i |  i  D]< \ } }	 | |	  o qξ n | |	 d  | | | |	 <qξ Wt | i   d  } t  o d G| GHn xE | t |  d  D]/ \ }	 } t  o d G|	 Gd G| GHn | |	 =qlWt |  }
 |
 | |  i | j o$ t  o	 d	 GHn | i   d }
 n n | |  _ |
 |  _ |  i d |  _ d
 S(   sk    Force a cut of the cache's contents.

            This will make room for at least one new entry.
        s     Cutting down cache size...s$      Size after cut to recent history:i    i   s      Ranking:i   s      Deletings   with weight =s&      Did not work, going the hard way...N(   s   _debugs   selfs	   cachesizes   newdatas   has_keys	   known_keys   datas   get_historys   localitys   ids   KeyErrors   lens   NOMs   max_cachesizes   DENOMs   ds   _weightss   weightss   gets   d_gets   iranges   is   sortedbys   itemss   rankings   weights   clears   cuts(   s   selfs   NOMs   DENOMs   weights	   known_keys   ds   rankings   is   d_gets   ids	   cachesizes   weightss   datas   newdata(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   cutW sX     				 		  	
		c    s   d |  _ h  |  _ g  |  _ d S(   s    Clear the cache.
        i    N(   s   selfs	   cachesizes   datas   history(   s   self(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   clear s     		c    s   |  i i | t  } | t j o |  i d |  _ | Sn |  i i	 |  t
 |  i  | j o |  i |  i 3n |  i d |  _ | Sd S(   sW    Get a value from the cache or return default if it is
            not cached.
        i   N(   s   selfs   datas   gets   ids   Nones   items   missess   defaults   get_historys   appends   lens   HISTORYLIMITs   localitys   hits(   s   selfs   ids   defaults   HISTORYLIMITs   item(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   get s     c    sΛ   | |  } | |  i j o d Sn |  i i |  oJ t o d G| GHn |  i	 d |  _	 } | |  i
 j o |  i   n n | |  i | <|  i i |  t |  i  | j o |  i |  i 3n d S(   s=    Add a value to the cache or update an existing one.
        Ns     Addingi   (   s   sizeofs   values   sizes   selfs   max_elementsizes   datas   has_keys   ids   _debugs	   cachesizes   max_cachesizes   cuts   put_historys   appends   lens   HISTORYLIMITs   locality(   s   selfs   ids   values   sizeofs   HISTORYLIMITs	   cachesizes   size(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   put² s     c    s(   y |  i | =Wn t j
 o n Xd S(   sv    Delete an entry from the cache.

            It is not an error, if the entry is not currently in the cache.
        N(   s   selfs   datas   ids   KeyError(   s   selfs   id(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   deleteΞ s
     (   s   __name__s
   __module__s   __doc__s   Nones   datas   put_historys   get_historys   __init__s   NOMs   DENOMs   cuts   clears	   NotCacheds   HISTORYLIMITs   gets   sizeofs   puts   adds   updates   deletes   remove(    (    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   Cache1 s    ?		s   __main__i
   id   s   localityi   s   Roundi   s   xiΘ   (   s   __doc__s   syss   mx.Tools.NewBuiltinss   mxs   MAXLOCALITYs   _weightss   HISTORYLIMITs   DENOMs   NOMs   _debugs   _modinits	   NotCacheds   Caches   __name__s   cs   is	   cachesizes   cutss   missess   datas   keyss   puts   get(   s   NOMs   cs   _debugs   is   _weightss   Caches	   NotCacheds   _modinits   syss   MAXLOCALITYs   HISTORYLIMITs   DENOMs   mx(    (    s7   /mit/seven/lib/python2.2/site-packages/mx/Misc/Cache.pys   ? sR   		
		­ 5