DESCRIPTION.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. Toolz
  2. =====
  3. |Build Status| |Coverage Status| |Version Status| |Downloads|
  4. A set of utility functions for iterators, functions, and dictionaries.
  5. See the PyToolz documentation at https://toolz.readthedocs.io
  6. LICENSE
  7. -------
  8. New BSD. See `License File <https://github.com/pytoolz/toolz/blob/master/LICENSE.txt>`__.
  9. Install
  10. -------
  11. ``toolz`` is on the Python Package Index (PyPI):
  12. ::
  13. pip install toolz
  14. Structure and Heritage
  15. ----------------------
  16. ``toolz`` is implemented in three parts:
  17. |literal itertoolz|_, for operations on iterables. Examples: ``groupby``,
  18. ``unique``, ``interpose``,
  19. |literal functoolz|_, for higher-order functions. Examples: ``memoize``,
  20. ``curry``, ``compose``
  21. |literal dicttoolz|_, for operations on dictionaries. Examples: ``assoc``,
  22. ``update-in``, ``merge``.
  23. .. |literal itertoolz| replace:: ``itertoolz``
  24. .. _literal itertoolz: https://github.com/pytoolz/toolz/blob/master/toolz/itertoolz.py
  25. .. |literal functoolz| replace:: ``functoolz``
  26. .. _literal functoolz: https://github.com/pytoolz/toolz/blob/master/toolz/functoolz.py
  27. .. |literal dicttoolz| replace:: ``dicttoolz``
  28. .. _literal dicttoolz: https://github.com/pytoolz/toolz/blob/master/toolz/dicttoolz.py
  29. These functions come from the legacy of functional languages for list
  30. processing. They interoperate well to accomplish common complex tasks.
  31. Read our `API
  32. Documentation <https://toolz.readthedocs.io/en/latest/api.html>`__ for
  33. more details.
  34. Example
  35. -------
  36. This builds a standard wordcount function from pieces within ``toolz``:
  37. .. code:: python
  38. >>> def stem(word):
  39. ... """ Stem word to primitive form """
  40. ... return word.lower().rstrip(",.!:;'-\"").lstrip("'\"")
  41. >>> from toolz import compose, frequencies, partial
  42. >>> from toolz.curried import map
  43. >>> wordcount = compose(frequencies, map(stem), str.split)
  44. >>> sentence = "This cat jumped over this other cat!"
  45. >>> wordcount(sentence)
  46. {'this': 2, 'cat': 2, 'jumped': 1, 'over': 1, 'other': 1}
  47. Dependencies
  48. ------------
  49. ``toolz`` supports Python 2.6+ and Python 3.3+ with a common codebase.
  50. It is pure Python and requires no dependencies beyond the standard
  51. library.
  52. It is, in short, a light weight dependency.
  53. CyToolz
  54. -------
  55. The ``toolz`` project has been reimplemented in `Cython <http://cython.org>`__.
  56. The ``cytoolz`` project is a drop-in replacement for the Pure Python
  57. implementation.
  58. See `CyToolz Github Page <https://github.com/pytoolz/cytoolz/>`__ for more
  59. details.
  60. See Also
  61. --------
  62. - `Underscore.js <http://underscorejs.org>`__: A similar library for
  63. JavaScript
  64. - `Enumerable <http://ruby-doc.org/core-2.0.0/Enumerable.html>`__: A
  65. similar library for Ruby
  66. - `Clojure <http://clojure.org>`__: A functional language whose
  67. standard library has several counterparts in ``toolz``
  68. - `itertools <http://docs.python.org/2/library/itertools.html>`__: The
  69. Python standard library for iterator tools
  70. - `functools <http://docs.python.org/2/library/functools.html>`__: The
  71. Python standard library for function tools
  72. Contributions Welcome
  73. ---------------------
  74. ``toolz`` aims to be a repository for utility functions, particularly
  75. those that come from the functional programming and list processing
  76. traditions. We welcome contributions that fall within this scope.
  77. We also try to keep the API small to keep ``toolz`` manageable. The ideal
  78. contribution is significantly different from existing functions and has
  79. precedent in a few other functional systems.
  80. Please take a look at our
  81. `issue page <https://github.com/pytoolz/toolz/issues>`__
  82. for contribution ideas.
  83. Community
  84. ---------
  85. See our `mailing list <https://groups.google.com/forum/#!forum/pytoolz>`__.
  86. We're friendly.
  87. .. |Build Status| image:: https://travis-ci.org/pytoolz/toolz.svg?branch=master
  88. :target: https://travis-ci.org/pytoolz/toolz
  89. .. |Coverage Status| image:: https://coveralls.io/repos/pytoolz/toolz/badge.svg?branch=master
  90. :target: https://coveralls.io/r/pytoolz/toolz
  91. .. |Version Status| image:: https://badge.fury.io/py/toolz.svg
  92. :target: http://badge.fury.io/py/toolz
  93. .. |Downloads| image:: https://img.shields.io/pypi/dm/toolz.svg
  94. :target: https://pypi.python.org/pypi/toolz/