I've been using win32com.client for the past year or so. Recently, I noticed that there was a bottleneck in my code, and I tracked this down to _get_good_single_object (line 478). When using comtypes instead of win32com.client, calling the ReadTagVEX method on my COM object is 4.8 times faster so the slowdown appears to be in _get_good_object_. The COM function in question, ReadTagVEX, is supposed to return an Array of VARIANT. These arrays are quite large (on the order of 100,000 or 200,000 samples) on each read.
I'd much rather stick with win32com.client if possible. Are there any suggestions for speeding up this function? I already know that the array returned will be an array of float32. The signature of ReadTagVEX generated by makepy: def ReadTagVEX(self, Name=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, nWords=defaultNamedNotOptArg, SrcType=defaultNamedNotOptArg , DstType=defaultNamedNotOptArg, nChans=defaultNamedNotOptArg): return self._ApplyTypes_(25, 1, (12, 0), ((8, 0), (3, 0), (3, 0), (8, 0), (8, 0), (3, 0)), u'ReadTagVEX', None,Name , nOS, nWords, SrcType, DstType, nChans ) Output of the cProfile function: 11 0.000 0.000 10.823 0.984 c:\Python26\lib\site-packages\win32com\gen_py\D323A622-1D13-11D4-8858-444553540000x0x1x0.py:192(ReadTagVEX) 11 0.025 0.002 10.823 0.984 c:\Python26\lib\site-packages\win32com\client\__init__.py:454(_ApplyTypes_) 11 0.000 0.000 10.046 0.913 c:\Python26\lib\site-packages\win32com\client\__init__.py:474(_get_good_object_) 3801275/11 4.605 0.000 10.046 0.913 c:\Python26\lib\site-packages\win32com\client\__init__.py:483(_get_good_object_) 192/16 2.009 0.010 10.046 0.628 {map} 3801088 1.765 0.000 1.765 0.000 c:\Python26\lib\site-packages\win32com\client\__init__.py:478(_get_good_single_object_) 3813844 1.677 0.000 1.677 0.000 {isinstance} 351 0.867 0.002 0.867 0.002 {method 'InvokeTypes' of 'PyIDispatch' objects} _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32