Its faster than the built in set type. Uniqueness of values isn't a 
requirement. The values need to be comparable so that they can be sorted. This 
allows a linear time complexity. That's basically the only restraint on the 
values. Here are some speed test results and pseudocode.
def naive(a,b):
    res = [x for x in a if x not in b]
def set_test(a,b):
    aset = set(a)
    bset = set(b)
   
    res = aset - bset
    res= list(res)

For A not in B:
trying A 10000 elements  B 50000 elements
naive test  10.285029 s
set test  0.008001 s
listex test  0.004000 s
 
For A subset of B:
trying A 100000 elements B 500000 elements
naive too long to wait :-)
set test  0.125013 s
listex test  0.054005s
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/O7AWG4CEXXVLBZF6JEAIM4SSLEA5TCB6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to