Need to improve COM performance
Mark Hammond
MarkH at ActiveState.com
Fri Nov 2 21:43:07 EST 2001
Tom Fenn wrote:
> Hello,
>
> I'm working on an application that involves calculating some
> statistics for data produced by a commercial scientific instrument
> (ion trap mass spectrometer). The code works, but takes longer than I
> expected to execute. I ran the profiler on it, and got the following
> results (which are sorted on cumtime and percall). Access to the data
> file is through a COM control provided by the manufacturer. I've
> wrapped it using genpy, and then wrapped an easier to use class around
> the component. If I read the profile data right, the program is
> spending 14 of its 15 minutes of execution time in the ApplyTypes
> routine from PythonCOM. Is there anything I can do to speed this up
> from within Python? Would implementing the Python class in C++
> improve performance significantly in this case? Happily, the
> application is spending only a few seconds in my own code.
If you look at _ApplyTypes_, you will notice it is a single line:
return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid,
0, wFlags, retType, argTypes) + args), user, resultCLSID)
The time for _get_good_object_ is accounted for in the profile stats.
The rest of the time is being spent in InvokeTypes. - ie, in some
*other* COM object.
ie, I think that all this is telling you is that the COM object you are
calling is taking all the time, not your Python code.
Mark.
More information about the Python-list
mailing list