I've using notepad++ for a few years but only recently took the time to try pythonscript.
I was hoping to automate cleanup of trace files. Right now I have a light trace file (only about 3000 lines).
Every line looks pretty much like this:
PSAPPSRV.15644 1-284 18.05.28 8.533095 Cur#1.15644.PAY89DEV RC=0 Dur=0.000474 COM Stmt=SELECT VERSION FROM PSVERSION WHERE OBJECTTYPENAME = 'SYS'
I'd like to remove everything till Dur=0.000474
Directly with notepad++ I'm using this regexp :
The result is about instantaneous.
I tried the following python script:
both take about 30 seconds to complete !
Actually, even a simple replace
takes the same time to complete.
I've seen the 1-year old "pymlreplace - very slow" thread in which the OP says "(about 100 lines per second for each editor.pymlreplace…)", that's about what I get.
I'm wondering whether this is expected ? Would the difference in speed between "native npp replace" and "python script replace" be justified by the fact we're in a plugin ?
Thank you for any input.
btw, I'm using PythonScript 0.9.2.0 on Notepad++ 5.9.8, win7-32, a recent setup.
Hi, I am face to the slow pyreplace too. I takes near 10 lines/s which is very slow
I'm using PythonScript 0.9.2.0 on Notepad++ 5.9.8, winXP-media-center 32bits.
No tried before. I am new to pyhonscript.
Yes, I can confirm it's slow. For pyreplace(), this is (as far as I can tell) down to swapping in and out of python context, and calling essentially a python function per line. For rereplace(), this should actually be as quick as N++ itself, however it's not. I'm working on a further plugin that specialises in search and replace, and that is already 5 times quicker than native n++. When it's done, I'll port the fast code back to Python script.
This will only affect rereplace(), although with the new regular expression support in N++ 6, that means you'll only need pyreplace() when you've actually got a function to replace the content.
I'll certainly see what I can do with the pyreplace() to make it a bit quicker - it may be faster, for instance, to actually do the whole replacement in python, and not switch in and out. Alternatively it may be the way pyreplace() uses Scintilla that makes it slow. I would expect some form of performance increase for pyreplace() in the next version of python script, which is long overdue.
thank you for your answer. It's good news for us that you're already working on updating the search and replace features.
will be waiting :-)
I see, that one year later pyreplace is still to slow to by useful. I believe the problem is caused by repeatedly screen refreshes. My solution is to use standard python regex functions instead, for example:
text = editor.getText()
text = re.sub(re.compile('\r\n\t[^\r\n]*\r\n', re.M), '\r\n', text)
text = re.sub(re.compile('\r\n(\r\n)+', re.M), '\r\n', text)
text = re.sub(re.compile('\r\n +', re.M), '', text)
text = re.sub(re.compile('\r\n(\[[^\r\n]*)\r\n', re.M), '\r\n\\1\t\r\n', text)
text = re.sub(re.compile('\r\n([^\)', re.M), '\\1', text)
I hope somebody will find this tip useful.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.