list - How to speed up a search in a long document using python? -
I was wondering if it is possible to search in Vime using a python to speed up the search in a longer document . / P>
I have a text document of 140,000 lines.
I have a list with 115 different search patterns.
I want to put all the rows with matches in a list (hit)
I do this now: for the category (1, the row ("$") for the category I 0, Lane (Marcelle) -1)
idx = match (get line, mysearch [ii]) if idx & gt; = 0 call add (hit, line) endif and end and
"Remove the double linen:
appell = filtered (hit), 'Index (Hit, V: Vel, V: Key + 1) == - 1')
The problem is that this search takes more than 5 minutes.
I How can I optimize the search in Python search?
How about:
pattern = join (mysearches, '\ |') = my list = systemlist ('grep -n' '.pattern.' '' Sh ('; Cut-d: -f1');
\ |
(like OR ), using the grep
to process your pattern, Grep should be very fast, with much more vim and possibly even Either it is more than a dragon or even a pearl (of course it depends on the pattern). The return value is a list, which contains all the mailing lines, because we have -n
grep Switch was used, so we had to get matching line number, which in turn cut
.
System list)
then output is partitioned on \ n
. That's why all the lines should be in my list, match your pattern. It definitely depends on your pattern, but if you use standard BRE or ERE (-E) or Pearl RE (-P switch) then you should be OK. Depending on the taste of RE, adjustment needs to be included in this.
However, it is basically unwanted, for a real solid solution, perhaps possibly preprinting the pattern) and split the whole part a bit, so that it is easy to read.
Comments
Post a Comment