Commit 19448fe
Fix: Handle unhashable items in remove_duplicates
The previous optimization broke when the function received unhashable items
like lists or dicts, causing TypeError. This commit adds backward compatibility
by checking if items are hashable:
- Hashable items use set for O(1) lookup (fast path)
- Unhashable items fall back to list membership check (preserves original behavior)
This maintains the O(n) optimization for the common case while preserving
backward compatibility for all input types.
Co-Authored-By: Keon <[email protected]>1 parent 1bd6670 commit 19448fe
1 file changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
0 commit comments