TL i_dZddlmZddlmZeZeZeddfdZefdZ efdZ dZ Gd d e Z d Zy ) z - the popular ``_memoize_default`` works like a typical memoize and returns the default otherwise. - ``CachedMetaClass`` uses ``_memoize_default`` to do the same with classes. wraps)debugFcfd}|S)aO This is a typical memoization decorator, BUT there is one difference: To prevent recursion it sets defaults. Preventing recursion is in this case the much bigger use than speed. I don't think, that there is a big speed difference, but there are many cases where recursion could happen (think about a = b; b = a). cfd}|S)Nc4 r |j}n( r|dj}n|jj} |}||t|j f}||vr||St ur||<|g|i|}|||<|S#t$r ix|<}YWwxYw)Nr) memoize_cacheinference_stateKeyError frozensetitems _NO_DEFAULT) objargskwargscachememokeyrvdefaultfunctioninference_state_is_first_argsecond_arg_is_inference_states Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/cache.pywrapperz/_memoize_default..func..wrappers+)).Q--++99 ,Xi 78Cd{Cy +- 'DIc3D3F3S   ,)++h$ ,sBBB)rrrrrs` rfuncz_memoize_default..funcs .r)rrrrs``` r_memoize_defaultrs4 Krcfd}|S)Nc*td|S)NT)rrrrrs r decoratorz1inference_state_function_cache..decorator5sSdSTXYYrrrr$s` rinference_state_function_cacher&4sZ rcfd}|S)Nc(t|S)N)rr"r#s rr$z/inference_state_method_cache..decorator<s0066rrr%s` rinference_state_method_cacher);s7 rc d}|S)Nc&td|S)NT)rr")calls rr$z8inference_state_as_method_param_cache..decoratorCsCdCDIIrr)r$s r%inference_state_as_method_param_cacher-BsJ rc6eZdZdZefdZxZS)CachedMetaClassz This is basically almost the same than the decorator above, it just caches class initializations. Either you do it this way or with decorators, but with decorators you lose class access (isinstance, etc). c"t||i|S)N)super__call__)selfrr __class__s rr2zCachedMetaClass.__call__Osw000r)__name__ __module__ __qualname____doc__r-r2 __classcell__)r4s@rr/r/Is +,1-1rr/c d}|S)z This is a special memoizer. It memoizes generators and also checks for recursion errors and returns no further iterator elemends in that case. c.tfd}|S)Nc?K|jj} | }||t|j f}||vr ||\}}n |g|i|}g}||f||<d} ||} | t urt jd|zy | |dz }2#t$r ix| <}YwxYw#t$r=|jt t|d} | |jYy| |d<YewxYww)Nrz"Found a generator recursion for %s) r r r r r _RECURSION_SENTINELrwarning IndexErrorappendnextpop) rrrrrractual_generator cached_lsti next_elementrs rrzEinference_state_method_generator_cache..func..wrapperZs2''55E ,Xi 78Cd{/3Cy, *#+C#A$#A&#A  ,j8S A 2#-a=L#':: &JS&PQ;#"Q ,)++h$ ,("2%%&9:#'(8$#?L#+"(%1JrN 2sXC2BAC2"%B) C2B&#C2%B&&C2).funcYs! x   Brr)rs r&inference_state_method_generator_cacherITs #J KrN)r8 functoolsrjedirobjectrr?rr&r)r-typer/rIrrrrNs[ h h)u38#L,7*51d1*r