10.1 beta and comtypes

624
6
11-10-2011 09:39 AM
MarkCederholm
Occasional Contributor III
I've been really busy this year and only just now started looking at the 10.1 beta.  I noticed that the current version of comtypes croaks when trying to wrap esriSystem.olb.  Fortunately, you can remedy this by adding the following entry to the _ctype_to_vartype dictionary in automation.py:

    POINTER(BSTR): VT_BYREF|VT_BSTR,

If there's a better approach I'd like to hear about it.


Also note that arcpy.da approaches ArcObjects via comtypes in terms of performance.  To query and hydrate ~500,000 polygons from a file GDB feature class:

ArcGIS 10.0SP3:
---------------
ArcObjects/comtypes: 31 sec
arcpy.SearchCursor: 96 sec

ArcGIS 10.1 Beta:
-----------------
ArcObjects/comtypes: 21 sec
arcpy.SearchCursor: 85 sec
arcpy.da.SearchCursor: 27 sec
Tags (2)
0 Kudos
6 Replies
JasonScheirer
Occasional Contributor III
Nice. Could you share your code? Have you tried benchmarking against a cursor without a shape field or using one of the Shape@XY etc shortcuts?
0 Kudos
MarkCederholm
Occasional Contributor III
arcpy.da blows away ArcObjects for accessing table fields in a file gdb:

ArcObjects/comtypes (Shape_Area): 13 sec
arcpy.SearchCursor (Shape_Area): 65 sec
arcpy.da.SearchCursor (Shape_Area): 2 sec
arcpy.da.SearchCursor (SHAPE@AREA): 14 sec
0 Kudos
JasonScheirer
Occasional Contributor III
Thanks for sharing, this is encouraging.
0 Kudos
DanPatterson_Retired
MVP Emeritus
Just curious, but is the da module using numpy recarrays? or is it some com wrapper thing?
0 Kudos
JasonScheirer
Occasional Contributor III
A little of column a, a little of column b.
0 Kudos
DanPatterson_Retired
MVP Emeritus
Jason ... oh you all revealing types 🙂
Thanks
0 Kudos