3 ms·
Here are some types that support hashing: str bytes int, float complex tuple frozenset Aside from int and float, you cannot perform comparisons be
by boothby 10mo ago
Here are some types that support hashing:
str
bytes
int, float
complex
tuple
frozenset
Aside from int and float, you cannot perform comparisons between objects of different types. Moreover, you cannot sort complex numbers at all.
I have crossed that bridge, and I'm telling you (again) that a sorted tuple is not a generic solution.
- morshu9001 10mo agoI'm not saying the problem with tuple doesn't exist, but that there doesn't need to be a built-in way to deal with it. If for some unfortunate reason you've got a mixed-type set that you also want to use as a dict key, you can write a helper.