I'm having an issue with an IO module that I'm developing, to access data in a file format (ASCII based).
It performs OK when it is used in a regular python script, but it is 5 times slower when I try to use it in a PyQt widget.
This is the simplified code that shows the issue:
from silx.io import spech5
import time
from PyQt4.QtGui import QApplication
with spech5.SpecH5("../data/mesh_and_mca.dat") as f:
start = time.time()
a = f["1.1/measurement/mca_0/data"]
end = time.time()
print("Simple access in python ", end - start)
app = QApplication([])
with spech5.SpecH5("../data/mesh_and_mca.dat") as f:
start = time.time()
a = f["1.1/measurement/mca_0/data"]
end = time.time()
print("Access after initializing QApplication ", end - start)
The first block takes 10 seconds, while the second identical block, after app = QApplication([])
takes 50 seconds.
I can repeat the code several before and after the app instantiation, and all the blocks before initializing the app are relatively fast while all the blocks after it are slow.
The line a = f["1.1/measurement/mca_0/data"]
causes the data file to be accessed 78026 times via a C function wrapped with Cython, to read a single "line" each time. The returned objects is a numpy array of shape (78026, 1024) and dtype float64.
Does anyone have a clue about what could cause this? Are there known issues/interferences between Qt and wrapped C code?