pytoolz / pytoolz/toolz

unique only works for hashables

Open
#166 20 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

unique only works for hashable items. I was hoping to get an algorithm that worked using ==, because such a thing is hard to get right.

An idea I had:

  • Implicitly assume that == is reflexive, transitive, and symmetric.
  • Create a dictionary of objects, keyed off of the id.
  • If id(object) is in the dictionary break early. Otherwise, go through the dictionary. If the object is equal to an item, break.
  • Return the values of the dictionary

I think this is O(n**2) time in general, but if I'm not mistaken, that is unavoidable for any algorithm that uses ==.

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

The issue names only the unique entry point, not a file or test. Start by locating its implementation and existing tests, then examine how hashability currently limits it. Done should mean unique supports unhashable items using equality while retaining the intended returned values and has coverage for the new behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.