-í
›KX;c       sÒ    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 1 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  xc e e ƒ D ]R \ 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­   1 t  Z d  Z = > e Z ? e Z A e Z D d d d d „ Z W 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£   D H | |  _  I | |  _ J | t j o K t d t ‚ n L | |  _ N d |  _ O d |  _ P d |  _ Q d |  _	 S h  |  _
 T g  |  _ U 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˜  W ^ _ t  o ` d GHn a |  i }
 d h  } e | i } f |  i } g xj |  i |  i Dg ]T }	 h | |	 ƒ o
 i q^ n j y k | |	 | |	 <Wn l t
 j
 o
 m n Xq^ Wo t | ƒ }
 p t  o q d G|
 GHn t |
 | |  i | j olw h  } x t } y | i } z xa t |  i |  i ƒ Dz ]E \ } }	 { | |	 ƒ o
 | q6n } | |	 d ƒ | | | |	 <q6W€ t | i ƒ  d ƒ }  t  o ‚ d G| GHn ƒ xQ | t | ƒ d  Dƒ ]8 \ }	 } „ t  o … d G|	 Gd G| GHn † | |	 =qÌW‰ t | ƒ }
 ‹ |
 | |  i | j o0  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 | ƒ oY ¾ 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   					­	 
8