pyrsistent - pydoc - phpman

Look up a command

 

Markdown Format | JSON API | MCP Server Tool


pyrsistent
NAME PACKAGE CONTENTS CLASSES FUNCTIONS DATA FILE
Help on package pyrsistent:

NAME
    pyrsistent - # -*- coding: utf-8 -*-

PACKAGE CONTENTS
    _checked_types
    _field_common
    _helpers
    _immutable
    _pbag
    _pclass
    _pdeque
    _plist
    _pmap
    _precord
    _pset
    _pvector
    _toolz
    _transformations
    typing

CLASSES
    builtins.Exception(builtins.BaseException)
        pyrsistent._checked_types.InvariantException
    builtins.object
        pyrsistent._checked_types.CheckedType
            pyrsistent._checked_types.CheckedPVector(pyrsistent._pvector.PythonPVector, pyrsistent._checked_types.CheckedType)
            pyrsistent._pclass.PClass
        pyrsistent._pbag.PBag
        pyrsistent._pdeque.PDeque
        pyrsistent._pmap.PMap
            pyrsistent._checked_types.CheckedPMap(pyrsistent._pmap.PMap, pyrsistent._checked_types.CheckedType)
            pyrsistent._precord.PRecord(pyrsistent._pmap.PMap, pyrsistent._checked_types.CheckedType)
        pyrsistent._pset.PSet
            pyrsistent._checked_types.CheckedPSet(pyrsistent._pset.PSet, pyrsistent._checked_types.CheckedType)
        pyrsistent._pvector.PVector
    builtins.type(builtins.object)
        pyrsistent._pclass.PClassMeta
    pyrsistent._checked_types.CheckedTypeError(builtins.TypeError)
        pyrsistent._checked_types.CheckedKeyTypeError
        pyrsistent._checked_types.CheckedValueTypeError
    pyrsistent._plist._PListBase(builtins.object)
        pyrsistent._plist.PList
    pyrsistent._pvector.PythonPVector(builtins.object)
        pyrsistent._checked_types.CheckedPVector(pyrsistent._pvector.PythonPVector, pyrsistent._checked_types.CheckedType)

    class CheckedKeyTypeError(CheckedTypeError)
     |  CheckedKeyTypeError(source_class, expected_types, actual_type, actual_value, *args, **kwargs)
     |
     |  Raised when trying to set a value using a key with a type that doesn't match the declared type.
     |
     |  Attributes:
     |  source_class -- The class of the collection
     |  expected_types  -- Allowed types
     |  actual_type -- The non matching type
     |  actual_value -- Value of the variable with the non matching type
     |
     |  Method resolution order:
     |      CheckedKeyTypeError
     |      CheckedTypeError
     |      builtins.TypeError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Methods inherited from CheckedTypeError:
     |
     |  __init__(self, source_class, expected_types, actual_type, actual_value, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from CheckedTypeError:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.TypeError:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class CheckedPMap(pyrsistent._pmap.PMap, CheckedType)
     |  CheckedPMap(initial={}, size=<object object at 0x7f8c1b7d4ab0>)
     |
     |  A CheckedPMap is a PMap which allows specifying type and invariant checks.
     |
     |  >>> class IntToFloatMap(CheckedPMap):
     |  ...     __key_type__ = int
     |  ...     __value_type__ = float
     |  ...     __invariant__ = lambda k, v: (int(v) == k, 'Invalid mapping')
     |  ...
     |  >>> IntToFloatMap({1: 1.5, 2: 2.25})
     |  IntToFloatMap({1: 1.5, 2: 2.25})
     |
     |  Method resolution order:
     |      CheckedPMap
     |      pyrsistent._pmap.PMap
     |      CheckedType
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __serializer__ = default_serializer(self, _, key, value)
     |
     |  __str__ = __repr__(self)
     |
     |  evolver(self)
     |      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.
     |
     |  serialize(self, format=None)
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create(source_data, _factory_fields=None) from pyrsistent._checked_types._CheckedMapTypeMeta
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, initial={}, size=<object object at 0x7f8c1b7d4ab0>)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  Evolver = <class 'pyrsistent._checked_types.CheckedPMap.Evolver'>
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from pyrsistent._pmap.PMap:
     |
     |  __add__(self, other)
     |
     |  __contains__(self, key)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__ = __lt__(self, other)
     |
     |  __getattr__(self, key)
     |
     |  __getitem__(self, key)
     |
     |  __gt__ = __lt__(self, other)
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__ = __lt__(self, other)
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __ne__(self, value, /)
     |      Return self!=value.
     |
     |  __or__ = __add__(self, other)
     |
     |  copy(self)
     |
     |  discard(self, key)
     |      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
     |
     |  get(self, key, default=None)
     |      D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
     |
     |  items(self)
     |
     |  iteritems(self)
     |
     |  iterkeys(self)
     |
     |  itervalues(self)
     |      # These are more efficient implementations compared to the original
     |      # methods that are based on the keys iterator and then calls the
     |      # accessor functions to access the value for the corresponding key
     |
     |  keys(self)
     |
     |  remove(self, key)
     |      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})
     |
     |  set(self, key, val)
     |      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
     |
     |  transform(self, *transformations)
     |      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
     |
     |  update(self, *maps)
     |      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
     |
     |  update_with(self, update_fn, *maps)
     |      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})
     |
     |  values(self)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from pyrsistent._pmap.PMap:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class CheckedPSet(pyrsistent._pset.PSet, CheckedType)
     |  CheckedPSet(initial=())
     |
     |  A CheckedPSet is a PSet which allows specifying type and invariant checks.
     |
     |  >>> class Positives(CheckedPSet):
     |  ...     __type__ = (int, float)
     |  ...     __invariant__ = lambda n: (n >= 0, 'Negative')
     |  ...
     |  >>> Positives([1, 2, 3])
     |  Positives([1, 2, 3])
     |
     |  Method resolution order:
     |      CheckedPSet
     |      pyrsistent._pset.PSet
     |      CheckedType
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __serializer__ = default_serializer(self, _, value)
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  evolver(self)
     |      Create a new evolver for this pset. For a discussion on evolvers in general see the
     |      documentation for the pvector evolver.
     |
     |      Create the evolver and perform various mutating updates to it:
     |
     |      >>> s1 = s(1, 2, 3)
     |      >>> e = s1.evolver()
     |      >>> _ = e.add(4)
     |      >>> len(e)
     |      4
     |      >>> _ = e.remove(1)
     |
     |      The underlying pset remains the same:
     |
     |      >>> s1
     |      pset([1, 2, 3])
     |
     |      The changes are kept in the evolver. An updated pmap can be created using the
     |      persistent() function on the evolver.
     |
     |      >>> s2 = e.persistent()
     |      >>> s2
     |      pset([2, 3, 4])
     |
     |      The new pset will share data with the original pset in the same way that would have
     |      been done if only using operations on the pset.
     |
     |  serialize(self, format=None)
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create = _checked_type_create(source_data, _factory_fields=None, ignore_extra=False) from pyrsistent._checked_types._CheckedTypeMeta
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, initial=())
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  Evolver = <class 'pyrsistent._checked_types.CheckedPSet.Evolver'>
     |
     |  __abstractmethods__ = frozenset()
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from pyrsistent._pset.PSet:
     |
     |  __and__(self, other)
     |
     |  __contains__(self, element)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__(self, other)
     |      Return self>=value.
     |
     |  __gt__(self, other)
     |      Return self>value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__(self, other)
     |      Return self<=value.
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __ne__(self, value, /)
     |      Return self!=value.
     |
     |  __or__(self, other)
     |      Return self|value.
     |
     |  __sub__(self, other)
     |
     |  __xor__(self, other)
     |
     |  add(self, element)
     |      Return a new PSet with element added
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.add(3)
     |      pset([1, 2, 3])
     |
     |  copy(self)
     |
     |  difference = __sub__(self, other)
     |
     |  discard(self, element)
     |      Return a new PSet with element removed. Returns itself if element is not present.
     |
     |  intersection = __and__(self, other)
     |
     |  isdisjoint(self, other)
     |      Return True if two sets have a null intersection.
     |
     |  issubset = __le__(self, other)
     |
     |  issuperset = __ge__(self, other)
     |
     |  remove(self, element)
     |      Return a new PSet with element removed. Raises KeyError if element is not present.
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.remove(2)
     |      pset([1])
     |
     |  symmetric_difference = __xor__(self, other)
     |
     |  union = __or__(self, other)
     |
     |  update(self, iterable)
     |      Return a new PSet with elements in iterable added
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.update([3, 4, 4])
     |      pset([1, 2, 3, 4])
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from pyrsistent._pset.PSet:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class CheckedPVector(pyrsistent._pvector.PythonPVector, CheckedType)
     |  CheckedPVector(initial=())
     |
     |  A CheckedPVector is a PVector which allows specifying type and invariant checks.
     |
     |  >>> class Positives(CheckedPVector):
     |  ...     __type__ = (int, float)
     |  ...     __invariant__ = lambda n: (n >= 0, 'Negative')
     |  ...
     |  >>> Positives([1, 2, 3])
     |  Positives([1, 2, 3])
     |
     |  Method resolution order:
     |      CheckedPVector
     |      pyrsistent._pvector.PythonPVector
     |      CheckedType
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __serializer__ = default_serializer(self, _, value)
     |
     |  __str__ = __repr__(self)
     |
     |  append(self, val)
     |
     |  evolver(self)
     |
     |  extend(self, it)
     |
     |  serialize(self, format=None)
     |
     |  set(self, key, value)
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create = _checked_type_create(source_data, _factory_fields=None, ignore_extra=False) from pyrsistent._checked_types._CheckedTypeMeta
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, initial=())
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  Evolver = <class 'pyrsistent._checked_types.CheckedPVector.Evolver'>
     |
     |  __abstractmethods__ = frozenset()
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from pyrsistent._pvector.PythonPVector:
     |
     |  __add__(self, other)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__(self, other)
     |      Return self>=value.
     |
     |  __getitem__(self, index)
     |
     |  __gt__(self, other)
     |      Return self>value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__(self, other)
     |      Return self<=value.
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __mul__(self, times)
     |
     |  __ne__(self, other)
     |      Return self!=value.
     |
     |  __rmul__ = __mul__(self, times)
     |
     |  count(self, value)
     |
     |  delete(self, index, stop=None)
     |
     |  index(self, value, *args, **kwargs)
     |
     |  mset(self, *args)
     |
     |  remove(self, value)
     |
     |  tolist(self)
     |      The fastest way to convert the vector into a python list.
     |
     |  transform(self, *transformations)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from pyrsistent._pvector.PythonPVector:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class CheckedType(builtins.object)
     |  Marker class to enable creation and serialization of checked object graphs.
     |
     |  Methods defined here:
     |
     |  serialize(self, format=None)
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create(source_data, _factory_fields=None) from builtins.type

    class CheckedValueTypeError(CheckedTypeError)
     |  CheckedValueTypeError(source_class, expected_types, actual_type, actual_value, *args, **kwargs)
     |
     |  Raised when trying to set a value using a key with a type that doesn't match the declared type.
     |
     |  Attributes:
     |  source_class -- The class of the collection
     |  expected_types  -- Allowed types
     |  actual_type -- The non matching type
     |  actual_value -- Value of the variable with the non matching type
     |
     |  Method resolution order:
     |      CheckedValueTypeError
     |      CheckedTypeError
     |      builtins.TypeError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Methods inherited from CheckedTypeError:
     |
     |  __init__(self, source_class, expected_types, actual_type, actual_value, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from CheckedTypeError:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.TypeError:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  __str__(self, /)
     |      Return str(self).
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class InvariantException(builtins.Exception)
     |  InvariantException(error_codes=(), missing_fields=(), *args, **kwargs)
     |
     |  Exception raised from a :py:class:`CheckedType` when invariant tests fail or when a mandatory
     |  field is missing.
     |
     |  Contains two fields of interest:
     |  invariant_errors, a tuple of error data for the failing invariants
     |  missing_fields, a tuple of strings specifying the missing names
     |
     |  Method resolution order:
     |      InvariantException
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __init__(self, error_codes=(), missing_fields=(), *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.Exception:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Helper for pickle.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __setstate__(...)
     |
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |
     |  __cause__
     |      exception cause
     |
     |  __context__
     |      exception context
     |
     |  __dict__
     |
     |  __suppress_context__
     |
     |  __traceback__
     |
     |  args

    class PBag(builtins.object)
     |  PBag(counts)
     |
     |  A persistent bag/multiset type.
     |
     |  Requires elements to be hashable, and allows duplicates, but has no
     |  ordering. Bags are hashable.
     |
     |  Do not instantiate directly, instead use the factory functions :py:func:`b`
     |  or :py:func:`pbag` to create an instance.
     |
     |  Some examples:
     |
     |  >>> s = pbag([1, 2, 3, 1])
     |  >>> s2 = s.add(4)
     |  >>> s3 = s2.remove(1)
     |  >>> s
     |  pbag([1, 1, 2, 3])
     |  >>> s2
     |  pbag([1, 1, 2, 3, 4])
     |  >>> s3
     |  pbag([1, 2, 3, 4])
     |
     |  Methods defined here:
     |
     |  __add__(self, other)
     |      Combine elements from two PBags.
     |
     |      >>> pbag([1, 2, 2]) + pbag([2, 3, 3])
     |      pbag([1, 2, 2, 2, 3, 3])
     |
     |  __and__(self, other)
     |      Intersection: Only keep elements that are present in both PBags.
     |
     |      >>> pbag([1, 2, 2, 2]) & pbag([2, 3, 3])
     |      pbag([2])
     |
     |  __contains__(self, elt)
     |      Check if an element is in the bag.
     |
     |      >>> 1 in pbag([1, 1, 2])
     |      True
     |      >>> 0 in pbag([1, 2])
     |      False
     |
     |  __eq__(self, other)
     |      Check if two bags are equivalent, honoring the number of duplicates,
     |      and ignoring insertion order.
     |
     |      >>> pbag([1, 1, 2]) == pbag([1, 2])
     |      False
     |      >>> pbag([2, 1, 0]) == pbag([0, 1, 2])
     |      True
     |
     |  __ge__ = __lt__(self, other)
     |
     |  __gt__ = __lt__(self, other)
     |
     |  __hash__(self)
     |      Hash based on value of elements.
     |
     |      >>> m = pmap({pbag([1, 2]): "it's here!"})
     |      >>> m[pbag([2, 1])]
     |      "it's here!"
     |      >>> pbag([1, 1, 2]) in m
     |      False
     |
     |  __init__(self, counts)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __iter__(self)
     |      Return an iterator of all elements, including duplicates.
     |
     |      >>> list(pbag([1, 1, 2]))
     |      [1, 1, 2]
     |      >>> list(pbag([1, 2]))
     |      [1, 2]
     |
     |  __le__ = __lt__(self, other)
     |
     |  __len__(self)
     |      Return the length including duplicates.
     |
     |      >>> len(pbag([1, 1, 2]))
     |      3
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __or__(self, other)
     |      Union: Keep elements that are present in either of two PBags.
     |
     |      >>> pbag([1, 2, 2, 2]) | pbag([2, 3, 3])
     |      pbag([1, 2, 2, 2, 3, 3])
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __sub__(self, other)
     |      Remove elements from one PBag that are present in another.
     |
     |      >>> pbag([1, 2, 2, 2, 3]) - pbag([2, 3, 3, 4])
     |      pbag([1, 2, 2])
     |
     |  add(self, element)
     |      Add an element to the bag.
     |
     |      >>> s = pbag([1])
     |      >>> s2 = s.add(1)
     |      >>> s3 = s.add(2)
     |      >>> s2
     |      pbag([1, 1])
     |      >>> s3
     |      pbag([1, 2])
     |
     |  count(self, element)
     |      Return the number of times an element appears.
     |
     |
     |      >>> pbag([]).count('non-existent')
     |      0
     |      >>> pbag([1, 1, 2]).count(1)
     |      2
     |
     |  remove(self, element)
     |      Remove an element from the bag.
     |
     |      >>> s = pbag([1, 1, 2])
     |      >>> s2 = s.remove(1)
     |      >>> s3 = s.remove(2)
     |      >>> s2
     |      pbag([1, 2])
     |      >>> s3
     |      pbag([1, 1])
     |
     |  update(self, iterable)
     |      Update bag with all elements in iterable.
     |
     |      >>> s = pbag([1])
     |      >>> s.update([1, 2])
     |      pbag([1, 1, 2])
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PClass(pyrsistent._checked_types.CheckedType)
     |  PClass(**kwargs)
     |
     |  A PClass is a python class with a fixed set of specified fields. PClasses are declared as python classes inheriting
     |  from PClass. It is defined the same way that PRecords are and behaves like a PRecord in all aspects except that it
     |  is not a PMap and hence not a collection but rather a plain Python object.
     |
     |
     |  More documentation and examples of PClass usage is available at https://github.com/tobgu/pyrsistent
     |
     |  Method resolution order:
     |      PClass
     |      pyrsistent._checked_types.CheckedType
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __delattr__(self, key)
     |      Implement delattr(self, name).
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __ne__(self, other)
     |      Return self!=value.
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __setattr__(self, key, value)
     |      Implement setattr(self, name, value).
     |
     |  evolver(self)
     |      Returns an evolver for this object.
     |
     |  remove(self, name)
     |      Remove attribute given by name from the current instance. Raises AttributeError if the
     |      attribute doesn't exist.
     |
     |  serialize(self, format=None)
     |      Serialize the current PClass using custom serializer functions for fields where
     |      such have been supplied.
     |
     |  set(self, *args, **kwargs)
     |      Set a field in the instance. Returns a new instance with the updated value. The original instance remains
     |      unmodified. Accepts key-value pairs or single string representing the field name and a value.
     |
     |      >>> from pyrsistent import PClass, field
     |      >>> class AClass(PClass):
     |      ...     x = field()
     |      ...
     |      >>> a = AClass(x=1)
     |      >>> a2 = a.set(x=2)
     |      >>> a3 = a.set('x', 3)
     |      >>> a
     |      AClass(x=1)
     |      >>> a2
     |      AClass(x=2)
     |      >>> a3
     |      AClass(x=3)
     |
     |  transform(self, *transformations)
     |      Apply transformations to the currency PClass. For more details on transformations see
     |      the documentation for PMap. Transformations on PClasses do not support key matching
     |      since the PClass is not a collection. Apart from that the transformations available
     |      for other persistent types work as expected.
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create(kwargs, _factory_fields=None, ignore_extra=False) from pyrsistent._pclass.PClassMeta
     |      Factory method. Will create a new PClass of the current type and assign the values
     |      specified in kwargs.
     |
     |      :param ignore_extra: A boolean which when set to True will ignore any keys which appear in kwargs that are not
     |                           in the set of fields on the PClass.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, **kwargs)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PClassMeta(builtins.type)
     |  PClassMeta(name, bases, dct)
     |
     |  Method resolution order:
     |      PClassMeta
     |      builtins.type
     |      builtins.object
     |
     |  Static methods defined here:
     |
     |  __new__(mcs, name, bases, dct)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __annotations__ = {}
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.type:
     |
     |  __call__(self, /, *args, **kwargs)
     |      Call self as a function.
     |
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |
     |  __dir__(self, /)
     |      Specialized __dir__ implementation for types.
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __instancecheck__(self, instance, /)
     |      Check if an object is an instance.
     |
     |  __or__(self, value, /)
     |      Return self|value.
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  __ror__(self, value, /)
     |      Return value|self.
     |
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |
     |  __sizeof__(self, /)
     |      Return memory consumption of the type object.
     |
     |  __subclasscheck__(self, subclass, /)
     |      Check if a class is a subclass.
     |
     |  __subclasses__(self, /)
     |      Return a list of immediate subclasses.
     |
     |  mro(self, /)
     |      Return a type's method resolution order.
     |
     |  ----------------------------------------------------------------------
     |  Class methods inherited from builtins.type:
     |
     |  __prepare__(...) from builtins.type
     |      __prepare__() -> dict
     |      used to create the namespace for the class statement
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.type:
     |
     |  __abstractmethods__
     |
     |  __dict__
     |
     |  __text_signature__
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from builtins.type:
     |
     |  __base__ = <class 'type'>
     |      type(object) -> the object's type
     |      type(name, bases, dict, **kwds) -> a new type
     |
     |
     |  __bases__ = (<class 'type'>,)
     |
     |  __basicsize__ = 888
     |
     |  __dictoffset__ = 264
     |
     |  __flags__ = 2148029952
     |
     |  __itemsize__ = 40
     |
     |  __mro__ = (<class 'pyrsistent._pclass.PClassMeta'>, <class 'type'>, <c...
     |
     |  __weakrefoffset__ = 368

    class PDeque(builtins.object)
     |  PDeque(left_list, right_list, length, maxlen=None)
     |
     |  Persistent double ended queue (deque). Allows quick appends and pops in both ends. Implemented
     |  using two persistent lists.
     |
     |  A maximum length can be specified to create a bounded queue.
     |
     |  Fully supports the Sequence and Hashable protocols including indexing and slicing but
     |  if you need fast random access go for the PVector instead.
     |
     |  Do not instantiate directly, instead use the factory functions :py:func:`dq` or :py:func:`pdeque` to
     |  create an instance.
     |
     |  Some examples:
     |
     |  >>> x = pdeque([1, 2, 3])
     |  >>> x.left
     |  1
     |  >>> x.right
     |  3
     |  >>> x[0] == x.left
     |  True
     |  >>> x[-1] == x.right
     |  True
     |  >>> x.pop()
     |  pdeque([1, 2])
     |  >>> x.pop() == x[:-1]
     |  True
     |  >>> x.popleft()
     |  pdeque([2, 3])
     |  >>> x.append(4)
     |  pdeque([1, 2, 3, 4])
     |  >>> x.appendleft(4)
     |  pdeque([4, 1, 2, 3])
     |
     |  >>> y = pdeque([1, 2, 3], maxlen=3)
     |  >>> y.append(4)
     |  pdeque([2, 3, 4], maxlen=3)
     |  >>> y.appendleft(4)
     |  pdeque([4, 1, 2], maxlen=3)
     |
     |  Methods defined here:
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __getitem__(self, index)
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __reversed__ = reverse(self)
     |
     |  __str__ = __repr__(self)
     |
     |  append(self, elem)
     |      Return new deque with elem as the rightmost element.
     |
     |      >>> pdeque([1, 2]).append(3)
     |      pdeque([1, 2, 3])
     |
     |  appendleft(self, elem)
     |      Return new deque with elem as the leftmost element.
     |
     |      >>> pdeque([1, 2]).appendleft(3)
     |      pdeque([3, 1, 2])
     |
     |  count(self, elem)
     |      Return the number of elements equal to elem present in the queue
     |
     |      >>> pdeque([1, 2, 1]).count(1)
     |      2
     |
     |  extend(self, iterable)
     |      Return new deque with all elements of iterable appended to the right.
     |
     |      >>> pdeque([1, 2]).extend([3, 4])
     |      pdeque([1, 2, 3, 4])
     |
     |  extendleft(self, iterable)
     |      Return new deque with all elements of iterable appended to the left.
     |
     |      NB! The elements will be inserted in reverse order compared to the order in the iterable.
     |
     |      >>> pdeque([1, 2]).extendleft([3, 4])
     |      pdeque([4, 3, 1, 2])
     |
     |  index(self, value, start=0, stop=None)
     |      S.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |
     |      Supporting start and stop arguments is optional, but
     |      recommended.
     |
     |  pop(self, count=1)
     |      Return new deque with rightmost element removed. Popping the empty queue
     |      will return the empty queue. A optional count can be given to indicate the
     |      number of elements to pop. Popping with a negative index is the same as
     |      popleft. Executes in amortized O(k) where k is the number of elements to pop.
     |
     |      >>> pdeque([1, 2]).pop()
     |      pdeque([1])
     |      >>> pdeque([1, 2]).pop(2)
     |      pdeque([])
     |      >>> pdeque([1, 2]).pop(-1)
     |      pdeque([2])
     |
     |  popleft(self, count=1)
     |      Return new deque with leftmost element removed. Otherwise functionally
     |      equivalent to pop().
     |
     |      >>> pdeque([1, 2]).popleft()
     |      pdeque([2])
     |
     |  remove(self, elem)
     |      Return new deque with first element from left equal to elem removed. If no such element is found
     |      a ValueError is raised.
     |
     |      >>> pdeque([2, 1, 2]).remove(2)
     |      pdeque([1, 2])
     |
     |  reverse(self)
     |      Return reversed deque.
     |
     |      >>> pdeque([1, 2, 3]).reverse()
     |      pdeque([3, 2, 1])
     |
     |      Also supports the standard python reverse function.
     |
     |      >>> reversed(pdeque([1, 2, 3]))
     |      pdeque([3, 2, 1])
     |
     |  rotate(self, steps)
     |      Return deque with elements rotated steps steps.
     |
     |      >>> x = pdeque([1, 2, 3])
     |      >>> x.rotate(1)
     |      pdeque([3, 1, 2])
     |      >>> x.rotate(-2)
     |      pdeque([3, 1, 2])
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, left_list, right_list, length, maxlen=None)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties defined here:
     |
     |  left
     |      Leftmost element in dqueue.
     |
     |  maxlen
     |      Maximum length of the queue.
     |
     |  right
     |      Rightmost element in dqueue.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PList(_PListBase)
     |  PList(first, rest)
     |
     |  Classical Lisp style singly linked list. Adding elements to the head using cons is O(1).
     |  Element access is O(k) where k is the position of the element in the list. Taking the
     |  length of the list is O(n).
     |
     |  Fully supports the Sequence and Hashable protocols including indexing and slicing but
     |  if you need fast random access go for the PVector instead.
     |
     |  Do not instantiate directly, instead use the factory functions :py:func:`l` or :py:func:`plist` to
     |  create an instance.
     |
     |  Some examples:
     |
     |  >>> x = plist([1, 2])
     |  >>> y = x.cons(3)
     |  >>> x
     |  plist([1, 2])
     |  >>> y
     |  plist([3, 1, 2])
     |  >>> y.first
     |  3
     |  >>> y.rest == x
     |  True
     |  >>> y[:2]
     |  plist([3, 1])
     |
     |  Method resolution order:
     |      PList
     |      _PListBase
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __bool__(self)
     |
     |  __nonzero__ = __bool__(self)
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, first, rest)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  first
     |
     |  rest
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from _PListBase:
     |
     |  __eq__(self, other)
     |      Traverses the lists, checking equality of elements.
     |
     |      This is an O(n) operation, but preserves the standard semantics of list equality.
     |
     |  __getitem__(self, index)
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __len__(self)
     |      Return the length of the list, computed by traversing it.
     |
     |      This is obviously O(n) but with the current implementation
     |      where a list is also a node the overhead of storing the length
     |      in every node would be quite significant.
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __reversed__ = reverse(self)
     |
     |  __str__ = __repr__(self)
     |
     |  cons(self, elem)
     |      Return a new list with elem inserted as new head.
     |
     |      >>> plist([1, 2]).cons(3)
     |      plist([3, 1, 2])
     |
     |  count(self, value)
     |      S.count(value) -> integer -- return number of occurrences of value
     |
     |  index(self, value, start=0, stop=None)
     |      S.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |
     |      Supporting start and stop arguments is optional, but
     |      recommended.
     |
     |  mcons(self, iterable)
     |      Return a new list with all elements of iterable repeatedly cons:ed to the current list.
     |      NB! The elements will be inserted in the reverse order of the iterable.
     |      Runs in O(len(iterable)).
     |
     |      >>> plist([1, 2]).mcons([3, 4])
     |      plist([4, 3, 1, 2])
     |
     |  remove(self, elem)
     |      Return new list with first element equal to elem removed. O(k) where k is the position
     |      of the element that is removed.
     |
     |      Raises ValueError if no matching element is found.
     |
     |      >>> plist([1, 2, 1]).remove(1)
     |      plist([2, 1])
     |
     |  reverse(self)
     |      Return a reversed version of list. Runs in O(n) where n is the length of the list.
     |
     |      >>> plist([1, 2, 3]).reverse()
     |      plist([3, 2, 1])
     |
     |      Also supports the standard reversed function.
     |
     |      >>> reversed(plist([1, 2, 3]))
     |      plist([3, 2, 1])
     |
     |  split(self, index)
     |      Spilt the list at position specified by index. Returns a tuple containing the
     |      list up until index and the list after the index. Runs in O(index).
     |
     |      >>> plist([1, 2, 3, 4]).split(2)
     |      (plist([1, 2]), plist([3, 4]))
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _PListBase:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PMap(builtins.object)
     |  PMap(size, buckets)
     |
     |  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
     |
     |  Methods defined here:
     |
     |  __add__(self, other)
     |
     |  __contains__(self, key)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__ = __lt__(self, other)
     |
     |  __getattr__(self, key)
     |
     |  __getitem__(self, key)
     |
     |  __gt__ = __lt__(self, other)
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__ = __lt__(self, other)
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __ne__(self, value, /)
     |      Return self!=value.
     |
     |  __or__ = __add__(self, other)
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  copy(self)
     |
     |  discard(self, key)
     |      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
     |
     |  evolver(self)
     |      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.
     |
     |  get(self, key, default=None)
     |      D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
     |
     |  items(self)
     |
     |  iteritems(self)
     |
     |  iterkeys(self)
     |
     |  itervalues(self)
     |      # These are more efficient implementations compared to the original
     |      # methods that are based on the keys iterator and then calls the
     |      # accessor functions to access the value for the corresponding key
     |
     |  keys(self)
     |
     |  remove(self, key)
     |      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})
     |
     |  set(self, key, val)
     |      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
     |
     |  transform(self, *transformations)
     |      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
     |
     |  update(self, *maps)
     |      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
     |
     |  update_with(self, update_fn, *maps)
     |      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})
     |
     |  values(self)
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, size, buckets)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PRecord(pyrsistent._pmap.PMap, pyrsistent._checked_types.CheckedType)
     |  PRecord(**kwargs)
     |
     |  A PRecord is a PMap with a fixed set of specified fields. Records are declared as python classes inheriting
     |  from PRecord. Because it is a PMap it has full support for all Mapping methods such as iteration and element
     |  access using subscript notation.
     |
     |  More documentation and examples of PRecord usage is available at https://github.com/tobgu/pyrsistent
     |
     |  Method resolution order:
     |      PRecord
     |      pyrsistent._pmap.PMap
     |      pyrsistent._checked_types.CheckedType
     |      builtins.object
     |
     |  Methods defined here:
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  evolver(self)
     |      Returns an evolver of this object.
     |
     |  serialize(self, format=None)
     |      Serialize the current PRecord using custom serializer functions for fields where
     |      such have been supplied.
     |
     |  set(self, *args, **kwargs)
     |      Set a field in the record. This set function differs slightly from that in the PMap
     |      class. First of all it accepts key-value pairs. Second it accepts multiple key-value
     |      pairs to perform one, atomic, update of multiple fields.
     |
     |  ----------------------------------------------------------------------
     |  Class methods defined here:
     |
     |  create(kwargs, _factory_fields=None, ignore_extra=False) from pyrsistent._precord._PRecordMeta
     |      Factory method. Will create a new PRecord of the current type and assign the values
     |      specified in kwargs.
     |
     |      :param ignore_extra: A boolean which when set to True will ignore any keys which appear in kwargs that are not
     |                           in the set of fields on the PRecord.
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, **kwargs)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Methods inherited from pyrsistent._pmap.PMap:
     |
     |  __add__(self, other)
     |
     |  __contains__(self, key)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__ = __lt__(self, other)
     |
     |  __getattr__(self, key)
     |
     |  __getitem__(self, key)
     |
     |  __gt__ = __lt__(self, other)
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__ = __lt__(self, other)
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __ne__(self, value, /)
     |      Return self!=value.
     |
     |  __or__ = __add__(self, other)
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  copy(self)
     |
     |  discard(self, key)
     |      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
     |
     |  get(self, key, default=None)
     |      D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
     |
     |  items(self)
     |
     |  iteritems(self)
     |
     |  iterkeys(self)
     |
     |  itervalues(self)
     |      # These are more efficient implementations compared to the original
     |      # methods that are based on the keys iterator and then calls the
     |      # accessor functions to access the value for the corresponding key
     |
     |  keys(self)
     |
     |  remove(self, key)
     |      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})
     |
     |  transform(self, *transformations)
     |      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
     |
     |  update(self, *maps)
     |      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
     |
     |  update_with(self, update_fn, *maps)
     |      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})
     |
     |  values(self)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from pyrsistent._pmap.PMap:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PSet(builtins.object)
     |  PSet(m)
     |
     |  Persistent set implementation. Built on top of the persistent map. The set supports all operations
     |  in the Set protocol and is Hashable.
     |
     |  Do not instantiate directly, instead use the factory functions :py:func:`s` or :py:func:`pset`
     |  to create an instance.
     |
     |  Random access and insert is log32(n) where n is the size of the set.
     |
     |  Some examples:
     |
     |  >>> s = pset([1, 2, 3, 1])
     |  >>> s2 = s.add(4)
     |  >>> s3 = s2.remove(2)
     |  >>> s
     |  pset([1, 2, 3])
     |  >>> s2
     |  pset([1, 2, 3, 4])
     |  >>> s3
     |  pset([1, 3, 4])
     |
     |  Methods defined here:
     |
     |  __and__(self, other)
     |
     |  __contains__(self, element)
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __ge__(self, other)
     |      Return self>=value.
     |
     |  __gt__(self, other)
     |      Return self>value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __iter__(self)
     |
     |  __le__(self, other)
     |      Return self<=value.
     |
     |  __len__(self)
     |
     |  __lt__(self, other)
     |      Return self<value.
     |
     |  __ne__(self, value, /)
     |      Return self!=value.
     |
     |  __or__(self, other)
     |      Return self|value.
     |
     |  __reduce__(self)
     |      Helper for pickle.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  __str__(self)
     |      Return str(self).
     |
     |  __sub__(self, other)
     |
     |  __xor__(self, other)
     |
     |  add(self, element)
     |      Return a new PSet with element added
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.add(3)
     |      pset([1, 2, 3])
     |
     |  copy(self)
     |
     |  difference = __sub__(self, other)
     |
     |  discard(self, element)
     |      Return a new PSet with element removed. Returns itself if element is not present.
     |
     |  evolver(self)
     |      Create a new evolver for this pset. For a discussion on evolvers in general see the
     |      documentation for the pvector evolver.
     |
     |      Create the evolver and perform various mutating updates to it:
     |
     |      >>> s1 = s(1, 2, 3)
     |      >>> e = s1.evolver()
     |      >>> _ = e.add(4)
     |      >>> len(e)
     |      4
     |      >>> _ = e.remove(1)
     |
     |      The underlying pset remains the same:
     |
     |      >>> s1
     |      pset([1, 2, 3])
     |
     |      The changes are kept in the evolver. An updated pmap can be created using the
     |      persistent() function on the evolver.
     |
     |      >>> s2 = e.persistent()
     |      >>> s2
     |      pset([2, 3, 4])
     |
     |      The new pset will share data with the original pset in the same way that would have
     |      been done if only using operations on the pset.
     |
     |  intersection = __and__(self, other)
     |
     |  isdisjoint(self, other)
     |      Return True if two sets have a null intersection.
     |
     |  issubset = __le__(self, other)
     |
     |  issuperset = __ge__(self, other)
     |
     |  remove(self, element)
     |      Return a new PSet with element removed. Raises KeyError if element is not present.
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.remove(2)
     |      pset([1])
     |
     |  symmetric_difference = __xor__(self, other)
     |
     |  union = __or__(self, other)
     |
     |  update(self, iterable)
     |      Return a new PSet with elements in iterable added
     |
     |      >>> s1 = s(1, 2)
     |      >>> s1.update([3, 4, 4])
     |      pset([1, 2, 3, 4])
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(cls, m)
     |      Create and return a new object.  See help(type) for accurate signature.
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __weakref__
     |      list of weak references to the object (if defined)

    class PVector(builtins.object)
     |  Persistent vector implementation. Meant as a replacement for the cases where you would normally
     |  use a Python list.
     |
     |  Do not instantiate directly, instead use the factory functions :py:func:`v` and :py:func:`pvector` to
     |  create an instance.
     |
     |  Heavily influenced by the persistent vector available in Clojure. Initially this was more or
     |  less just a port of the Java code for the Clojure vector. It has since been modified and to
     |  some extent optimized for usage in Python.
     |
     |  The vector is organized as a trie, any mutating method will return a new vector that contains the changes. No
     |  updates are done to the original vector. Structural sharing between vectors are applied where possible to save
     |  space and to avoid making complete copies.
     |
     |  This structure corresponds most closely to the built in list 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.
     |
     |  The PVector implements the Sequence protocol and is Hashable.
     |
     |  Inserts are amortized O(1). Random access is log32(n) where n is the size of the vector.
     |
     |  The following are examples of some common operations on persistent vectors:
     |
     |  >>> p = v(1, 2, 3)
     |  >>> p2 = p.append(4)
     |  >>> p3 = p2.extend([5, 6, 7])
     |  >>> p
     |  pvector([1, 2, 3])
     |  >>> p2
     |  pvector([1, 2, 3, 4])
     |  >>> p3
     |  pvector([1, 2, 3, 4, 5, 6, 7])
     |  >>> p3[5]
     |  6
     |  >>> p.set(1, 99)
     |  pvector([1, 99, 3])
     |  >>>
     |
     |  Methods defined here:
     |
     |  __add__(self, other)
     |      >>> v1 = v(1, 2)
     |      >>> v2 = v(3, 4)
     |      >>> v1 + v2
     |      pvector([1, 2, 3, 4])
     |
     |  __getitem__(self, index)
     |      Get value at index. Full slicing support.
     |
     |      >>> v1 = v(5, 6, 7, 8)
     |      >>> v1[2]
     |      7
     |      >>> v1[1:3]
     |      pvector([6, 7])
     |
     |  __hash__(self)
     |      >>> v1 = v(1, 2, 3)
     |      >>> v2 = v(1, 2, 3)
     |      >>> hash(v1) == hash(v2)
     |      True
     |
     |  __len__(self)
     |      >>> len(v(1, 2, 3))
     |      3
     |
     |  __mul__(self, times)
     |      >>> v1 = v(1, 2)
     |      >>> 3 * v1
     |      pvector([1, 2, 1, 2, 1, 2])
     |
     |  append(self, val)
     |      Return a new vector with val appended.
     |
     |      >>> v1 = v(1, 2)
     |      >>> v1.append(3)
     |      pvector([1, 2, 3])
     |
     |  count(self, value)
     |      Return the number of times that value appears in the vector.
     |
     |      >>> v1 = v(1, 4, 3, 4)
     |      >>> v1.count(4)
     |      2
     |
     |  delete(self, index, stop=None)
     |      Delete a portion of the vector by index or range.
     |
     |      >>> v1 = v(1, 2, 3, 4, 5)
     |      >>> v1.delete(1)
     |      pvector([1, 3, 4, 5])
     |      >>> v1.delete(1, 3)
     |      pvector([1, 4, 5])
     |
     |  evolver(self)
     |      Create a new evolver for this pvector. The evolver acts as a mutable view of the vector
     |      with "transaction like" semantics. No part of the underlying vector i updated, it is still
     |      fully immutable. Furthermore multiple evolvers created from the same pvector do not
     |      interfere with each other.
     |
     |      You may want to use an evolver instead of working directly with the pvector in the
     |      following cases:
     |
     |      * Multiple updates are done to the same vector and the intermediate results are of no
     |        interest. In this case using an evolver may be a more efficient and easier to work with.
     |      * You need to pass a vector into a legacy function or a function that you have no control
     |        over which performs in place mutations of lists. In this case pass an evolver instance
     |        instead and then create a new pvector from the evolver once the function returns.
     |
     |      The following example illustrates a typical workflow when working with evolvers. It also
     |      displays most of the API (which i kept small by design, you should not be tempted to
     |      use evolvers in excess ;-)).
     |
     |      Create the evolver and perform various mutating updates to it:
     |
     |      >>> v1 = v(1, 2, 3, 4, 5)
     |      >>> e = v1.evolver()
     |      >>> e[1] = 22
     |      >>> _ = e.append(6)
     |      >>> _ = e.extend([7, 8, 9])
     |      >>> e[8] += 1
     |      >>> len(e)
     |      9
     |
     |      The underlying pvector remains the same:
     |
     |      >>> v1
     |      pvector([1, 2, 3, 4, 5])
     |
     |      The changes are kept in the evolver. An updated pvector can be created using the
     |      persistent() function on the evolver.
     |
     |      >>> v2 = e.persistent()
     |      >>> v2
     |      pvector([1, 22, 3, 4, 5, 6, 7, 8, 10])
     |
     |      The new pvector will share data with the original pvector in the same way that would have
     |      been done if only using operations on the pvector.
     |
     |  extend(self, obj)
     |      Return a new vector with all values in obj appended to it. Obj may be another
     |      PVector or any other Iterable.
     |
     |      >>> v1 = v(1, 2, 3)
     |      >>> v1.extend([4, 5])
     |      pvector([1, 2, 3, 4, 5])
     |
     |  index(self, value, *args, **kwargs)
     |      Return first index of value. Additional indexes may be supplied to limit the search to a
     |      sub range of the vector.
     |
     |      >>> v1 = v(1, 2, 3, 4, 3)
     |      >>> v1.index(3)
     |      2
     |      >>> v1.index(3, 3, 5)
     |      4
     |
     |  mset(self, *args)
     |      Return a new vector with elements in specified positions replaced by values (multi set).
     |
     |      Elements on even positions in the argument list are interpreted as indexes while
     |      elements on odd positions are considered values.
     |
     |      >>> v1 = v(1, 2, 3)
     |      >>> v1.mset(0, 11, 2, 33)
     |      pvector([11, 2, 33])
     |
     |  remove(self, value)
     |      Remove the first occurrence of a value from the vector.
     |
     |      >>> v1 = v(1, 2, 3, 2, 1)
     |      >>> v2 = v1.remove(1)
     |      >>> v2
     |      pvector([2, 3, 2, 1])
     |      >>> v2.remove(1)
     |      pvector([2, 3, 2])
     |
     |  set(self, i, val)
     |      Return a new vector with element at position i replaced with val. The original vector remains unchanged.
     |
     |      Setting a value one step beyond the end of the vector is equal to appending. Setting beyond that will
     |      result in an IndexError.
     |
     |      >>> v1 = v(1, 2, 3)
     |      >>> v1.set(1, 4)
     |      pvector([1, 4, 3])
     |      >>> v1.set(3, 4)
     |      pvector([1, 2, 3, 4])
     |      >>> v1.set(-1, 4)
     |      pvector([1, 2, 4])
     |
     |  transform(self, *transformations)
     |      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
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __abstractmethods__ = frozenset({'__add__', '__getitem__', '__hash__',...

FUNCTIONS
    b(*elements)
        Construct a persistent bag.

        Takes an arbitrary number of arguments to insert into the new persistent
        bag.

        >>> b(1, 2, 3, 2)
        pbag([1, 2, 2, 3])

    discard(evolver, key)
        Discard the element and returns a structure without the discarded elements

    dq(*elements)
        Return deque containing all arguments.

        >>> dq(1, 2, 3)
        pdeque([1, 2, 3])

    field(type=(), invariant=<function <lambda> at 0x7f8c1b315ab0>, initial=<object object at 0x7f8c1b7d4b10>, mandatory=False, factory=<function <lambda> at 0x7f8c1b315c60>, serializer=<function <lambda> at 0x7f8c1b315cf0>)
        Field specification factory for :py:class:`PRecord`.

        :param type: a type or iterable with types that are allowed for this field
        :param invariant: a function specifying an invariant that must hold for the field
        :param initial: value of field if not specified when instantiating the record
        :param mandatory: boolean specifying if the field is mandatory or not
        :param factory: function called when field is set.
        :param serializer: function that returns a serialized version of the field

    freeze(o, strict=True)
        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.

        If strict == True (default):

        - freeze is called on elements of pvectors
        - freeze is called on values of pmaps

        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([]))

    get_in(keys, coll, default=None, no_default=False)
        NB: This is a straight copy of the get_in implementation found in
            the toolz library (https://github.com/pytoolz/toolz/). It works
            with persistent data structures as well as the corresponding
            datastructures from the stdlib.

        Returns coll[i0][i1]...[iX] where [i0, i1, ..., iX]==keys.

        If coll[i0][i1]...[iX] cannot be found, returns ``default``, unless
        ``no_default`` is specified, then it raises KeyError or IndexError.

        ``get_in`` is a generalization of ``operator.getitem`` for nested data
        structures such as dictionaries and lists.
        >>> from pyrsistent import freeze
        >>> transaction = freeze({'name': 'Alice',
        ...                       'purchase': {'items': ['Apple', 'Orange'],
        ...                                    'costs': [0.50, 1.25]},
        ...                       'credit card': '5555-1234-1234-1234'})
        >>> get_in(['purchase', 'items', 0], transaction)
        'Apple'
        >>> get_in(['name'], transaction)
        'Alice'
        >>> get_in(['purchase', 'total'], transaction)
        >>> get_in(['purchase', 'items', 'apple'], transaction)
        >>> get_in(['purchase', 'items', 10], transaction)
        >>> get_in(['purchase', 'total'], transaction, 0)
        0
        >>> get_in(['y'], {}, no_default=True)
        Traceback (most recent call last):
            ...
        KeyError: 'y'

    immutable(members='', name='Immutable', verbose=False)
        Produces a class that either can be used standalone or as a base class for persistent classes.

        This is a thin wrapper around a named tuple.

        Constructing a type and using it to instantiate objects:

        >>> Point = immutable('x, y', name='Point')
        >>> p = Point(1, 2)
        >>> p2 = p.set(x=3)
        >>> p
        Point(x=1, y=2)
        >>> p2
        Point(x=3, y=2)

        Inheriting from a constructed type. In this case no type name needs to be supplied:

        >>> class PositivePoint(immutable('x, y')):
        ...     __slots__ = tuple()
        ...     def __new__(cls, x, y):
        ...         if x > 0 and y > 0:
        ...             return super(PositivePoint, cls).__new__(cls, x, y)
        ...         raise Exception('Coordinates must be positive!')
        ...
        >>> p = PositivePoint(1, 2)
        >>> p.set(x=3)
        PositivePoint(x=3, y=2)
        >>> p.set(y=-3)
        Traceback (most recent call last):
        Exception: Coordinates must be positive!

        The persistent class also supports the notion of frozen members. The value of a frozen member
        cannot be updated. For example it could be used to implement an ID that should remain the same
        over time. A frozen member is denoted by a trailing underscore.

        >>> Point = immutable('x, y, id_', name='Point')
        >>> p = Point(1, 2, id_=17)
        >>> p.set(x=3)
        Point(x=3, y=2, id_=17)
        >>> p.set(id_=18)
        Traceback (most recent call last):
        AttributeError: Cannot set frozen members id_

    inc(x)
        Add one to the current value

    l(*elements)
        Creates a new persistent list containing all arguments.

        >>> l(1, 2, 3)
        plist([1, 2, 3])

    m(**kwargs)
        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

    mutant(fn)
        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.

    ny(_)
        Matcher that matches any value

    optional(*typs)
        Convenience function to specify that a value may be of any of the types in type 'typs' or None

    pbag(elements)
        Convert an iterable to a persistent bag.

        Takes an iterable with elements to insert.

        >>> pbag([1, 2, 3, 2])
        pbag([1, 2, 2, 3])

    pdeque(iterable=(), maxlen=None)
        Return deque containing the elements of iterable. If maxlen is specified then
        len(iterable) - maxlen elements are discarded from the left to if len(iterable) > maxlen.

        >>> pdeque([1, 2, 3])
        pdeque([1, 2, 3])
        >>> pdeque([1, 2, 3, 4], maxlen=2)
        pdeque([3, 4], maxlen=2)

    plist(iterable=(), reverse=False)
        Creates a new persistent list containing all elements of iterable.
        Optional parameter reverse specifies if the elements should be inserted in
        reverse order or not.

        >>> plist([1, 2, 3])
        plist([1, 2, 3])
        >>> plist([1, 2, 3], reverse=True)
        plist([3, 2, 1])

    pmap(initial={}, pre_size=0)
        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

    pmap_field(key_type, value_type, optional=False, invariant=<function <lambda> at 0x7f8c1b315ab0>)
        Create a checked ``PMap`` field.

        :param key: The required type for the keys of the map.
        :param value: The required type for the values of the map.
        :param optional: If true, ``None`` can be used as a value for
            this field.
        :param invariant: Pass-through to ``field``.

        :return: A ``field`` containing a ``CheckedPMap``.

    pset(iterable=(), pre_size=8)
        Creates a persistent set from iterable. Optionally takes a sizing parameter equivalent to that
        used for :py:func:`pmap`.

        >>> s1 = pset([1, 2, 3, 2])
        >>> s1
        pset([1, 2, 3])

    pset_field(item_type, optional=False, initial=(), invariant=<function <lambda> at 0x7f8c1b315ab0>, item_invariant=<function <lambda> at 0x7f8c1b315ab0>)
        Create checked ``PSet`` field.

        :param item_type: The required type for the items in the set.
        :param optional: If true, ``None`` can be used as a value for
            this field.
        :param initial: Initial value to pass to factory if no value is given
            for the field.

        :return: A ``field`` containing a ``CheckedPSet`` of the given type.

    pvector(...)
        pvector([iterable])
        Create a new persistent vector containing the elements in iterable.

        >>> v1 = pvector([1, 2, 3])
        >>> v1
        pvector([1, 2, 3])

    pvector_field(item_type, optional=False, initial=(), invariant=<function <lambda> at 0x7f8c1b315ab0>, item_invariant=<function <lambda> at 0x7f8c1b315ab0>)
        Create checked ``PVector`` field.

        :param item_type: The required type for the items in the vector.
        :param optional: If true, ``None`` can be used as a value for
            this field.
        :param initial: Initial value to pass to factory if no value is given
            for the field.

        :return: A ``field`` containing a ``CheckedPVector`` of the given type.

    rex(expr)
        Regular expression matcher to use together with transform functions

    s(*elements)
        Create a persistent set.

        Takes an arbitrary number of arguments to insert into the new set.

        >>> s1 = s(1, 2, 3, 2)
        >>> s1
        pset([1, 2, 3])

    thaw(o, strict=True)
        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.

        If strict == True (the default):

        - thaw is called on elements of lists
        - thaw is called on values in dicts

        >>> from pyrsistent import s, m, v
        >>> thaw(s(1, 2))
        {1, 2}
        >>> thaw(v(1, m(a=3)))
        [1, {'a': 3}]
        >>> thaw((1, v()))
        (1, [])

    v(*elements)
        Create a new persistent vector containing all parameters to this function.

        >>> v1 = v(1, 2, 3)
        >>> v1
        pvector([1, 2, 3])

DATA
    __all__ = ('pmap', 'm', 'PMap', 'pvector', 'v', 'PVector', 'pset', 's'...

FILE
    /usr/lib/python3/dist-packages/pyrsistent/__init__.py



Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 TransitionalValid CSS!

^_back to top