How do I most efficienty check the unique elements in a list?
Posted
by alex
on Stack Overflow
See other posts from Stack Overflow
or by alex
Published on 2010-04-02T22:43:29Z
Indexed on
2010/04/02
22:53 UTC
Read the original article
Hit count: 158
let's say I have a list
li = [{'q':'apple','code':'2B'},
{'q':'orange','code':'2A'},
{'q':'plum','code':'2A'}]
What is the most efficient way to return the count of unique "codes" in this list? In this case, the unique codes is 2, because only 2B and 2A are unique.
I could put everything in a list and compare, but is this really efficient?
© Stack Overflow or respective owner