Hi, Just wondering if anyone has ever investigated the idea of stripping down the arcpy libraries to decrease load time. We have a few processing machines running scripts that only ever use a given set of geoprocessing tools. Yet, presumably when arcpy loads, all libraries are loaded even though we are only using a small percentage. Obviously the installation on the machines targeted could only be use for vetted processes afterward.
If you know what you want to use, you can import directly
from arcpy import gp import arcgisscripting as ags
You can follow the import chain by examining the code in the import path (look for __init__ files)
For example, when you import arcpy, the path is as follows, and the imports cascade within the imports therein.
Also, arcgisscripting is located in
So if you only need the geoprocessor, or the data access stuff, just import those directly.
You will eventually develop a "chain of command" to limit importing everything in the namespace.
This isn't worth chasing. What are you hoping to gain? Quicker start/load times? The vast majority of the ArcPy startup time is licensing activation, and you will have to activate a license even if just using a single piece of ArcPy code.
Well I for one would like to know why my startup time is up to 5 times longer than others and if there's anything I can do about it https://community.esri.com/message/913697-what-is-your-import-arcpy-overhead
If you are trying to reduce the memory footprint of the ArcPy session, well, you are out of luck. It is true that loading ArcPy (ArcPy for Pro) takes a Python session from 15 MB to nearly 200 MB, but there isn't much you can do about it. If you profile the memory usage of the Python session after loading ArcPy, you will see that a handful of DLLs counts for a vast majority of that increase, and those DLLs are fundamental to the operation of any ArcPy code.