Conversation
Use dict.keys() for set operations rather than explicitly creating sets.
|
This change does work -- and you'd think it might be faster, but it looks like it is actually slower -- even for large sets. Probably sticking with builtin python objects is faster than using the same tools via the NetworkX views. The collections.abc tools are nice, but not optimized for speed -- rather for ease of implementation I suspect. Anyway, if anyone is thinking of propagating use of |
|
Thanks @dschult , I didn't bother to check the performance which was an oversight on my part! In that case, I think the original is unquestionably better as it was a) shorter, b) more performant, and c) explicit (i.e. readers don't have to know that |
|
Getting rid of the comment is a Good Thing! |
Just doing it the hard way ;) |
Python3 cleanup Use dict.keys() for set operations rather than explicitly creating sets.
Python3 cleanup Use dict.keys() for set operations rather than explicitly creating sets.
Use dict.keys() for set operations rather than explicitly creating sets, as recommended in the comment.