+
    n9eJ                     J   ^ RI HtHt ^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ]! R4      t]! RRR	7      t ! R
 R4      t ! R R]4      t ! R R]4      t ! R R]]]3,          4      t]P$                  ! ]4       ]P$                  ! ]4       R t]! / ^ 4      t/ ^ 3R ltR tR# )    )MappingHashable)chain)GenericTypeVar)pvector	transformKTVT_coT)	covariantc                   <   a  ] tR t^
t o RtR tR tR tR tRt	V t
R# )PMapViewa{  View type for the persistent map/dict type `PMap`.

Provides an equivalent of Python's built-in `dict_values` and `dict_items`
types that result from expreessions such as `{}.values()` and
`{}.items()`. The equivalent for `{}.keys()` is absent because the keys are
instead represented by a `PSet` object, which can be created in `O(1)` time.

The `PMapView` class is overloaded by the `PMapValues` and `PMapItems`
classes which handle the specific case of values and items, respectively

Parameters
----------
m : mapping
    The mapping/dict-like object of which a view is to be created. This
    should generally be a `PMap` object.
c                    \        V\        4      '       g.   \        V\        4      '       d   \        V4      pM\	        R 4      h\
        P                  V RV4       R# )z"PViewMap requires a Mapping object_mapN)
isinstancePMapr   pmap	TypeErrorobject__setattr__)selfms   &&2/usr/lib/python3/dist-packages/pyrsistent/_pmap.py__init__PMapView.__init__   sC    !T""!W%%G DEE4+    c                ,    \        V P                  4      # N)lenr   r   s   &r   __len__PMapView.__len__&   s    499~r   c                2    \        \        V 4      : R 24      h)z is immutable)r   type)r   kvs   &&&r   r   PMapView.__setattr__)   s    T$Z9::r   c                    \        R 4      hz"Persistent maps are not reversibler   r!   s   &r   __reversed__PMapView.__reversed__,       <==r    N)__name__
__module____qualname____firstlineno____doc__r   r"   r   r,   __static_attributes____classdictcell____classdict__s   @r   r   r   
   s#     ",;> >r   r   c                   B   a  ] tR t^/t o RtR tR tR tR tR t	Rt
V tR# )	
PMapValuesa_  View type for the values of the persistent map/dict type `PMap`.

Provides an equivalent of Python's built-in `dict_values` type that result
from expreessions such as `{}.values()`. See also `PMapView`.

Parameters
----------
m : mapping
    The mapping/dict-like object of which a view is to be created. This
    should generally be a `PMap` object.
c                6    V P                   P                  4       # r   r   
itervaluesr!   s   &r   __iter__PMapValues.__iter__;   s    yy##%%r   c                :    WP                   P                  4       9   # r   r<   )r   args   &&r   __contains__PMapValues.__contains__>   s    ii**,,,r   c                2    R \        \        V 4      4       R2# zpmap_values()listiterr!   s   &r   __str__PMapValues.__str__B       d4:./q11r   c                2    R \        \        V 4      4       R2# rE   rG   r!   s   &r   __repr__PMapValues.__repr__E   rL   r   c                    WJ d   R # R# TFr/   r   xs   &&r   __eq__PMapValues.__eq__H   s     9Tr   r/   Nr0   r1   r2   r3   r4   r>   rB   rJ   rN   rT   r5   r6   r7   s   @r   r:   r:   /   s(     
&-22 r   r:   c                   B   a  ] tR t^Nt o RtR tR tR tR tR t	Rt
V tR# )		PMapItemsa\  View type for the items of the persistent map/dict type `PMap`.

Provides an equivalent of Python's built-in `dict_items` type that result
from expreessions such as `{}.items()`. See also `PMapView`.

Parameters
----------
m : mapping
    The mapping/dict-like object of which a view is to be created. This
    should generally be a `PMap` object.
c                6    V P                   P                  4       # r   )r   	iteritemsr!   s   &r   r>   PMapItems.__iter__Z   s    yy""$$r   c                    Vw  r#Y P                  9   ;'       d    T P                  T,          T8H  #   \          d     R # i ; i)F)	Exceptionr   )r   rA   r&   r'   s   &&  r   rB   PMapItems.__contains__]   s9    UaII~33$))A,!"33 &&s   1 A A c                2    R \        \        V 4      4       R2# zpmap_items(rF   rG   r!   s   &r   rJ   PMapItems.__str__c       T$t*-.a00r   c                2    R \        \        V 4      4       R2# r`   rG   r!   s   &r   rN   PMapItems.__repr__f   rb   r   c                |    WJ d   R # \        V\        V 4      4      '       g   R# V P                  VP                  8H  # rQ   )r   r%   r   rR   s   &&r   rT   PMapItems.__eq__i   s/    9TAtDz**5YY!&&((r   r/   NrV   r7   s   @r   rX   rX   N   s(     
%411) )r   rX   c                   b  a a ] tR t^nt oRtR$tV 3R lt]R 4       t]R 4       t	R t
]R 4       tR t]P                  tR tR	 tR
 tR tR tR tR tR tR tR tR tR t]P6                  tR t]t]t]tR t R t!R t"R t#R t$R t%R t&R t']'t(R t)R t*R t+ ! R  R!],4      t-R" t.R#t/Vt0V ;t1# )%r   at  
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
c                F   < \         \        V `  V 4      pWn        W#n        V# r   )superr   __new___size_buckets)clssizebucketsr   	__class__s   &&& r   rj   PMap.__new__   s#    T3',
r   c                N    \        V4      \        V 4      ,          pW,          pW#3# r   )hashr    )ro   keyindexbuckets   &&  r   _get_bucketPMap._get_bucket   s#    S	CL(}r   c                    \         P                  W4      w  r#V'       d   V F  w  rEWA8X  g   K  Vu # 	  \        V4      hr   )r   rw   KeyError)ro   rt   _rv   r&   r'   s   &&    r   _getitemPMap._getitem   s9    $$W2	8H  smr   c                B    \         P                  V P                  V4      # r   )r   r|   rl   r   rt   s   &&r   __getitem__PMap.__getitem__   s    }}T]]C00r   c                p    \         P                  W4      w  r#V'       d   V F  w  rBWA8X  g   K   R # 	  R# R# rQ   )r   rw   )ro   rt   r{   rv   r&   s   &&   r   	_containsPMap._contains   s3    $$W2	8  r   c                :    V P                  V P                  V4      # r   )r   rl   r   s   &&r   rB   PMap.__contains__   s    ~~dmmS11r   c                "    V P                  4       # r   )iterkeysr!   s   &r   r>   PMap.__iter__       }}r   c                    \        R 4      hr*   r+   r!   s   &r   r,   PMap.__reversed__   r.   r   c                     W,          #   \          d5   p\        R P                  \        T 4      P                  T4      4      ThRp?ii ; i)z{0} has no attribute '{1}'N)rz   AttributeErrorformatr%   r0   )r   rt   es   && r   __getattr__PMap.__getattr__   sI    	9 	 ,33DJ4G4GM	s   
 A	/AA	c              #  H   "   V P                  4        F	  w  rVx  K  	  R # 5ir   rZ   )r   r&   r{   s   &  r   r   PMap.iterkeys        NN$DAG %    "c              #  H   "   V P                  4        F	  w  rVx  K  	  R # 5ir   r   )r   r{   r'   s   &  r   r=   PMap.itervalues   r   r   c              #  h   "   V P                    F  pV'       g   K  V F
  w  r#W#3x  K  	  K  	  R # 5ir   )rl   )r   rv   r&   r'   s   &   r   rZ   PMap.iteritems   s+     mmFv"DA$J # $s   22c                    \        V 4      # r   )r:   r!   s   &r   valuesPMap.values   s    $r   c                    ^RI Hp V! V 4      # )   )PSet)_psetr   )r   r   s   & r   keys	PMap.keys   s    Dzr   c                    \        V 4      # r   )rX   r!   s   &r   items
PMap.items   s    r   c                    V P                   # r   rk   r!   s   &r   r"   PMap.__len__   s    zzr   c                H    R P                  \        \        V 4      4      4      # )z	pmap({0}))r   strdictr!   s   &r   rN   PMap.__repr__   s    !!#d4j/22r   c                   WJ d   R # \        V\        4      '       g   \        # \        V 4      \        V4      8w  d   R# \        V\        4      '       d   \        V R4      '       d0   \        VR4      '       d   V P                  VP                  8w  d   R# V P                  VP                  8X  d   R # \        V P                  4       4      \        VP                  4       4      8H  # \        V\        4      '       d   \        V P                  4       4      V8H  # \        V P                  4       4      \        VP                  4       4      8H  # )TF_cached_hash)r   r   NotImplementedr    r   hasattrr   rl   r   rZ   r   r   others   &&r   rT   PMap.__eq__   s    =%))!!t9E
"eT""n--'%2P2P))U-?-??}}.()T%//2C-DDDt$$()U22DNN$%ekkm)<<<r   c                    \        R 4      h)zPMaps are not orderabler+   r   s   &&r   __lt__PMap.__lt__  s    122r   c                "    V P                  4       # r   )rN   r!   s   &r   rJ   PMap.__str__  r   r   c                    \        V R 4      '       g(   \        \        V P                  4       4      4      V n        V P                  # )r   )r   rs   	frozensetrZ   r   r!   s   &r   __hash__PMap.__hash__  s4    t^,, $Yt~~/?%@ AD   r   c                \    V P                  4       P                  W4      P                  4       # )z
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r   rt   vals   &&&r   r   PMap.set  s$     ||~!!#+6688r   c                \    V P                  4       P                  V4      P                  4       # )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   &&r   r   PMap.remove%  s$     ||~$$S)4466r   c                L     V P                  V4      #   \         d    T u # i ; i)z
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
)r   rz   r   s   &&r   discardPMap.discard0  s*    	;;s## 	K	s    ##c                ,    V P                   ! R .VO5!  # )z
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                     V# r   r/   )lrs   &&r   <lambda>PMap.update.<locals>.<lambda>I  s    Qr   )update_with)r   mapss   &*r   updatePMap.update@  s     666r   c           	         V P                  4       pV FC  pVP                  4        F,  w  rVTP                  YUV9   d   V! W5,          V4      MT4       K.  	  KE  	  VP                  4       # )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   r   r   r   )r   	update_fnr   r   maprt   values   &&*    r   r   PMap.update_withK  sZ      ,,.C!iik
C'>7<!?W\] *  !!##r   c                $    V P                  V4      # r   )r   r   s   &&r   __add__PMap.__add__b  s    {{5!!r   c                &    \         \        V 4      33# r   )r   r   r!   s   &r   
__reduce__PMap.__reduce__g  s    d4j]""r   c                    \        W4      # )aW  
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   &*r   r
   PMap.transformk  s    4 //r   c                    V # r   r/   r!   s   &r   copy	PMap.copy  s    r   c                   f   a  ] tR tRt o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tRtV tR# )PMap._Evolveri  c                r    Wn         VP                  P                  4       V n        VP                  V n        R # r   )_original_pmaprl   r   _buckets_evolverrk   )r   original_pmaps   &&r   r   PMap._Evolver.__init__  s,    "/$1$:$:$B$B$DD!&,,DJr   c                B    \         P                  V P                  V4      # r   )r   r|   r   r   s   &&r   r   PMap._Evolver.__getitem__  s    ==!6!6<<r   c                (    V P                  W4       R # r   )r   r   s   &&&r   __setitem__PMap._Evolver.__setitem__  s    HHSr   c                   W3p\         P                  V P                  V4      w  rE\        V P                  4      R V P                  ,          8  pV'       d   V FA  w  rxWq8X  g   K  WJd.   V U	U
u. uF  w  rW8X  g   W3MW3NK  	  pp	p
WP                  V&   V u # 	  V'       d"   V P                  4        V P                  W4      # V.pVP                  V4       WP                  V&   V ;P                  ^,          un        V # V'       d"   V P                  4        V P                  W4      # V.V P                  V&   V ;P                  ^,          un        V # u up
p	i )gq=
ףp?)r   rw   r   r    rk   _reallocater   extend)r   rt   r   kvru   rv   reallocation_requiredr&   r'   k2v2
new_buckets   &&&         r   r   PMap._Evolver.set  s6   B ,,T-B-BCHME$'(=(=$>

AR$R!"DAx<ag)hagW]WY272("*RagJ)h;E11%8# # )$$&88C-- T
!!&)/9%%e,

a
 K )$$&88C--02t%%e,

a
K/ *is   0Ec                   ^\        V P                  4      ,          pVR.,          pV P                  P                  4       p\        P                  ! R V 4       4       FE  w  rE\        V4      V,          pW&,          '       d   W&,          P                  WE34       K?  WE3.W&&   KG  	  \        4       P                  4       V n        V P                  P                  V4       R# )   Nc              3   8   "   T F  q'       g   K  Vx  K  	  R # 5ir   r/   ).0rS   s   & r   	<genexpr>,PMap._Evolver._reallocate.<locals>.<genexpr>  s     +Dw!!AAws   	
)
r    r   r   r   from_iterablers   appendr   r   r   )r   new_sizenew_listro   r&   r'   ru   s   &      r   r   PMap._Evolver._reallocate  s    3t4455H4&(H++668G+++Dw+DDQ(*??O**A62()vhHO E %,I$5$5$7D!!!((2r   c                6    V P                   P                  4       # r   )r   is_dirtyr!   s   &r   r  PMap._Evolver.is_dirty  s    ((1133r   c                    V P                  4       '       d4   \        V P                  V P                  P	                  4       4      V n        V P
                  # r   )r  r   rk   r   r   r   r!   s   &r   r   PMap._Evolver.persistent  s;    }}&*4::t7L7L7W7W7Y&Z#&&&r   c                    V P                   # r   r   r!   s   &r   r"   PMap._Evolver.__len__  s    ::r   c                B    \         P                  V P                  V4      # r   )r   r   r   r   s   &&r   rB   PMap._Evolver.__contains__  s    >>$"7"7==r   c                (    V P                  V4       R # r   )r   r   s   &&r   __delitem__PMap._Evolver.__delitem__  s    KKr   c                ~   \         P                  V P                  V4      w  r#V'       du   V UUu. uF  w  rEWA8X  d   K  WE3NK  	  ppp\        V4      \        V4      ,
          pV^ 8  d5   V'       d   TMRV P                  V&   V ;P                  V,          un        V # \        RP                  V4      4      hu uppi )r   Nz{0})r   rw   r   r    rk   rz   r   )r   rt   ru   rv   r&   r'   r   	size_diffs   &&      r   r   PMap._Evolver.remove  s     ,,T-B-BCHME39L6!!(fqf6
LK#j/9	q=AK:QUD))%0JJ)+JK5<<,-- Ms
   
B9B9)r   r   rk   N)r   rk   r   )r0   r1   r2   r3   	__slots__r   r   r   r   r   r  r   r"   rB   r  r   r5   r6   r7   s   @r   _Evolverr     sG     C		-
	=	 	D	3 	4	'		>		. 	.r   r  c                $    V P                  V 4      # )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  r!   s   &r   r   PMap.evolver  s    : }}T""r   )rl   r   rk   )rk   rl   __weakref__r   )2r0   r1   r2   r3   r4   r  rj   staticmethodrw   r|   r   r   rB   r   getr>   r,   r   r   r=   rZ   r   r   r   r"   rN   rT   __ne__r   __le____gt____ge__rJ   r   r   r   r   r   r   r   __or__r   r
   r   r   r  r   r5   r6   __classcell__)rp   r8   s   @@r   r   r   n   s    $J EI  
  1 	 	2 ++C> 3=$ ^^F3 FFF!
9 	7 	7$." F#08^.6 ^.@# #r   r   c                    V'       d   TpM ^\        V 4      ,          ;'       g    ^pVR.,          p\        V \        4      '       g   \	        V 4      p V P                  4        FB  w  rE\        V4      pWb,          pW7,          pV'       d   VP                  WE34       K<  WE3.W7&   KD  	  \        \        V 4      \        4       P                  V4      4      #   \         d    ^p Li ; i)r   N)r    r]   r   r   r   r   rs   r  r   r   r   )	initialpre_sizern   ro   r&   r'   hru   rv   s	   &&       r   _turbo_mappingr'    s    	s7|#((qD dVmGgw'' w-GMM1&! fXGN   Ggi..w788/  	 D	s   C C C&%C&c                B    V '       g   V^ 8X  d   \         # \        W4      # )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
)_EMPTY_PMAPr'  )r$  r%  s   &&r   r   r   0  s     x1}',,r   c                     \        V 4      # )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
)r   )kwargss   ,r   r   r   @  s     <r   N)collections.abcr   r   	itertoolsr   typingr   r   pyrsistent._pvectorr   pyrsistent._transformationsr
   r   r   r   r:   rX   r   registerr'  r)  r   r   r/   r   r   <module>r2     s    -  # ' 1T]4(#> #>J >) )@Y#72u9 Y#v       $ 9@ R# a - r   