Select to view content in your preferred language

arcpy and pmf

5093
23
02-02-2010 10:29 AM
TedCronin
MVP Honored Contributor
Will the generation of pmf files be supported with arcpy?  I don't remember seeing anything in the help.
0 Kudos
23 Replies
TedCronin
MVP Honored Contributor
Adding the STAThread attribute dramatically changes C# and F# performance, and adding in the missing ReleaseComObject lines significantly improves VB .NET performance, bringing all three in line with each other as I had originally expected. Also, setting the "CLR Thread Attribute" and "CLR Unmanaged Code Check" linker settings in the C++/CLI benchmark [the actual benchmark code is unmanaged] brings its performance to about the same as C++/ATL, which is what it should be. :cool:

So here once again *sigh* are my benchmarks for 9.3.1:

Seconds:   
Java: 81
IronPython: 54
Python: 40
VB/C#/F#: 27
VBA: 14
C++: 13
Python/arcgisscripting: 43

and now for the 10.0 RC:

Seconds:   
Java: 78
IronPython: 44
Python: 33
VB/C#/F#: 19
VBA: 8
C++ : 8
Python/arcpy: 98

At the DevSummit, the ESRI geoprocessing team said for the 10.1 release they hope to improve the performance of arcpy and add Python support to the add-in framefork. :rolleyes:

I've also updated both the sample code and the presentation at my web site. 😛


Well then I guess I will be looking forward to 10.1, then, just amazing on how slow arcpy is on these tests at 10.
0 Kudos
KimOllivier
Regular Contributor II

I haven't really seen any bugs regarding comtypes and ArcObjects, except one:  it doesn't wrap the esriSystem.Array object since there's a name clash with ctypes Array.  I'd be curious as to what version of comtypes you've been using and what problems you've been seeing.



I did notice that in arcpy the Array object is not iterable. I had to use the .next() function. Should I expect it to be iterable?
while row:
        feat = row.getValue(shapefield)
        qInterior = False
        for partNum in range(feat.partCount) :
            part = feat.getPart(partNum) 
            qInterior = False
            for ptNum in range(part.count):
                pt = part.next() 
                if pt != None:
                    arrayOuter.add(pt)
                else :
                    qInterior = True
                    break # ignore donut vertices
            arrayObj.add(arrayOuter)
            arrayOuter.RemoveAll()
0 Kudos
FrankPerks
New Contributor II
I did notice that in arcpy the Array object is not iterable. I had to use the .next() function. Should I expect it to be iterable?
while row:
        feat = row.getValue(shapefield)
        qInterior = False
        for partNum in range(feat.partCount) :
            part = feat.getPart(partNum) 
            qInterior = False
            for ptNum in range(part.count):
                pt = part.next() 
                if pt != None:
                    arrayOuter.add(pt)
                else :
                    qInterior = True
                    break # ignore donut vertices
            arrayObj.add(arrayOuter)
            arrayOuter.RemoveAll()


Heres an easy way to make arcpy non iterable objects usable in a for each loop.

for each in iter(lambda: <your object>.next(), None):


This basically iterates through getting the next element until the termination condition of the element being None is met.

while row:
        feat = row.getValue(shapefield)
        qInterior = False
        for partNum in range(feat.partCount) :
            part = feat.getPart(partNum) 
            qInterior = False
            
            # to iterate you can use the iterable wrapper in
            # conjunction with a lambda.
            for pt in iter(lambda: part.next(), None):
                qInterior = True
                arrayOuter.add(pt)
            # old method
            for ptNum in range(part.count):
                pt = part.next() 
                if pt != None:
                    arrayOuter.add(pt)
                else :
                    qInterior = True
                    break # ignore donut vertices
            arrayObj.add(arrayOuter)
            arrayOuter.RemoveAll()


For the comtypes bug not generating esriSystem.Array its because of namespace pollution that comtypes generator does.

@Riverside

Can you tell me if your version of comtypes is actually generating any sort of builtin methods like len/iter/getitem/etc, for enumerable interfaces? Some Interfaces do, but the majority don't.
0 Kudos
KimOllivier
Regular Contributor II
fperks;16230 wrote:
Heres an easy way to make arcpy non iterable objects usable in a for each loop.


for each in iter(lambda: <your object>.next(), None):


This basically iterates through getting the next element until the termination condition of the element being None is met.

Thanks very much. Wonderfully Pythonic!
0 Kudos