Slow import of googleapiclient

I’m building an app that interacts with Google’s API services. My forms’ interactions with the server module seemed really slow to me. I examined the individual load times for the all of the imports at the top of my server module and it turns out that the following line would take anywhere from 3 to 5 seconds alone:

from googleapiclient.discovery import build

Has anyone else experienced this type of delay when using googleapiclient.discovery? Is my 3-5 second time to load normal? Any suggestions for optimization?

Thanks so much,

Doug

I can’t say whether that’s normal for that particular import, but some imports are time consuming. For optimization, you can move the import away from the global scope and only into the server functions that actually use it. That would at least keep the other server functions from being delayed by an import they don’t use.

2 Likes

I would ad to what @jshaffstall says that, if you have a Business plan, you can keep the server running, so the import is done very rarely.

2 Likes