README.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. =========
  2. multidict
  3. =========
  4. .. image:: https://github.com/aio-libs/multidict/actions/workflows/ci-cd.yml/badge.svg
  5. :target: https://github.com/aio-libs/multidict/actions
  6. :alt: GitHub status for master branch
  7. .. image:: https://codecov.io/gh/aio-libs/multidict/branch/master/graph/badge.svg
  8. :target: https://codecov.io/gh/aio-libs/multidict
  9. :alt: Coverage metrics
  10. .. image:: https://img.shields.io/pypi/v/multidict.svg
  11. :target: https://pypi.org/project/multidict
  12. :alt: PyPI
  13. .. image:: https://readthedocs.org/projects/multidict/badge/?version=latest
  14. :target: https://multidict.aio-libs.org
  15. :alt: Read The Docs build status badge
  16. .. image:: https://img.shields.io/pypi/pyversions/multidict.svg
  17. :target: https://pypi.org/project/multidict
  18. :alt: Python versions
  19. .. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
  20. :target: https://matrix.to/#/%23aio-libs:matrix.org
  21. :alt: Matrix Room — #aio-libs:matrix.org
  22. .. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
  23. :target: https://matrix.to/#/%23aio-libs-space:matrix.org
  24. :alt: Matrix Space — #aio-libs-space:matrix.org
  25. Multidict is dict-like collection of *key-value pairs* where key
  26. might occur more than once in the container.
  27. Introduction
  28. ------------
  29. *HTTP Headers* and *URL query string* require specific data structure:
  30. *multidict*. It behaves mostly like a regular ``dict`` but it may have
  31. several *values* for the same *key* and *preserves insertion ordering*.
  32. The *key* is ``str`` (or ``istr`` for case-insensitive dictionaries).
  33. ``multidict`` has four multidict classes:
  34. ``MultiDict``, ``MultiDictProxy``, ``CIMultiDict``
  35. and ``CIMultiDictProxy``.
  36. Immutable proxies (``MultiDictProxy`` and
  37. ``CIMultiDictProxy``) provide a dynamic view for the
  38. proxied multidict, the view reflects underlying collection changes. They
  39. implement the ``collections.abc.Mapping`` interface.
  40. Regular mutable (``MultiDict`` and ``CIMultiDict``) classes
  41. implement ``collections.abc.MutableMapping`` and allows them to change
  42. their own content.
  43. *Case insensitive* (``CIMultiDict`` and
  44. ``CIMultiDictProxy``) assume the *keys* are case
  45. insensitive, e.g.::
  46. >>> dct = CIMultiDict(key='val')
  47. >>> 'Key' in dct
  48. True
  49. >>> dct['Key']
  50. 'val'
  51. *Keys* should be ``str`` or ``istr`` instances.
  52. The library has optional C Extensions for speed.
  53. License
  54. -------
  55. Apache 2
  56. Library Installation
  57. --------------------
  58. .. code-block:: bash
  59. $ pip install multidict
  60. The library is Python 3 only!
  61. PyPI contains binary wheels for Linux, Windows and MacOS. If you want to install
  62. ``multidict`` on another operating system (or *Alpine Linux* inside a Docker) the
  63. tarball will be used to compile the library from source. It requires a C compiler and
  64. Python headers to be installed.
  65. To skip the compilation, please use the `MULTIDICT_NO_EXTENSIONS` environment variable,
  66. e.g.:
  67. .. code-block:: bash
  68. $ MULTIDICT_NO_EXTENSIONS=1 pip install multidict
  69. Please note, the pure Python (uncompiled) version is about 20-50 times slower depending on
  70. the usage scenario!!!
  71. Changelog
  72. ---------
  73. See `RTD page <http://multidict.aio-libs.org/en/latest/changes>`_.