On Sep 20, 2019, at 02:41, Richard Musil
I just added another implementation to the test (which I believe you had on mind): ``` def relcomp_set_list(a, b): bset = set(b) return [ia for ia in a if ia not in bset]
Or just `set(b).intersection(a)` and maybe checking the len to pick which one. If you really want to go overboard with micro-optimizing this version, you might want to also check whether stashing bset.__contains__ and using that speeds things up (which may be different across recent versions of Python with changes to method calling?), and using it in filter instead of a comprehension (to move the loop fully into C, at the cost of needing to build a list out of an iterator at the end). But I don’t really think we need to go overboard with that. We already know that using a set is faster except possibly when you already have pre-sorted lists, and if you do have that case, I’m not sure pressing further with this artificial benchmark will tell you much anyway.