Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time taken by an import in Python

Tags:

python

import

I want to know how much time an import takes for both built-in as well as user defined modules.

like image 428
user46646 Avatar asked Apr 20 '09 11:04

user46646


1 Answers

Starting from Python3.7 releaese, new -X importtime option is available. To measure import time, just simply execute your script with that option, e.g. python -X importtime my_script.py.

For reference:

  • https://docs.python.org/3.7/using/cmdline.html#id5
like image 106
Szymon P. Avatar answered Sep 24 '22 13:09

Szymon P.