Your IP : 3.145.92.33


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/__pycache__/_helpers.cpython-37.pyc

B

��@[�	�@s`ddlmZddlZddlmZmZddlmZmZddl	m
Z
mZdd�Zdd	�Z
d
d�ZdS)�)�wrapsN)�PMap�pmap)�PSet�pset)�PVector�pvectorcCslt|�}|tkr,ttdd�t�|�D���S|tkrBttt|��S|t	krXt	tt|��S|t
krht|�S|S)a
    Recursively convert simple Python containers into pyrsistent versions
    of those containers.

    - list is converted to pvector, recursively
    - dict is converted to pmap, recursively on values (but not keys)
    - set is converted to pset, but not recursively
    - tuple is converted to tuple, recursively.

    Sets and dict keys are not recursively frozen because they do not contain
    mutable data by convention. The main exception to this rule is that
    dict keys and set elements are often instances of mutable objects that
    support hash-by-id, which this function can't convert anyway.

    >>> freeze(set([1, 2]))
    pset([1, 2])
    >>> freeze([1, {'a': 3}])
    pvector([1, pmap({'a': 3})])
    >>> freeze((1, []))
    (1, pvector([]))
    css|]\}}|t|�fVqdS)N)�freeze)�.0�k�v�r
�F/opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/_helpers.py�	<genexpr> szfreeze.<locals>.<genexpr>)�type�dictr�six�	iteritems�listr�mapr	�tuple�setr)�o�typr
r
rr	sr	cCsht|t�rttt|��St|t�r8tdd�|��D��St|t�rJt	|�St
|�tkrdttt|��S|S)a�
    Recursively convert pyrsistent containers into simple Python containers.

    - pvector is converted to list, recursively
    - pmap is converted to dict, recursively on values (but not keys)
    - pset is converted to set, but not recursively
    - tuple is converted to tuple, recursively.

    >>> from pyrsistent import s, m, v
    >>> thaw(s(1, 2))
    set([1, 2])
    >>> thaw(v(1, m(a=3)))
    [1, {'a': 3}]
    >>> thaw((1, v()))
    (1, [])
    css|]\}}|t|�fVqdS)N)�thaw)r
rrr
r
rr>szthaw.<locals>.<genexpr>)�
isinstancerrrrrrrrrrr)rr
r
rr*s


rcst���fdd��}|S)a
    Convenience decorator to isolate mutation to within the decorated function (with respect
    to the input arguments).

    All arguments to the decorated function will be frozen so that they are guaranteed not to change.
    The return value is also frozen.
    cs*t�dd�|D�tdd�|��D����S)NcSsg|]}t|��qSr
)r	)r
�er
r
r�
<listcomp>Psz+mutant.<locals>.inner_f.<locals>.<listcomp>css|]}t|�VqdS)N)r	)r
�itemr
r
rrPsz*mutant.<locals>.inner_f.<locals>.<genexpr>)r	r�items)�args�kwargs)�fnr
r�inner_fNszmutant.<locals>.inner_f)r)r"r#r
)r"r�mutantFsr$)�	functoolsrrZpyrsistent._pmaprrZpyrsistent._psetrrZpyrsistent._pvectorrrr	rr$r
r
r
r�<module>s"

?>