uBFjUdZddlZddlmZddlmZmZmZddlm Z ddl m Z ia ee eeeeefffed<dd ed dfd Zd Zd ZdZdS)a7 This caching is very important for speed and memory optimizations. There's nothing really spectacular, just some decorators. The following cache types are available: - ``time_cache`` can be used to cache something for just a limited time span, which can be useful if there's user interaction and the user cannot react faster than a certain time. This module is one of the reasons why |jedi| is not thread-safe. As you can see there are global variables, which are holding the cache information. Some of these variables are being cleaned after every API usage. Nwraps)AnyDictTuple)settings) parser_cache _time_cachesF delete_allreturncT|rEtD]}|tjdStD]F}t |D]"\}\}}|t jkr||=#GdS)z Jedi caches many things, that should be completed after each completion finishes. :param delete_all: Deletes also the cache that is normally not deleted, like parser cache, which is important for faster parsing. N)r valuesclearr listitemstime)r cachetckeytvalues 8C:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/cache.pyclear_time_cachesrs  !((**  E KKMMMM%%''  B#' #3#3  Zaty{{??3   cfd}|S)a\ This decorator works as follows: Call it with a setting and after that use the function with a callable that returns the key. But: This function is only called if the key is not available. After a certain amount of time (`time_add_setting`) the cache is invalid. If the given key is None, the function will not be cached. c2it<fd}|S)Nc$|i|}t|} |\}}|tjkr|Sn#t$rYnwxYwt|}tt }|tj|z|f|<|SN)nextrKeyErrorgetattrr) argskwargs generatorrexpiryrtime_adddctkey_functime_add_settings rwrapperz4signature_time_cache.._temp..wrapper<s $1&11Iy//C  #C DIKK'' L(    OOEx)9::H9;;158CLs#? A  A )r )r(r*r'r)s` @r_tempz#signature_time_cache.._temp8s?), %&       r)r)r+s` rsignature_time_cacher-/s#( Lrcfd}|S)Nc\itfd}fd|_|S)Nc|t|f} |\}}tj|zkr|Sn#t$rYnwxYw|i|}tj|f|<|Sr) frozensetrrr )r"r#rcreatedresultrfuncsecondss rr*z.time_cache..decorator..wrapperSs6<<>>223C "'*9;;7!222!M3    T4*6**Ff,E#JMs&A AAc,Sr)r)rsrz/time_cache..decorator..`sekkmmr)r clear_cache)r4r*rr5s` @r decoratorztime_cache..decoratorPsU t        4333rr,)r5r9s` r time_cacher:Os$& rc<tfd}|S)zA normal memoize function.c|jdi}|i}|t|f} ||S#t$r|g|Ri|}|||<|cYSwxYw)N_memoize_method_dct)__dict__ setdefaultr1rr )selfr"r# cache_dictr'rr3methods rr*zmemoize_method..wrapperhs]--.CRHH ##FB//Yv||~~../ s8O   VD24222622FCHMMM sAA?>A?r)rBr*s` rmemoize_methodrCfs3 6]]    ]  Nr)F)__doc__r functoolsrtypingrrrjedir parso.cacher r strfloat__annotations__boolrr-r:rCr,rrrMs    ##########$$$$$$8: d3S%s "33445:::  $ 4    .@.     r