Hello everybody !!!

I recently had to write two very easy lines of python, and I wondered
if there was ( there is ) a better way to write them. The problem is
easy : I have a list A, a list B whose elements all belong to A, and I
want to return A-B.

I wrote [v for v in A if v not in B] which may be the worst option.

I thought about list(Set(A)-Set(B)), or about first sorting both lists
(nlog n) then taking the difference in linear time. Well, perhaps the
overhead due to sorting or to coercion to Sets is already too much for
this application ( the sets in questions where vertices in a Graph,
and the other parts of the function in which they are used is already
quite long ), but, well, I wondered... :-)

Thanksssssss ! :-)

Nathann

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to