README.rst 2.9 KB

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