This commit is contained in:
lz_db
2025-11-16 12:31:03 +08:00
commit 0fab423a18
1451 changed files with 743213 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
"""
Alternate namespace for toolz such that all functions are curried
Currying provides implicit partial evaluation of all functions
Example:
Get usually requires two arguments, an index and a collection
>>> from curried import get
>>> get(0, ('a', 'b'))
'a'
When we use it in higher order functions we often want to pass a partially
evaluated form
>>> data = [(1, 2), (11, 22), (111, 222)]
>>> list(map(lambda seq: get(0, seq), data))
[1, 11, 111]
The curried version allows simple expression of partial evaluation
>>> list(map(get(0), data))
[1, 11, 111]
See Also:
funccurry
"""
from . import operator
from .. import (
apply,
comp,
complement,
compose,
compose_left,
concat,
concatv,
count,
curry,
diff,
first,
flip,
frequencies,
identity,
interleave,
isdistinct,
isiterable,
juxt,
last,
memoize,
merge_sorted,
peek,
pipe,
second,
thread_first,
thread_last,
)
from .exceptions import merge, merge_with
# accumulate = curry(accumulate)
# assoc = curry(assoc)
# assoc_in = curry(assoc_in)
# cons = curry(cons)
# countby = curry(countby)
# dissoc = curry(dissoc)
# do = curry(do)
# drop = curry(drop)
# excepts = curry(excepts)
# filter = curry(filter)
# get = curry(get)
# get_in = curry(get_in)
# groupby = curry(groupby)
# interpose = curry(interpose)
# itemfilter = curry(itemfilter)
# itemmap = curry(itemmap)
# iterate = curry(iterate)
# join = curry(join)
# keyfilter = curry(keyfilter)
# keymap = curry(keymap)
# map = curry(map)
# mapcat = curry(mapcat)
# nth = curry(nth)
# partial = curry(partial)
# partition = curry(partition)
# partition_all = curry(partition_all)
# partitionby = curry(partitionby)
# peekn = curry(peekn)
# pluck = curry(pluck)
# random_sample = curry(random_sample)
# reduce = curry(reduce)
# reduceby = curry(reduceby)
# remove = curry(remove)
# sliding_window = curry(sliding_window)
# sorted = curry(sorted)
# tail = curry(tail)
# take = curry(take)
# take_nth = curry(take_nth)
# topk = curry(topk)
# unique = curry(unique)
# update_in = curry(update_in)
# valfilter = curry(valfilter)
# valmap = curry(valmap)
del exceptions

View File

@@ -0,0 +1,22 @@
from .. import (
curry,
merge_with,
merge
)
__all__ = ['merge_with', 'merge']
@curry
def merge_with(func, d, *dicts, **kwargs):
return merge_with(func, d, *dicts, **kwargs)
@curry
def merge(d, *dicts, **kwargs):
return merge(d, *dicts, **kwargs)
merge_with.__doc__ = merge_with.__doc__
merge.__doc__ = merge.__doc__

View File

@@ -0,0 +1,22 @@
from __future__ import absolute_import
import operator
from ..functoolz import curry
# Tests will catch if/when this needs updated
IGNORE = {
"__abs__", "__index__", "__inv__", "__invert__", "__neg__", "__not__",
"__pos__", "_abs", "abs", "attrgetter", "index", "inv", "invert",
"itemgetter", "neg", "not_", "pos", "truth"
}
locals().update(
{name: f if name in IGNORE else curry(f)
for name, f in vars(operator).items() if callable(f)}
)
# Clean up the namespace.
del IGNORE
del curry
del operator