3 ms·
I was working on a function to deduplicate (preserving order) collections in python. Very straightforward: take the next value, see if it's in the set of alread
by andreareina 4y ago
I was working on a function to deduplicate (preserving order) collections in python. Very straightforward: take the next value, see if it's in the set of already-seen values, put it in the output list if not. Since it uses sets under the hood, the values have to be hashable. Testing was almost equally straightforward: I favor property testing[1] and just asked for examples from from_type(Sequence[Hashable]).
Except. It turns out that Decimal is a hashable type, but there is a specific value that isn't: Decimal('sNaN'). Which of course the tests found pretty much right away (yay prop tests). sNaN: not even once.
[1] specifically, using hypothesis