Matthew Barnett <[email protected]> added the comment:
I've just had a look at _uniq, and the code surprises me.
The obvious way to detect duplicates is with a set, but that requires the items
to be hashable. Are they?
Well, the first line of the function uses 'set', so they are.
Why, then, isn't it using a set to detect the duplicates?
How about this:
def _uniq(items):
newitems = []
seen = set()
for item in items:
if item not in seen:
newitems.append(item)
seen.add(item)
return newitems
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37723>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com