Format: application/x-python-code
⬇ Download File (4.2 KB)
   1  o
   2  
   3  �h_�@stdZddlmZddlmZe�Ze�Zeddfdd�Zefdd�Z	efd	d
   4  �Z
   5  dd�ZGd
   6  d�de�Z
   7  dd�ZdS)z�
   8  - the popular ``_memoize_default`` works like a typical memoize and returns the
   9    default otherwise.
  10  - ``CachedMetaClass`` uses ``_memoize_default`` to do the same with classes.
  11  ���wraps)�debugFcs���fdd�}|S)aO This is a typical memoization decorator, BUT there is one difference:
  12      To prevent recursion it sets defaults.
  13  
  14      Preventing recursion is in this case the much bigger use than speed. I
  15      don't think, that there is a big speed difference, but there are many cases
  16      where recursion could happen (think about a = b; b = a).
  17      cs����fdd�}|S)Ncs��r|j}n�r|dj}n|jj}z|�}Wnty'i|�<}Ynw||t|���f}||vr9||S�turA�||<�|g|�Ri|��}|||<|S)Nr)�
  18  memoize_cache�inference_state�KeyError�	frozenset�items�_NO_DEFAULT)�obj�args�kwargs�cache�memo�key�rv)�default�function�inference_state_is_first_arg�second_arg_is_inference_state��Jc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/cache.py�wrappers$�z/_memoize_default.<locals>.func.<locals>.wrapperr�rr�rrr�rr�funcsz_memoize_default.<locals>.funcr)rrrrrrr�_memoize_defaults	rc��fdd�}|S)Ncst�dd�|�S)NT)rr�r�r�rrr�	decorator5sz1inference_state_function_cache.<locals>.decoratorr�rr"rr!r�inference_state_function_cache4�r$cr)Ncst�d�|�S)Nr!rr r!rrr"<�z/inference_state_method_cache.<locals>.decoratorrr#rr!r�inference_state_method_cache;r%r'cC�dd�}|S)NcSstdd�|�S)NT)rr)�callrrrr"Cr&z8inference_state_as_method_param_cache.<locals>.decoratorr)r"rrr�%inference_state_as_method_param_cacheBsr*cs&eZdZdZe��fdd��Z�ZS)�CachedMetaClassz�
  19      This is basically almost the same than the decorator above, it just caches
  20      class initializations. Either you do it this way or with decorators, but
  21      with decorators you lose class access (isinstance, etc).
  22      cst�j|i|��S)N)�super�__call__)�selfrr
  23  ��	__class__rrr-OszCachedMetaClass.__call__)�__name__�
  24  __module__�__qualname__�__doc__r*r-�
  25  __classcell__rrr/rr+Isr+cCr()z�
  26      This is a special memoizer. It memoizes generators and also checks for
  27      recursion errors and returns no further iterator elemends in that case.
  28      cst���fdd��}|S)Nc
  29  ?s�|jj}z|�}Wntyi|�<}Ynw||t|���f}||vr/||\}}n�|g|�Ri|��}g}||f||<d}	z||}	|	turXt�d|�WdSWn"ty{|�	t�t
  30  |d�}	|	duru|��YdS|	|d<Ynw|	V|d7}qE)NrTz"Found a generator recursion for %s������)rrrrr	�_RECURSION_SENTINELr�warning�
  31  IndexError�append�next�pop)
  32  rrr
  33  rrrZactual_generatorZ
  34  cached_lst�iZnext_elementrrrrZs@���
  35  
  36  ��zEinference_state_method_generator_cache.<locals>.func.<locals>.wrapperrrrrrrYs!z4inference_state_method_generator_cache.<locals>.funcrr rrr�&inference_state_method_generator_cacheTs%r?N)r4�	functoolsrZjedir�objectr
  37  r8rr$r'r*�typer+r?rrrr�<module>s
  38  �&