TL iZUdZddlZddlmZddlmZmZmZddlm Z ddl m Z ia ee eeeeefffed<dded dfd Zd Zd Zd Zy)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_caches delete_allreturnc4|r>tjD]}|jtjytjD]A}t |j D]#\}\}}|t j ks!||=%Cy)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 P/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/cache.pyclear_time_cachesrs!((* E KKM %%' B#' #3 Zatyy{?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. c0it<fd}|S)Nc|i|}t|} |\}}|tjkDr|S t|}tt }|tj|z|f|<|S#t$rYFwxYwN)nextrKeyErrorgetattrr) argskwargs generatorrexpiryrtime_adddctkey_functime_add_settings rwrapperz4signature_time_cache.._temp..wrapper<s $1&1Iy/C  #C DIIK' L( OEx)9:H99;158CL  s A33 A?>A?)r )r(r*r'r)s` @r_tempz#signature_time_cache.._temp8s), %& r)r)r+s` rsignature_time_cacher-/s( Lrcfd}|S)NcNitfd}fd|_|S)Nc|t|jf} |\}}tj|zkr|S |i|}tj|f|<|S#t$rY.wxYwr) frozensetrrr )r"r#rcreatedresultrfuncsecondss rr*z.time_cache..decorator..wrapperSs6<<>23C "'*99;7!22!M34*6*Ff,E#JM   s#A&& A21A2c$jSr)r)rsrz/time_cache..decorator..`s ekkmr)r clear_cache)r4r*rr5s` @r decoratorztime_cache..decoratorPs- t   4rr,)r5r9s` r time_cacher:Os& rc.tfd}|S)zA normal memoize function.c|jjdi}|ji}|t|jf} ||S#t$r|g|i|}|||<|cYSwxYw)N_memoize_method_dct)__dict__ setdefaultr1rr )selfr"r# cache_dictr'rr3methods rr*zmemoize_method..wrapperhs]]--.CRH ##FB/Yv||~./ s8O D24262FCHM s AA0/A0r)rBr*s` rmemoize_methodrCfs  6]   Nr)F)__doc__r functoolsrtypingrrrjedir parso.cacher r strfloat__annotations__boolrr-r:rCr,rrrMsh  ##$8: d3S%s "33445: $ 4 .@. r