
    \h                        S r SSKJr  SSKJr   " S S\5      r\" 5       r\R                  r\R                  r	SSK
JrJr  S rS rS	 rSS jr\" SS5      R#                  5       r\" SS5      r\R#                  5       S:X  a  S
rO	 \" \5      r\S:X  a  \rO)\S:X  a	  \" \5      rO\S:X  a	  \" \5      rO\" S\-  5      eS rS\S\S\4S jrg
! \ a    \" SS\-  -   5      ef = f)zCaching facility for SymPy     )import_module)Callablec                   $    \ rS rSrSrS rS rSrg)_cache   zList of cached functions c                     U  Hp  nUR                   nUn[        US5      (       aA  [        US5      (       a  UR                  5       nO!UR                  n[        US5      (       a  MA  Sn[	        X$5        Mr     g)zprint cache info__wrapped__
cache_infoN)__name__hasattrr
   r	   print)selfitemnamemyfuncinfos        H/var/www/auris/envauris/lib/python3.13/site-packages/sympy/core/cache.pyprint_cache_cache.print_cache   sp     D==DF&-006<00!,,.D#//F &-00 $     c                     U  HZ  nUn[        US5      (       d  M  [        US5      (       a  UR                  5         M;  UR                  n[        US5      (       a  MB  M\     g)zclear cache contentr	   cache_clearN)r   r   r	   )r   r   r   s      r   clear_cache_cache.clear_cache   sT    DF&-006=11&&(#//F &-00 r    N)r   
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r   r      s    $"	0r   r   )	lru_cachewrapsc                    ^  U 4S jnU$ )a  caching decorator.

important: the result of cached function must be *immutable*


Examples
========

>>> from sympy import cacheit
>>> @cacheit
... def f(a, b):
...    return a+b

>>> @cacheit
... def f(a, b): # noqa: F811
...    return [a, b] # <-- WRONG, returns mutable object

to force cacheit to check returned results mutability and consistency,
set environment variable SYMPY_USE_CACHE to 'debug'
c                    >^ ^ [        TSS9" T 5      m[        T 5      UU 4S j5       nTR                  Ul        TR                  Ul        [        R                  U5        U$ )NT)typedc                     >  T" U 0 UD6nU$ ! [          aH  nUR                  (       a#  UR                  S   R                  S5      (       d  e T" U 0 UD6n S nAU$ S nAff = f)Nr   zunhashable type:)	TypeErrorargs
startswith)r(   kwargsretvalecfuncfuncs       r   wrapper0__cacheit.<locals>.func_wrapper.<locals>.wrapperE   sg    ///
 M	  /vvQVVAY%9%9:L%M%Mt.v.M	/s    
A=AA)r!   r"   r
   r   CACHEappendr.   r/   r-   maxsizes   ` @r   func_wrapper__cacheit.<locals>.func_wrapperB   sY    '.t4	t	 
	 #--#//Wr   r   r4   r5   s   ` r   	__cacheitr8   -   s    *& r   c                     U $ Nr   )r.   s    r   __cacheit_nocacher;   Y   s    Kr   c                    ^  U 4S jnU$ )z)cacheit + code to check cache consistencyc                 X   >^ ^ [        T5      " T 5      m[        T 5      UU 4S j5       nU$ )Nc                  t   > T" U 0 UD6nT" U 0 UD6n[        U5      [        U5      4  X#:w  a  [        S5      eU$ )Nz Returned values are not the same)hashRuntimeError)r(   kw_argsr1r2r-   r.   s       r   r/   6__cacheit_debug.<locals>.func_wrapper.<locals>.wrapperb   sM     t'w'B((B Hd2h x"#EFFIr   )r8   r"   r3   s   ` @r   r5   %__cacheit_debug.<locals>.func_wrapper_   s/    '"4(	t	 
	( r   r   r7   s   ` r   __cacheit_debugrF   ]   s    2 r   Nc                     SSK Jn  U" X5      $ )Nr   )getenv)osrH   )keydefaultrH   s      r   _getenvrL   {   s    #r   SYMPY_USE_CACHEyesSYMPY_CACHE_SIZE1000nonez2SYMPY_CACHE_SIZE must be a valid integer or None. zGot: %snodebugz*unrecognized value for SYMPY_USE_CACHE: %sc                 `   ^ ^^ ST R                   -   m[        5       mUUU 4S jn[        U5      $ )z"Decorator to cache property method__c                 V   > [        U TT5      nUTL a  T" U 5      n[        U TU5        U$ r:   )getattrsetattr)r   val_cached_property_sentinelattrnamer.   s     r   propfunc!cached_property.<locals>.propfunc   s5    dH&?@++t*CD(C(
r   )r   objectproperty)r.   r\   rZ   r[   s   ` @@r   cached_propertyr`      s+    dmm#H & Hr   moduler   returnc                 r   ^ ^^^ SmUU U4S jm " UU U4S jS[         5      n " UUU U4S jSUS9nU" 5       $ )zCreate a lazy proxy for a function in a module.

The module containing the function is not imported until the function is used.

Nc                  8   > T c  [        [        T5      T5      m T $ r:   rW   r   )r.   ra   r   s   r   _get_function$lazy_function.<locals>._get_function   s    <=0$7Dr   c                   0   > \ rS rSr\U UU4S j5       rSrg)'lazy_function.<locals>.LazyFunctionMeta   c                 p   > T" 5       R                   nUSU R                  R                   ST ST S3-  nU$ Nz

Note: this is a z wrapper of '.'r   	__class__r   r   	docstringrf   ra   r   s     r   r   /lazy_function.<locals>.LazyFunctionMeta.__doc__   G    %//I/0G0G/HV\U]]^_c^ddeffIr   r   N)r   r   r   r   r_   r   r    )rf   ra   r   s   r   LazyFunctionMetari      s    		 
	r   ru   c                   d   >^  \ rS rSrUUU4S jr\UUU4S j5       rU4S jrU UU4S jrSr	U =r
$ )#lazy_function.<locals>.LazyFunction   c                 D   > Tc  [        [        T5      T5      mT" U0 UD6$ r:   re   )r   r(   r*   r.   ra   r   s      r   __call__,lazy_function.<locals>.LazyFunction.__call__   s+     |}V4d;(((r   c                 p   > T" 5       R                   nUSU R                  R                   ST ST S3-  nU$ rl   ro   rq   s     r   r   +lazy_function.<locals>.LazyFunction.__doc__   rt   r   c                 .   > T" 5       R                  5       $ r:   )__str__)r   rf   s    r   r   +lazy_function.<locals>.LazyFunction.__str__   s     ?**,,r   c           	      J   > STR                    S[        U 5      S ST ST S3	$ )N<z object at 0xxz>: wrapping 'rm   rn   )r   id)r   rp   ra   r   s    r   __repr__,lazy_function.<locals>.LazyFunction.__repr__   s7    y))*-4|=QWPXXYZ^Y__`aar   r   )r   r   r   r   rz   r_   r   r   r   r    __classcell__)rp   rf   r.   ra   r   s   @r   LazyFunctionrw      s-    	) 
	 
	
	-	b 	br   r   )	metaclass)type)ra   r   ru   r   rf   r.   s   ``  @@r   lazy_functionr      s?     D 4 b b!1 b( >r   r:   )r   	importlibr   typingr   listr   r1   r   r   	functoolsr!   r"   r8   r;   rF   rL   lower	USE_CACHEscsrO   int
ValueErrorr@   cacheitr`   strr   r   r   r   <module>r      s6   " # 0T 0B 	 &(X< 
 %u-335	
  &)99;&*s8 G%()G'./G
4y@B B
*3 *s *x *;  *@(()* 	**s   C C%