[QScintilla] Using python strings with SendScintilla

Phil Thompson phil at riverbankcomputing.com
Sat Nov 8 16:44:55 GMT 2008


On Sat, 08 Nov 2008 16:34:56 +0000, Baz Walter <bazwal at ftml.net> wrote:
> Phil Thompson wrote:
>   > So you are using SendScintilla() to bypass the immutability of Python
>> strings? In that case you deserve all you get.
> 
> i had a hunch that you might say something like this :)
> 
> of course, i don't *want* to use python strings in this way. it's just 
> that, AFAICT, that's how the SendScintilla api works - it requires a 
> string buffer to be passed in. if there's another way, please let me 
> know, because i'd be more than happy to use it!
> 
>> If speed is a real problem (and not premature optimisation) then a
better
>> solution would be to implement a new method (stripTrailingSpaces()) at
>> the
>> C++ level.
> 
> a stripTrailingSpaces method would be nice, but what i would really like 
> is a more general method that simply returned the undecoded bytes (as a 
> str/bytes object for the python bindings). there are lots of uses that i 
> could make of this that aren't really optimisations. they're more to do 
> with working in a more pythonic way - it is just more natural for me to 
> work directly with python strings, particularly as i am making a lot of 
> use of python's regexps and io (on unix). the speed issues arise with 
> larger documents (e.g. multi-megabyte xml files) where some operations 
> that would normally take fractions of second can take several tens of 
> seconds. this obviously hurts the usuablility of the program a lot if 
> the operation is occuring repeatedly (like stripping trailing spaces 
> when saving the document).
> 
> i hope this makes it clearer what i'm asking for and why.

There's no problem with adding something like...

const char *QsciScintilla::rawText() const;
void QsciScintilla::setRawText(const char *text);

Phil


More information about the QScintilla mailing list