[PyQt] General questions on parsing large QStrings

Phil Thompson phil at riverbankcomputing.com
Sun May 12 22:43:59 BST 2013


On Sun, 12 May 2013 13:19:55 -0700, David Cortesi <davecortesi at gmail.com>
wrote:
> For an app to be built with PyQt5/Qt5, I will have a
> QPlainTextEdit in which the document may be quite
> sizable, 500K characters or more.
> 
> I will want at times to inspect the document character
> by character, or possibly apply Python relib REs to it.
> 
> I am somewhat at sea regarding the relationship between
> a const QString such as returned by QPlainTextEdit.toPlainText()
> and a Python3 unicode string, and -- just in general -- about
> the best way to do intensive examination of big strings.
> Is there a copy involved in, e.g.
> 
>     docstring = unicode( myEditor.toPlainText() )

In PyQt5 toPlainText() will return a str object for Python3 and a unicode
object for Python2.

> I note that the PyQt4 QString reference omits the
> QString.begin() or .constBegin() etc methods that return an
> "STL-style iterator" so that's out. Is there some internal magic
> to integrate the QString type into Python's "for" mechanism
> so that "for c in myEditor.toPlainText()" might be more
> efficient than making a Python3 string and iterating on it?
> 
> Also in regard to making intensive loops faster,
> how well do PyQtx calls integrate with Cython or PyPy?
> 
> Thanks for any insights,
> 
> Dave Cortesi

Phil


More information about the PyQt mailing list