uBFj_dZddlmZddlmZeZeZeddfdZefdZ efdZ dZ Gd d e Z d Zd S) 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} |}n#t$r ix|<}YnwxYw||t|f}||vr||St ur||<|g|Ri|}|||<|S)Nr) memoize_cacheinference_stateKeyError frozensetitems _NO_DEFAULT) objargskwargscachememokeyrvdefaultfunctioninference_state_is_first_argsecond_arg_is_inference_states BC:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/inference/cache.pywrapperz/_memoize_default..func..wrappers+ :). :Q-+9 ,X , , ,)++h$$$ ,i 778Cd{{Cy +-- 'DIXc3D333F33S  s2AA)rrrrrs` rfuncz_memoize_default..funcs3        .r)rrrrs``` r_memoize_defaultrs/4 Krcfd}|S)Nc8td|S)NT)rrrrrs r decoratorz1inference_state_function_cache..decorator5s"SdSSSTXYYYrrrr$s` rinference_state_function_cacher&4s)ZZZZZ rcfd}|S)Nc6t|S)N)rr"r#s rr$z/inference_state_method_cache..decorator<s0000666rrr%s` rinference_state_method_cacher);s$77777 rc d}|S)Nc4td|S)NT)rr")calls rr$z8inference_state_as_method_param_cache..decoratorCsCdCCCDIIIrr)r$s r%inference_state_as_method_param_cacher-BsJJJ rcBeZdZdZefdZxZS)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). c6tj|i|S)N)super__call__)selfrr __class__s rr2zCachedMetaClass.__call__Osuww0000r)__name__ __module__ __qualname____doc__r-r2 __classcell__)r4s@rr/r/IsX +*,,1111-,11111rr/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} | }n#t$r ix| <}YnwxYw||t|f}||vr ||\}}n |g|Ri|}g}||f||<d} ||} | t urt jd|zdSnX#t$rK| t t|d} | | YdS| |d<YnwxYw| V|dz })NrTz"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..wrapperZs'5E ,X , , ,)++h$$$ ,i 778Cd{{/3Cy, **#+8C#A$#A#A#A&#A#A  ,j8S A  2#-a=L#'::: &JS&PQQQ;"222%%&9:::#'(8$#?#?L#+"(((%1JrNNN 2#"""Q s%..>(B))A C>6C>=C>r)rrs` rrz4inference_state_method_generator_cache..funcYs4 x      Brr)rs r&inference_state_method_generator_cacherITs ###J KrN)r8 functoolsrjedirobjectrr?rr&r)r-typer/rIrrrrNs fhh fhh)u38####L,7*511111d111*****r