HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/pyrsistent/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/pyrsistent/__pycache__/_pmap.cpython-311.pyc
�

���an9����ddlmZmZddlmZddlmZddlmZGd�de	��Z
eje
��eje
��d�Zeid��Z
idfd�Zd	�Zd
S)�)�Mapping�Hashable)�chain)�pvector��	transformc�L��eZdZdZdZ�fd�Zed���Zed���Zd�Z	ed���Z
d�Zej
Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZejZd�ZeZeZeZd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%e%Z&d�Z'd�Z(d�Z)Gd �d!e*��Z+d"�Z,�xZ-S)#�PMapa�
    Persistent map/dict. Tries to follow the same naming conventions as the built in dict where feasible.

    Do not instantiate directly, instead use the factory functions :py:func:`m` or :py:func:`pmap` to
    create an instance.

    Was originally written as a very close copy of the Clojure equivalent but was later rewritten to closer
    re-assemble the python dict. This means that a sparse vector (a PVector) of buckets is used. The keys are
    hashed and the elements inserted at position hash % len(bucket_vector). Whenever the map size exceeds 2/3 of
    the containing vectors size the map is reallocated to a vector of double the size. This is done to avoid
    excessive hash collisions.

    This structure corresponds most closely to the built in dict type and is intended as a replacement. Where the
    semantics are the same (more or less) the same function names have been used but for some cases it is not possible,
    for example assignments and deletion of values.

    PMap implements the Mapping protocol and is Hashable. It also supports dot-notation for
    element access.

    Random access and insert is log32(n) where n is the size of the map.

    The following are examples of some common operations on persistent maps

    >>> m1 = m(a=1, b=3)
    >>> m2 = m1.set('c', 3)
    >>> m3 = m2.remove('a')
    >>> m1 == {'a': 1, 'b': 3}
    True
    >>> m2 == {'a': 1, 'b': 3, 'c': 3}
    True
    >>> m3 == {'b': 3, 'c': 3}
    True
    >>> m3['c']
    3
    >>> m3.c
    3
    )�_size�_buckets�__weakref__�_cached_hashc�t��tt|���|��}||_||_|S�N)�superr
�__new__rr)�cls�size�buckets�self�	__class__s    ��2/usr/lib/python3/dist-packages/pyrsistent/_pmap.pyrzPMap.__new__/s3����T�3���'�'��,�,����
���
���c�X�t|��t|��z}||}||fSr)�hash�len)r�key�index�buckets    r�_get_bucketzPMap._get_bucket5s+���S�	�	�C��L�L�(�������f�}�rc��t�||��\}}|r|D]\}}||kr|cS�t|���r)r
r �KeyError)rr�_r�k�vs      r�_getitemz
PMap._getitem;s[���$�$�W�c�2�2�	��6��	��
�
���1���8�8��H�H�H���s�m�m�rc�B�t�|j|��Sr)r
r&r�rrs  r�__getitem__zPMap.__getitem__Es���}�}�T�]�C�0�0�0rc�l�t�||��\}}|r|D]\}}||krdS�dSdS)NTF)r
r )rrr#rr$s     r�	_containszPMap._containsHsW���$�$�W�c�2�2�	��6��	��
 �
 ���1���8�8��4�4���5��urc�8�|�|j|��Sr)r+rr(s  r�__contains__zPMap.__contains__Ts���~�~�d�m�S�1�1�1rc�*�|���Sr)�iterkeys�rs r�__iter__z
PMap.__iter__Y����}�}���rc��	||S#t$r;}td�t|��j|����|�d}~wwxYw)Nz{0} has no attribute '{1}')r"�AttributeError�format�type�__name__)rr�es   r�__getattr__zPMap.__getattr__\sa��	���9����	�	�	� �,�3�3�D��J�J�4G��M�M����
�����	���s�
�
A�6A
�
Ac#�FK�|���D]	\}}|V��
dSr��	iteritems)rr$r#s   rr/z
PMap.iterkeysd�8�����N�N�$�$�	�	�D�A�q��G�G�G�G�	�	rc#�FK�|���D]	\}}|V��
dSrr;)rr#r%s   r�
itervalueszPMap.itervalueskr=rc#�>K�|jD]}|r|D]\}}||fV���dSr)r)rrr$r%s    rr<zPMap.iteritemsosL�����m�	�	�F��
�"���D�A�q��Q�$�J�J�J�J��	�	rc�D�t|�����Sr)rr?r0s r�valueszPMap.valuesus���t���(�(�)�)�)rc�D�t|�����Sr)rr/r0s r�keysz	PMap.keysxs���t�}�}���'�'�'rc�D�t|�����Sr)rr<r0s r�itemsz
PMap.items{s���t�~�~�'�'�(�(�(rc��|jSr�rr0s r�__len__zPMap.__len__~s
���z�rc�`�d�tt|������S)Nz	pmap({0}))r5�str�dictr0s r�__repr__z
PMap.__repr__�s"���!�!�#�d�4�j�j�/�/�2�2�2rc��||urdSt|t��stSt|��t|��krdSt|t��r�t|d��r"t|d��r|j|jkrdS|j|jkrdSt|�	����t|�	����kSt|t��r%t|�	����|kSt|�	����t|�
����kS)NTFr)�
isinstancer�NotImplementedrr
�hasattrrrrLr<rF�r�others  r�__eq__zPMap.__eq__�s.���5�=�=��4��%��)�)�	"�!�!��t�9�9��E�
�
�"�"��5��e�T�"�"�	3���n�-�-�
�'�%��2P�2P�
��)�U�-?�?�?��u��}���.�.��t�����(�(�)�)�T�%�/�/�2C�2C�-D�-D�D�D�
��t�
$�
$�	3�����(�(�)�)�U�2�2��D�N�N�$�$�%�%��e�k�k�m�m�)<�)<�<�<rc� �td���)NzPMaps are not orderable)�	TypeErrorrRs  r�__lt__zPMap.__lt__�s���1�2�2�2rc�*�|���Sr)rMr0s r�__str__zPMap.__str__�r2rc��t|d��s3tt|�������|_|jS)Nr)rQr�	frozensetr<rr0s r�__hash__z
PMap.__hash__�s@���t�^�,�,�	B� $�Y�t�~�~�/?�/?�%@�%@� A� A�D��� � rc�v�|����||�����S)a4
        Return a new PMap with key and val inserted.

        >>> m1 = m(a=1, b=2)
        >>> m2 = m1.set('a', 3)
        >>> m3 = m1.set('c' ,4)
        >>> m1 == {'a': 1, 'b': 2}
        True
        >>> m2 == {'a': 3, 'b': 2}
        True
        >>> m3 == {'a': 1, 'b': 2, 'c': 4}
        True
        )�evolver�set�
persistent�rr�vals   rr_zPMap.set�s.���|�|�~�~�!�!�#�s�+�+�6�6�8�8�8rc�t�|����|�����S)z�
        Return a new PMap without the element specified by key. Raises KeyError if the element
        is not present.

        >>> m1 = m(a=1, b=2)
        >>> m1.remove('a')
        pmap({'b': 2})
        )r^�remover`r(s  rrdzPMap.remove�s,���|�|�~�~�$�$�S�)�)�4�4�6�6�6rc�R�	|�|��S#t$r|cYSwxYw)a
        Return a new PMap without the element specified by key. Returns reference to itself
        if element is not present.

        >>> m1 = m(a=1, b=2)
        >>> m1.discard('a')
        pmap({'b': 2})
        >>> m1 is m1.discard('c')
        True
        )rdr"r(s  r�discardzPMap.discard�s=��	��;�;�s�#�#�#���	�	�	��K�K�K�	���s��&�&c� �|jd�g|�R�S)a,
        Return a new PMap with the items in Mappings inserted. If the same key is present in multiple
        maps the rightmost (last) value is inserted.

        >>> m1 = m(a=1, b=2)
        >>> m1.update(m(a=2, c=3), {'a': 17, 'd': 35}) == {'a': 17, 'b': 2, 'c': 3, 'd': 35}
        True
        c��|Sr�)�l�rs  r�<lambda>zPMap.update.<locals>.<lambda>�s��Q�r)�update_with)r�mapss  r�updatezPMap.update�s!�� �t����6��6�6�6�6rc	���|���}|D]H}|���D]1\}}|�|||vr||||��n|���2�I|���S)a%
        Return a new PMap with the items in Mappings maps inserted. If the same key is present in multiple
        maps the values will be merged using merge_fn going from left to right.

        >>> from operator import add
        >>> m1 = m(a=1, b=2)
        >>> m1.update_with(add, m(a=2)) == {'a': 3, 'b': 2}
        True

        The reverse behaviour of the regular merge. Keep the leftmost element instead of the rightmost.

        >>> m1 = m(a=1)
        >>> m1.update_with(lambda l, r: l, m(a=2), {'a':3})
        pmap({'a': 1})
        )r^rFr_r`)r�	update_fnrnr^�mapr�values       rrmzPMap.update_with�s��� �,�,�.�.���	^�	^�C�!�i�i�k�k�
^�
^�
��U����C�3�'�>�>���7�3�<��!?�!?�!?�W\�]�]�]�]�
^��!�!�#�#�#rc�,�|�|��Sr)rorRs  r�__add__zPMap.__add__�s���{�{�5�!�!�!rc�0�tt|��ffSr)�pmaprLr0s r�
__reduce__zPMap.__reduce__�s���d�4�j�j�]�"�"rc�"�t||��S)a�
        Transform arbitrarily complex combinations of PVectors and PMaps. A transformation
        consists of two parts. One match expression that specifies which elements to transform
        and one transformation function that performs the actual transformation.

        >>> from pyrsistent import freeze, ny
        >>> news_paper = freeze({'articles': [{'author': 'Sara', 'content': 'A short article'},
        ...                                   {'author': 'Steve', 'content': 'A slightly longer article'}],
        ...                      'weather': {'temperature': '11C', 'wind': '5m/s'}})
        >>> short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:25] + '...' if len(c) > 25 else c)
        >>> very_short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:15] + '...' if len(c) > 15 else c)
        >>> very_short_news.articles[0].content
        'A short article'
        >>> very_short_news.articles[1].content
        'A slightly long...'

        When nothing has been transformed the original data structure is kept

        >>> short_news is news_paper
        True
        >>> very_short_news is news_paper
        False
        >>> very_short_news.articles[0] is news_paper.articles[0]
        True
        r)r�transformationss  rrzPMap.transform�s��4���/�/�/rc��|Srrir0s r�copyz	PMap.copys���rc�T�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
S)�
PMap._Evolver)�_buckets_evolverr�_original_pmapc�h�||_|j���|_|j|_dSr)r�rr^rr)r�
original_pmaps  r�__init__zPMap._Evolver.__init__s/��"/�D��$1�$:�$B�$B�$D�$D�D�!�&�,�D�J�J�Jrc�B�t�|j|��Sr)r
r&rr(s  rr)zPMap._Evolver.__getitem__$s���=�=��!6��<�<�<rc�2�|�||��dSr)r_ras   r�__setitem__zPMap._Evolver.__setitem__'s���H�H�S�#�����rc�����t|j��d|jzkr*|�dt|j��z��|�f}t�|j|��\}}|rb|D],\�}�|kr!|�ur��fd�|D��}||j|<|cS�-|g}|�|��||j|<|xjdz
c_n|g|j|<|xjdz
c_|S)Ngq=
ףp�?�c�2��g|]\}}|�kr||fn|�f��Sriri)�.0�k2�v2r$rbs   ��r�
<listcomp>z%PMap._Evolver.set.<locals>.<listcomp>4s4���)b�)b�)b�QW�QS�UW�b�A�g�g�2�r�(�(�B��9�)b�)b�)br�)rrr�_reallocater
r �extend)	rrrb�kvrrr%�
new_bucketr$s	  `     @rr_zPMap._Evolver.set*s-�����4�(�)�)�D�4�:�,=�=�=�� � ��S��)>�%?�%?�!?�@�@�@��s��B� �,�,�T�-B�C�H�H�M�E�6��
 �"�$�$�D�A�q��C�x�x��C�<�<�)b�)b�)b�)b�)b�[a�)b�)b�)b�J�;E�D�1�%�8�#���� �!�T�
��!�!�&�)�)�)�/9��%�e�,��
�
�a��
�
�
�02�t��%�e�,��
�
�a��
�
��Krc��|dgz}|j���}tjd�|D����D]E\}}t	|��|z}||r||�||f���=||fg||<�Ft
�����|_|j�|��dS)Nc3�K�|]}|�|V��	dSrri)r��xs  r�	<genexpr>z,PMap._Evolver._reallocate.<locals>.<genexpr>Fs'����+D�+D�!�!�+D�A�+D�+D�+D�+D�+D�+Dr)	rr`r�
from_iterabler�appendrr^r�)r�new_size�new_listrr$r%rs       rr�zPMap._Evolver._reallocateCs����4�&�(�H��+�6�6�8�8�G��+�+D�+D�w�+D�+D�+D�D�D�
/�
/���1��Q���(�*���E�?�/��U�O�*�*�A�q�6�2�2�2�2�()�1�v�h�H�U�O�O�%,�I�I�$5�$5�$7�$7�D�!��!�(�(��2�2�2�2�2rc�4�|j���Sr)r�is_dirtyr0s rr�zPMap._Evolver.is_dirtyRs���(�1�1�3�3�3rc��|���r1t|j|j�����|_|jSr)r�r
rrr`r�r0s rr`zPMap._Evolver.persistentUs?���}�}���
[�&*�4�:�t�7L�7W�7W�7Y�7Y�&Z�&Z��#��&�&rc��|jSrrHr0s rrIzPMap._Evolver.__len__[s
���:�rc�B�t�|j|��Sr)r
r+rr(s  rr-zPMap._Evolver.__contains__^s���>�>�$�"7��=�=�=rc�0�|�|��dSr)rdr(s  r�__delitem__zPMap._Evolver.__delitem__as���K�K������rc�.��t�|j���\}}|rN�fd�|D��}t|��t|��kr |r|nd|j|<|xjdzc_|Std�������)Nc�*��g|]\}}|�k�||f��Sriri)r�r$r%rs   �rr�z(PMap._Evolver.remove.<locals>.<listcomp>hs&���F�F�F��!�Q�Q�#�X�X�q�!�f�X�X�Xrr�z{0})r
r rrrr"r5)rrrrr�s `   rrdzPMap._Evolver.removeds���� �,�,�T�-B�C�H�H�M�E�6��
 �F�F�F�F�6�F�F�F�
��v�;�;��Z���0�0�AK�3U�:�:�QU�D�)�%�0��J�J�!�O�J�J��K��5�<�<��,�,�-�-�-rN)r7�
__module__�__qualname__�	__slots__r�r)r�r_r�r�r`rIr-r�rdrirr�_Evolverr~s�������C�	�	-�	-�	-�
	=�	=�	=�	�	�	�	�	�	�2
	3�
	3�
	3�	4�	4�	4�	'�	'�	'�	�	�	�	>�	>�	>�	�	�	�
	.�
	.�
	.�
	.�
	.rr�c�,�|�|��S)a-
        Create a new evolver for this pmap. For a discussion on evolvers in general see the
        documentation for the pvector evolver.

        Create the evolver and perform various mutating updates to it:

        >>> m1 = m(a=1, b=2)
        >>> e = m1.evolver()
        >>> e['c'] = 3
        >>> len(e)
        3
        >>> del e['a']

        The underlying pmap remains the same:

        >>> m1 == {'a': 1, 'b': 2}
        True

        The changes are kept in the evolver. An updated pmap can be created using the
        persistent() function on the evolver.

        >>> m2 = e.persistent()
        >>> m2 == {'b': 2, 'c': 3}
        True

        The new pmap will share data with the original pmap in the same way that would have
        been done if only using operations on the pmap.
        )r�r0s rr^zPMap.evolverps��:�}�}�T�"�"�"r).r7r�r��__doc__r�r�staticmethodr r&r)r+r-r�getr1r9r/r?r<rBrDrFrIrMrT�__ne__rW�__le__�__gt__�__ge__rYr\r_rdrfrormru�__or__rxrr|�objectr�r^�
__classcell__)rs@rr
r
s�������$�$�JE�I����������\��
����\��1�1�1��	�	��\�	�2�2�2��+�C����������������*�*�*�(�(�(�)�)�)����3�3�3�=�=�=�$�^�F�3�3�3��F�
�F�
�F����!�!�!�
9�9�9� 	7�	7�	7���� 	7�	7�	7�$�$�$�."�"�"��F�#�#�#�0�0�0�8���R.�R.�R.�R.�R.�6�R.�R.�R.�h#�#�#�#�#�#�#rr
c���|r|}n(	dt|��zpd}n#t$rd}YnwxYw|dgz}t|t��st	|��}|���D]C\}}t
|��}||z}||}|r|�||f���;||fg||<�Dtt|��t���
|����S)Nr��)r�	ExceptionrOrrLrFrr�r
rr�)	�initial�pre_sizerrr$r%�hrrs	         r�_turbo_mappingr��s�������	��s�7�|�|�#�(�q�D�D���	�	�	��D�D�D�	����
�d�V�m�G��g�w�'�'� ��w�-�-���
�
���&�&���1���G�G���D��������	&��M�M�1�a�&�!�!�!�!� �!�f�X�G�E�N�N���G���g�i�i�.�.�w�7�7�8�8�8s��+�+c�@�|s
|dkrtSt||��S)a�
    Create new persistent map, inserts all elements in initial into the newly created map.
    The optional argument pre_size may be used to specify an initial size of the underlying bucket vector. This
    may have a positive performance impact in the cases where you know beforehand that a large number of elements
    will be inserted into the map eventually since it will reduce the number of reallocations required.

    >>> pmap({'a': 13, 'b': 14}) == {'a': 13, 'b': 14}
    True
    r)�_EMPTY_PMAPr�)r�r�s  rrwrw�s*����x�1�}�}����'�8�,�,�,rc� �t|��S)z�
    Creates a new persistent map. Inserts all key value arguments into the newly created map.

    >>> m(a=13, b=14) == {'a': 13, 'b': 14}
    True
    )rw)�kwargss r�mr��s����<�<�rN)�collections.abcrr�	itertoolsr�pyrsistent._pvectorr�pyrsistent._transformationsrr�r
�registerr�r�rwr�rirr�<module>r�s��-�-�-�-�-�-�-�-�������'�'�'�'�'�'�1�1�1�1�1�1�F#�F#�F#�F#�F#�6�F#�F#�F#�P����������$����9�9�9�@�n�R��#�#���a�
-�
-�
-�
-� ����r