Feature Class To FeatureClass conversion 2.7 python vs 3.6 Python

1018
15
02-04-2019 12:11 PM
CCWeedcontrol
Occasional Contributor III

I am trying to test some of my 2.7 python scripts on 3.6 python and i noticed a huge difference on amount of time it takes to run the FeatureClassToFeatureClass_conversion process. so with 3.6 python the process took 18 min 5 secs, with 2.6 python it took only 8 seconds. Does anyone know why the it take much longer in 3.6 Python?

This is what i am using, there is more fields than this i just removed a lot of them.

PT1 = "C:/Temp/Scratchworkspace.gdb/Drain"

def Layers15(PT1):
    FieldMapString = "" \

                + """PIN "PIN" true true false 13 Text 0 0 ,First,#,""" + PT1 + """,Pin,-1,-1;"""\
                + """ACRES "ACRES" true true false 4 Double 0 0  ,First,#,""" + PT1+ """,ACRES,-1,-1;"""\
                + """Instrument "Instrument" true true false 10 Text 0 0 ,First,#,""" + PT1 + """,Instrument,-1,-1;"""\
                + """SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#,""" + PT1 + """,SiteAddres,-1,-1;"""\
                + """SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#,""" + PT1 + """,SiteCity,-1,-1;"""\
                + """SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#,""" + PT1 + """,SiteZip,-1,-1;"""\
                + """SubName "SubName" true true false 20 Text 0 0 ,First,#,""" + PT1 + """,SubName,-1,-1;"""\       
                            

    fieldmappings = arcpy.FieldMappings()
    fieldmappings.loadFromString(FieldMapString)
    return fieldmappings


def main(args=None):
        if args is None:
                args = sys.argv

# Process: Feature Class to Feature Class
arcpy.FeatureClassToFeatureClass_conversion(PT1, "C:/Temp/Scratchworkspace.gdb", "PT_ALL","", Layers15(PT1),"")
0 Kudos
15 Replies
DanPatterson_Retired
MVP Emeritus
PT1 = 'HELLO'

FieldMapString = '''
PIN "PIN" true true false 13 Text 0 0 ,First,#, {0}, Pin,-1,-1;
ACRES "ACRES" true true false 4 Double 0 0  ,First,#, {0}, ACRES,-1,-1;
Instrument "Instrument" true true false 10 Text 0 0 ,First,#, {0}, Instrument,-1,-1;
SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#, {0}, SiteAddres,-1,-1;
SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#, {0}, SiteCity,-1,-1;
SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#, {0}, SiteZip,-1,-1;
SubName "SubName" true true false 20 Text 0 0 ,First,#, {0}, SubName,-1,-1;
'''
print(FieldMapString.format(PT1))
def Layers15(PT1, FieldMapString):
    """pass the variable and the constant into
    the function
    """
    fieldmappings = arcpy.FieldMappings()
    fieldmappings.loadFromString(FieldMapString)
    return fieldmappings

don't know about the speed thing, but that ugly string in a function surely had to go.  

0 Kudos
CCWeedcontrol
Occasional Contributor III

It's always been the way i have done it. Thanks for the suggestion i will try it out.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Is this code running on the same machine?

0 Kudos
CCWeedcontrol
Occasional Contributor III

Joshua,

Yes very same computer. None of the code was changed.

0 Kudos
CCWeedcontrol
Occasional Contributor III

With Dan Petterson suggestions it took 16 min 40 secs in Python 3.6.

0 Kudos
DanPatterson_Retired
MVP Emeritus

is your field mapping necessary? Just try a copy features tool to compare speed. It may be either things are slower in your environment or it is now just slower.

I haven't noticed any tool slowness at all in Pro 2.3, but I have beefy machines and I use local data.  It could be the way data is served/handled from sde or whatever if it isn't locally stored.  It seems to be a common thread for those that are on the "slow train"

0 Kudos
CCWeedcontrol
Occasional Contributor III

Yes because the field mapping rearranges the fields which is linked to a reporting tool. Unless there is another way to rearrange the fields?

All my data is on my local PC, i have noticed slowness with Pro 2.2. I haven't upgraded to Pro 2.3 yet.

0 Kudos
DanPatterson_Retired
MVP Emeritus

When you run Check My ability to run ArcGIS pro on the help page

ArcGIS Pro 2.3 system requirements—ArcGIS Pro | ArcGIS Desktop 

does it pass... errrr more importantly, does it surpass the highest recommendations? 

Do you run other stuff like browsers, social media and other unnecessary fluff when you are trying this?  

Pro is going to be slower apparently since people are complaining about it, but I can assure you it has nothing to do with Python

0 Kudos
CCWeedcontrol
Occasional Contributor III

My requirements pass.

When i run that block of code in 2.7 and 3.6 i had the same stuff open.

I restarted my PC and just run the script with python 2.7 the process took 10 secs. Then i closed python2.7 and opened python 3.6  and run the code it took 16 min 40 secs. Seem like the issue has to do with python 3.6 because i run the exactly same code. My python 2.7 is 32 bit, my 3.6 is 64 bit if that makes a difference.

0 Kudos