4 ms·
In loopless Python: set(open('file_b')) - set(open('file_a')) Slower than J by a factor of 2-3, but still 10x faster than grep: real 0m0.128s
by DylanDmitri 6y ago
In loopless Python:
set(open('file_b')) - set(open('file_a'))
Slower than J by a factor of 2-3, but still 10x faster than grep:
real 0m0.128s
user 0m0.078s
sys 0m0.063s
This would make a good Rosetta Code prompt.
- qmmmur 6y agothis is cheeky, I like it
- throwaway_pdp09 6y agoI didn't know you could simply open a file and setify it. Interesting. & neat.
- fennecfoxen 6y agoYou can setify any iterable. File handles are iterables that return a line at a time. Tada!
- throwaway_pdp09 6y ago> File handles are iterables... I did not know that. Assumed you had to somehow wrap them first. Very useful, thanks!
- dunefox 6y agoThis is only fast because it hits C underneath, isn't it?