Thoughts on partialz with ellipsis?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reviewing the existing thread_(first|last) entry points and partial-related APIs in toolz, then compare the proposed partialz and Ellipsis placeholder behavior with the package's functional design. The issue does not name files or tests, and its open-ended question means completion would require maintainer agreement on scope and direction.
Written by the indexing model from the issue text.
Description
I really enjoy using this package.
The functional approach is very attractive to me.
And in particular, I often use pipe and thread_(first|last).
Upon lot's of use I've made my own modifications and therefore would like to ask about it here to see if it's the philosophy of the package and perhaps I can try a pull request.
I should mention that I've never made a contribution to an external package, and therefore don't know about the real blows and whistles about such collaboration. So thank you for your comprehension.
The functions that I like are the following:
from functools import partial, reduce
from itertools import chain
VARHOLDER = Ellipsis
class partialz(partial):
"""Allow Ellipsis (...) as variable holder."""
def __call__(self, *args, **keywords):
args_i = iter(args)
args_0 = (next(iargs) if arg is VARHOLDER else arg for arg in self.args)
argz = chain(args_0, args_i)
keywordz = {**self.keywords, **keywords}
return self.func(*argz, **keywordz)
def thread(val, *forms):
"""Unify thread_(first|last) to use Ellipsis placeholder."""
eval_ff = (lambda vv, ff:
partial2(*ff)(vv) if isinstance(ff, tuple) else ff(vv))
return reduce(eval_ff, forms, val)
## This one is less important, but shows up in partialz
def interweave(seq1, seq2, cond=None):
"""Replace elements of seq1 where cond is True with elements from seq2."""
cond = cond or (lambda ee: ee is None) # return_none?
seq_i = iter(seq2)
seq_0 = (next(seq_i) if cond(elem) else elem for elem in seq1)
return chain(seq_0, seq_i)
So the motivation for all of this was generalizing thread_(first|last) to having the arguments in any place, and that's how I came to find about something like partialz that use Ellipsis as placeholder for the variables.
And finally I was looking into ways to combine sequences based on the arguments argz in partialz, as the following line seemed to show room for simplification.
(next(iargs) if arg is VARHOLDER else arg for arg in self.args)
So my question is, Do these changes make sense in the project?
Thank you for reading me.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 280
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pytoolz/toolz
-
tail(0, seq) returns the whole sequence instead of empty (and is inconsistent across iterable types) Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100