pytoolz / pytoolz/toolz

`toolz.merge_with` not lazy, breaks with Clojure interface

Open
#153 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

Clojure's core.merge-with takes a binary operator

(defn add [a b]
  (+ a b))  ; yes I know this is silly, I wanted an explicit binary operator

(merge-with add [{:a 1} {:a 2} {:a 3}])
;; {:a 6}

Toolz merge_with takes a reduction operation

>>> merge_with(sum, [{'a': 1}, {'a': 2}, {'a': 3}])
{'a': 6}

This is convenient from a Python perspective because operations like sum are more familiar than binary operators like add. However this is not lazy and requires all dicts to be read in at once.

I tried a solution in https://github.com/pytoolz/toolz/pull/127 but gave up.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the merge_with entry point and compare its current reduction behavior with Clojure's core.merge-with. Review the abandoned pull request #127 before defining the expected lazy behavior and compatibility tests; done means the intended input pattern works without requiring all dictionaries to be read at once.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.