B
    7r\	                 @   sN   d Z e ZeddfddZefddZefddZdd	 ZG d
d deZd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.
Fc                s    fdd}|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).
    c                s    fdd}|S )Nc                s   r| j }nr|d j }n| jj }y| }W n  tk
rP   i }||< Y nX | |t| f}||krt|| S  tk	r ||< | f||}|||< |S d S )N    )Zmemoize_cacheZ	evaluatorKeyError	frozensetitems_NO_DEFAULT)objargskwargscachememokeyrv)defaultevaluator_is_first_argfunctionsecond_arg_is_evaluator 2lib/python3.7/site-packages/jedi/evaluate/cache.pywrapper   s$    z/_memoize_default.<locals>.func.<locals>.wrapperr   )r   r   )r   r   r   )r   r   func   s    z_memoize_default.<locals>.funcr   )r   r   r   r   r   )r   r   r   r   _memoize_default
   s    r   c                s    fdd}|S )Nc                s   t  dd| S )NT)r   r   )r   )r   )r   r   r   	decorator1   s    z+evaluator_function_cache.<locals>.decoratorr   )r   r   r   )r   r   evaluator_function_cache0   s    r   c                s    fdd}|S )Nc                s   t  d| S )N)r   )r   )r   )r   r   r   r   8   s    z)evaluator_method_cache.<locals>.decoratorr   )r   r   r   )r   r   evaluator_method_cache7   s    r   c              C   s   dd } | S )Nc             S   s   t dd| S )NT)r   )r   )Zcallr   r   r   r   ?   s    z2evaluator_as_method_param_cache.<locals>.decoratorr   )r   r   r   r   evaluator_as_method_param_cache>   s    r   c                   s&   e Zd ZdZe  fddZ  ZS )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                s   t t| j||S )N)superr   __call__)selfr   r   )	__class__r   r   r   K   s    zCachedMetaClass.__call__)__name__
__module____qualname____doc__r   r   __classcell__r   r   )r   r   r   E   s   r   N)	r"   objectr   r   r   r   r   typer   r   r   r   r   <module>   s   &