|
|
|
|
|
by aleksiy123
1508 days ago
|
|
Seems like you should just go with what you you know best. Taking 10x longer doesn't seem like a language problem. If you don't know bash well you're going to take even longer to do it in bash than in python. In any case the task you described is pretty much the same in python as in bash. At worst the python is going to be more more verbose. python -c "print(len(set(w for l in list(open('test.txt')) for w in l.split())))"
vs tr ' ' '\n' < file_name | sort | uniq -c | wc -l
|
|
In Python you could use a generator but it would get a little more complicated and you'd still have to add all the words to set() but hopefully the number of different words is not that great.
The trie approach is quite memory efficient and that can matter.