File: //opt/alt/python37/lib/python3.7/site-packages/cachetools/__pycache__/keys.cpython-37.pyc
B
��f� � @ sB d Z dZG dd� de�ZefZdd� Zdd� Zdd � Zd
d� ZdS )
z'Key functions for memoizing decorators.)�hashkey� methodkey�typedkey�typedmethodkeyc @ sF e Zd ZdZdZejfdd�Zejfdd�Zejfdd�Zd d
� Z dS )�_HashedTuplez�A tuple that ensures that hash() will be called no more than once
per element, since cache decorators will hash the key multiple
times on a cache miss. See also _HashedSeq in the standard
library functools implementation.
Nc C s | j }|d kr|| � | _ }|S )N)�_HashedTuple__hashvalue)�self�hash� hashvalue� r
�@/opt/alt/python37/lib/python3.7/site-packages/cachetools/keys.py�__hash__ s z_HashedTuple.__hash__c C s t || |��S )N)r )r �other�addr
r
r �__add__ s z_HashedTuple.__add__c C s t ||| ��S )N)r )r r
r r
r
r �__radd__ s z_HashedTuple.__radd__c C s i S )Nr
)r r
r
r �__getstate__ s z_HashedTuple.__getstate__)
�__name__�
__module__�__qualname__�__doc__r �tupler r r r r
r
r
r r s r c O s* |rt | tt|�� �t� �S t | �S dS )z8Return a cache key for the specified hashable arguments.N)r �sum�sorted�items�_kwmark)�args�kwargsr
r
r r % s r c O s
t ||�S )z/Return a cache key for use with cached methods.)r )r r r r
r
r r . s r c O sB t | |�}|tdd� | D ��7 }|tdd� t|�� �D ��7 }|S )z>Return a typed cache key for the specified hashable arguments.c s s | ]}t |�V qd S )N)�type)�.0�vr
r
r � <genexpr>7 s ztypedkey.<locals>.<genexpr>c s s | ]\}}t |�V qd S )N)r )r �_r r
r
r r 8 s )r r r r )r r �keyr
r
r r 3 s
r c O s
t ||�S )z5Return a typed cache key for use with cached methods.)r )r r r r
r
r r <