Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
e221dc5
implement Compose.__repr__
May 16, 2018
ba50667
implement Compose equality
May 17, 2018
3ded3fc
refactor Compose.__repr__
May 17, 2018
d39d1ab
implement compose.__hash__
May 17, 2018
9e878e1
Compose now acts as method when bound to a class
May 17, 2018
5d95878
implement Compose.__wrapped__
May 17, 2018
ad9f297
implement basic Compose.__signature__
May 17, 2018
8aaf970
extend Compose.__signature__ tests
May 17, 2018
937de13
add clarifying comment
May 17, 2018
c10bbbe
add coverage exemptions
May 23, 2018
d7b8c40
set annotations in tests in python2-compatible manner
May 23, 2018
3ef3de7
remove signature exception propagation test.
May 23, 2018
a33b578
Avoid using .index()
groutr Jun 5, 2018
90ea648
Try to find first index of no_pad more intelligently.
groutr Jun 5, 2018
c323698
len(prev) == n
groutr Jun 5, 2018
0b24bb1
Add regression test.
groutr Jun 6, 2018
0373145
Fix comments to make pep8 happy.
groutr Jun 6, 2018
5b0e57b
drop py26 and py33 support
Jun 6, 2018
7534eef
Remove added whitespace from tests.
groutr Jun 6, 2018
86953ab
Test both fast and slow paths and make sure they give same result.
groutr Jun 6, 2018
2bd9139
Merge pull request #399 from groutr/fix-partition-all
eriknw Jun 13, 2018
d1e8082
python3.7 generator expression fix
kalefranz Jul 6, 2018
c789e3c
Merge pull request #405 from kalefranz/py37-generator-expession-fix
eriknw Jul 6, 2018
2673126
Point to itertoolz and functoolz at mrocklin's GitHub account
florisla Jul 10, 2018
c27c178
Change HTTP links to use HTTPS
florisla Jul 10, 2018
4ea6619
Avoid overhead of islice.
groutr Aug 10, 2018
a69f8a5
Fix accumulate for Python 3.7
groutr Aug 14, 2018
2bf9e8b
Merge pull request #410 from groutr/fix-accumulate-3.7
eriknw Aug 14, 2018
2c1dabb
Merge pull request #407 from florisla/fix-heritage-links
eriknw Aug 14, 2018
701712f
Handle StopIteration in Python 3.7+
groutr Aug 15, 2018
307b0bb
Revert "Handle StopIteration in Python 3.7+"
groutr Aug 15, 2018
68d8df8
Merge pull request #408 from groutr/faster-second
eriknw Aug 15, 2018
5b222b3
added clojure style function
Aug 16, 2018
89665af
test for apply
Aug 16, 2018
eb26030
More efficient assoc.
groutr Aug 24, 2018
b791293
Remove broken download badge
hugovk Sep 27, 2018
bb7ff0b
Add support for Python 3.7
hugovk Sep 27, 2018
76b6b28
Drop support for EOL Python 2.6 and 3.3
hugovk Sep 27, 2018
04855e5
Use 'is None' rather than equality comparison
hugovk Sep 27, 2018
ddd428a
Remove redundant parentheses
hugovk Sep 27, 2018
7fe24c9
Add python_requires to help pip
hugovk Sep 27, 2018
8851fcc
Upgrade Python syntax with pyupgrade (but not % formatting)
hugovk Oct 6, 2018
062786a
Merge pull request #412 from groutr/faster_assoc
eriknw Oct 8, 2018
a6665b1
Make dissoc smarter.
groutr Oct 18, 2018
d55666d
Remove import.
groutr Oct 18, 2018
03cf714
Fix indentation error.
groutr Oct 18, 2018
c6a2779
Add dissoc to curried namespace.
groutr Oct 19, 2018
18947fe
Avoid error catching inside loop for significant performance gain.
groutr Nov 3, 2018
afd126f
On Python 2, don't create a copy of the dictionary items.
groutr Nov 3, 2018
33c6687
Detect join case and perform each case separately.
groutr Nov 7, 2018
a99299e
Restore identity comparisons.
groutr Nov 8, 2018
9ffd119
Adjust line breaks to 79 characters.
groutr Nov 8, 2018
663d57a
Merge pull request #422 from hugovk/rm-eol2
eriknw Nov 13, 2018
8fa7ec4
Merge pull request #416 from hugovk/add-3.7
eriknw Nov 13, 2018
752bc21
Merge pull request #415 from hugovk/rm-broken-badge
eriknw Nov 13, 2018
01e4313
Fix DeprecationWarning in Python 3.7
hugovk Oct 6, 2018
cb94a5b
Ignore file created when running tests
hugovk Oct 6, 2018
e9cea93
Don't cover non-runnable code on Python 3
hugovk Oct 6, 2018
a055df3
Ignore file created when running tests with coverage
hugovk Oct 6, 2018
1804af0
Move compat code to compatibility.py
hugovk Nov 13, 2018
68a3591
change signature of `apply` as per @eriknw
Nov 23, 2018
dcebedd
add apply to toolz.curried
Nov 23, 2018
4d67092
add apply to toolz.curried
Nov 23, 2018
65c81ca
format __all__ to fit in line breaks
Nov 23, 2018
4704748
complete code coverage
Nov 23, 2018
62a6869
Add hint for groupby to documentation
lumbric Nov 30, 2018
6019234
Fix wrong docstring for unzip()
lumbric Nov 30, 2018
ba9d148
Use a non-recursive implementation inspired by cytoolz.
groutr Dec 6, 2018
0217f38
Remove unnecessary parens.
groutr Dec 6, 2018
54aa442
Avoid lookups for set.add method.
groutr Dec 6, 2018
b2eb929
Fix linting error.
groutr Dec 6, 2018
f058785
Update tests for dissoc to use factory keyword argument.
groutr Dec 6, 2018
5360b15
Merge pull request #423 from hugovk/fix-deprecation-warning
eriknw Dec 6, 2018
40ac543
DOC/BUG: fix import so in memory split-apply-combine example runs
dlovell Dec 23, 2018
41a382b
fix memory leak
EricTheMagician Jan 10, 2019
cc49f89
Remove unecessary definitions of exceptions
EricTheMagician Jan 21, 2019
2a6ef53
Merge pull request #437 from thejinx0r/master
eriknw Jan 21, 2019
f25bc8e
Update streaming-analytics.rst
mrshu Apr 2, 2019
ee962d8
Merge pull request #443 from mrshu/patch-1
eriknw Jun 22, 2019
0da106d
Merge pull request #435 from dlovell/streaming-analytics-doc-bug
eriknw Jun 22, 2019
4e0e819
Merge pull request #432 from lumbric/unzip_documentation_fix
eriknw Jun 22, 2019
04adf41
Merge pull request #431 from lumbric/master
eriknw Jun 22, 2019
cde596b
Merge pull request #433 from groutr/faster_update_in
eriknw Jun 22, 2019
2ac03ce
Merge pull request #428 from groutr/faster_join
eriknw Jun 22, 2019
639043e
Merge pull request #411 from eliasmistler/master
eriknw Jun 22, 2019
7b6570a
Added peekn
MitalAshok Aug 31, 2017
9e97f73
Write pipeline function, with tests
samfrances Jun 30, 2019
9808e49
Correct failing doctest
samfrances Jun 30, 2019
3f4f601
Convert pipeline() tests from pytest to nose
samfrances Jun 30, 2019
44983f7
Correct docstring for pipeline()
samfrances Jul 1, 2019
1c07bc3
Rename pipline() to compose_left()
samfrances Jul 8, 2019
1ef435f
Add compose_left to toolz.curried
samfrances Jul 8, 2019
e8989cf
Merge pull request #451 from samfrances/pipeline
eriknw Jul 8, 2019
020161b
Merge pull request #381 from MitalAshok/peekn
eriknw Jul 9, 2019
1b23ada
Merge pull request #425 from groutr/faster-dissoc
eriknw Jul 9, 2019
7764358
Merge branch 'compose-improvements' of https://github.com/ariebovenbe…
eriknw Jul 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .binstar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ platform:
- win-64
- win-32
engine:
- python=2.6
- python=2.7
- python=3.3
- python=3.4
script:
- conda build conda.recipe
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
build/
dist/
*.egg-info/
bench/shakespeare.txt
.coverage
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
sudo: false
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"
- "pypy"

# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs
matrix:
include:
- python: 3.7
dist: xenial
sudo: true

env:
- PEP8_IGNORE="E731,W503,E402"

matrix:
allow_failures:
- python: "3.7-dev"

# command to install dependencies
install:
- pip install coverage pep8 pytest
Expand Down
24 changes: 11 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Toolz
=====

|Build Status| |Coverage Status| |Version Status| |Downloads|
|Build Status| |Coverage Status| |Version Status|

A set of utility functions for iterators, functions, and dictionaries.

Expand Down Expand Up @@ -30,7 +30,7 @@ Structure and Heritage
``unique``, ``interpose``,

|literal functoolz|_, for higher-order functions. Examples: ``memoize``,
``curry``, ``compose``
``curry``, ``compose``,

|literal dicttoolz|_, for operations on dictionaries. Examples: ``assoc``,
``update-in``, ``merge``.
Expand Down Expand Up @@ -73,11 +73,11 @@ This builds a standard wordcount function from pieces within ``toolz``:
Dependencies
------------

``toolz`` supports Python 2.6+ and Python 3.3+ with a common codebase.
``toolz`` supports Python 2.7 and Python 3.4+ with a common codebase.
It is pure Python and requires no dependencies beyond the standard
library.

It is, in short, a light weight dependency.
It is, in short, a lightweight dependency.


CyToolz
Expand All @@ -86,21 +86,21 @@ CyToolz
The ``toolz`` project has been reimplemented in `Cython <http://cython.org>`__.
The ``cytoolz`` project is a drop-in replacement for the Pure Python
implementation.
See `CyToolz Github Page <https://github.com/pytoolz/cytoolz/>`__ for more
See `CyToolz GitHub Page <https://github.com/pytoolz/cytoolz/>`__ for more
details.

See Also
--------

- `Underscore.js <http://underscorejs.org>`__: A similar library for
- `Underscore.js <https://underscorejs.org/>`__: A similar library for
JavaScript
- `Enumerable <http://ruby-doc.org/core-2.0.0/Enumerable.html>`__: A
- `Enumerable <https://ruby-doc.org/core-2.0.0/Enumerable.html>`__: A
similar library for Ruby
- `Clojure <http://clojure.org>`__: A functional language whose
- `Clojure <https://clojure.org/>`__: A functional language whose
standard library has several counterparts in ``toolz``
- `itertools <http://docs.python.org/2/library/itertools.html>`__: The
- `itertools <https://docs.python.org/2/library/itertools.html>`__: The
Python standard library for iterator tools
- `functools <http://docs.python.org/2/library/functools.html>`__: The
- `functools <https://docs.python.org/2/library/functools.html>`__: The
Python standard library for function tools

Contributions Welcome
Expand Down Expand Up @@ -129,6 +129,4 @@ We're friendly.
.. |Coverage Status| image:: https://coveralls.io/repos/pytoolz/toolz/badge.svg?branch=master
:target: https://coveralls.io/r/pytoolz/toolz
.. |Version Status| image:: https://badge.fury.io/py/toolz.svg
:target: http://badge.fury.io/py/toolz
.. |Downloads| image:: https://img.shields.io/pypi/dm/toolz.svg
:target: https://pypi.python.org/pypi/toolz/
:target: https://badge.fury.io/py/toolz
1 change: 1 addition & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Itertoolz
partition
partition_all
peek
peekn
pluck
random_sample
reduceby
Expand Down
16 changes: 8 additions & 8 deletions doc/source/heritage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ philosophy but mimics declarative database languages rather than functional
ones. Enumerable_ is is the closest project in Ruby. Other excellent projects
also exist within the Python ecosystem, most notably Fn.py_ and Funcy_.

.. [itertools] http://docs.python.org/2/library/itertools.html
.. [functools] http://docs.python.org/2/library/functools.html
.. [itertoolz] http://github.com/pytoolz/itertoolz
.. [functoolz] http://github.com/pytoolz/functoolz
.. [Underscore.js] http://underscorejs.org
.. [cheatsheet] http://clojure.org/cheatsheet
.. [Guido] http://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html
.. [Enumerable] http://ruby-doc.org/core-2.0.0/Enumerable.html
.. [itertools] https://docs.python.org/2/library/itertools.html
.. [functools] https://docs.python.org/2/library/functools.html
.. [itertoolz] https://github.com/mrocklin/itertoolz
.. [functoolz] https://github.com/mrocklin/functoolz
.. [Underscore.js] https://underscorejs.org
.. [cheatsheet] https://clojure.org/cheatsheet
.. [Guido] https://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html
.. [Enumerable] https://ruby-doc.org/core-2.0.0/Enumerable.html
.. [funcy] https://github.com/suor/funcy/
.. [fn.py] https://github.com/kachayev/fn.py
2 changes: 1 addition & 1 deletion doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ three ways:

1. Toolz is pure Python
2. Toolz relies only on the standard library
3. Toolz simultaneously supports Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, PyPy
3. Toolz simultaneously supports Python versions 2.7, 3.4+, PyPy
6 changes: 3 additions & 3 deletions doc/source/streaming-analytics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ These functions correspond to the SQL commands ``SELECT`` and ``WHERE``.
... map(get([1, 2])),
... list)

*note: this uses the curried_ versions of ``map`` and ``filter``.*
Note: this uses the `curried`_ versions of ``map`` and ``filter``.

Of course, these operations are also well supported with standard
list/generator comprehension syntax. This syntax is more often used and
Expand Down Expand Up @@ -81,8 +81,8 @@ groups.

.. code::

>>> from toolz import groupby, valmap, compose
>>> from toolz.curried import get, pluck
>>> from toolz import compose
>>> from toolz.curried import get, pluck, groupby, valmap

>>> groupby(get(3), accounts)
{'F': [(1, 'Alice', 100, 'F'), (5, 'Edith', 300, 'F')],
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(name='toolz',
version=toolz.__version__,
description='List processing tools and functional utilities',
url='http://github.com/pytoolz/toolz/',
url='https://github.com/pytoolz/toolz/',
author='https://raw.github.com/pytoolz/toolz/master/AUTHORS.md',
maintainer='Matthew Rocklin',
maintainer_email='mrocklin@gmail.com',
Expand All @@ -21,16 +21,17 @@
long_description=(open('README.rst').read() if exists('README.rst')
else ''),
zip_safe=False,
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy"])
6 changes: 3 additions & 3 deletions tlz/_build_tlz.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import sys
import types
import toolz
from toolz.compatibility import import_module
from importlib import import_module


class TlzLoader(object):
""" Finds and loads ``tlz`` modules when added to sys.meta_path"""
def __init__(self):
self.always_from_toolz = set([
self.always_from_toolz = {
toolz.pipe,
])
}

def _load_toolz(self, fullname):
rv = {}
Expand Down
13 changes: 7 additions & 6 deletions toolz/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import inspect
import itertools
import operator
from importlib import import_module

from .compatibility import PY3, import_module
from .compatibility import PY3
from .functoolz import (is_partial_args, is_arity, has_varargs,
has_keywords, num_required_args)

Expand Down Expand Up @@ -640,8 +641,8 @@ def get_exclude_keywords(num_pos_only, sigspec):
def signature_or_spec(func):
try:
return inspect.signature(func)
except (ValueError, TypeError) as e:
return e
except (ValueError, TypeError):
return None

else: # pragma: py3 no cover
def num_pos_args(sigspec):
Expand All @@ -662,8 +663,8 @@ def get_exclude_keywords(num_pos_only, sigspec):
def signature_or_spec(func):
try:
return inspect.getargspec(func)
except TypeError as e:
return e
except TypeError:
return None


def expand_sig(sig):
Expand Down Expand Up @@ -697,7 +698,7 @@ def expand_sig(sig):
num_pos_only = num_pos_args(sigspec)
keyword_only = ()
keyword_exclude = get_exclude_keywords(num_pos_only, sigspec)
return (num_pos_only, func, keyword_only + keyword_exclude, sigspec)
return num_pos_only, func, keyword_only + keyword_exclude, sigspec


signatures = {}
Expand Down
12 changes: 3 additions & 9 deletions toolz/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import operator
import sys
PY3 = sys.version_info[0] > 2
PY33 = sys.version_info[0] == 3 and sys.version_info[1] == 3
PY34 = sys.version_info[0] == 3 and sys.version_info[1] == 4
PYPY = hasattr(sys, 'pypy_version_info')

__all__ = ('map', 'filter', 'range', 'zip', 'reduce', 'zip_longest',
'iteritems', 'iterkeys', 'itervalues', 'filterfalse',
'PY3', 'PY34', 'PYPY', 'import_module')
'PY3', 'PY34', 'PYPY')

if PY3:
map = map
Expand All @@ -20,6 +19,7 @@
iteritems = operator.methodcaller('items')
iterkeys = operator.methodcaller('keys')
itervalues = operator.methodcaller('values')
from collections.abc import Sequence
else:
range = xrange
reduce = reduce
Expand All @@ -31,10 +31,4 @@
iteritems = operator.methodcaller('iteritems')
iterkeys = operator.methodcaller('iterkeys')
itervalues = operator.methodcaller('itervalues')

try:
from importlib import import_module
except ImportError:
def import_module(name):
__import__(name)
return sys.modules[name]
from collections import Sequence
4 changes: 4 additions & 0 deletions toolz/curried/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import toolz
from . import operator
from toolz import (
apply,
comp,
complement,
compose,
compose_left,
concat,
concatv,
count,
Expand Down Expand Up @@ -59,6 +61,7 @@
assoc_in = toolz.curry(toolz.assoc_in)
cons = toolz.curry(toolz.cons)
countby = toolz.curry(toolz.countby)
dissoc = toolz.curry(toolz.dissoc)
do = toolz.curry(toolz.do)
drop = toolz.curry(toolz.drop)
excepts = toolz.curry(toolz.excepts)
Expand All @@ -80,6 +83,7 @@
partition = toolz.curry(toolz.partition)
partition_all = toolz.curry(toolz.partition_all)
partitionby = toolz.curry(toolz.partitionby)
peekn = toolz.curry(toolz.peekn)
pluck = toolz.curry(toolz.pluck)
random_sample = toolz.curry(toolz.random_sample)
reduce = toolz.curry(toolz.reduce)
Expand Down
4 changes: 2 additions & 2 deletions toolz/curried/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def should_curry(f):


locals().update(
dict((name, curry(f) if should_curry(f) else f)
for name, f in vars(operator).items() if callable(f)),
{name: curry(f) if should_curry(f) else f
for name, f in vars(operator).items() if callable(f)},
)

# Clean up the namespace.
Expand Down
Loading