Both PyQt and the Python standard library provide facilities for writing and reading binary files. PyQt uses the QDataStream class, and the Python standard library uses the file class, either directly or in conjunction with the pickle module.
Binary formats are not human-readable, but they are the easiest to code and the fastest to write and read to and from disk. No parsing is necessary: Numbers, dates, and many PyQt types, including images, can be read and written without formality. PyQt's support for binary files is very strong: PyQt ensures that binary files are platform-independent, and it isn't difficult to version our binary file types so that we can extend our file format when required. The Python standard library's pickle module (and its faster cPickle counterpart) also provide fast platform-independent loading and saving, but may not be as efficient as PyQt's QDataStream for handling complex PyQt types, such as images.
Was this article helpful?