[Python-Dev] C extension import time
Stefan Krah
stefan at bytereef.org
Fri Oct 11 14:24:29 CEST 2013
Hi,
recently there has been some talk about reducing import times. It seems
that the current import strategy for C extensions (i.e. importing the
extension at the bottom of the .py file) is quite slow:
====================
import sys
for i in range(10000):
import decimal
del sys.modules('decimal')
del sys.modules('_decimal')
====================
With the regular decimal.py the script is about 9 times slower than running
it with a modified decimal.py that just contains "from _decimal import *".
I don't know enough about the import mechanism to say whether this is
a particularly good benchmark. If it is, perhaps we should devise another
strategy for loading C extensions.
Stefan Krah
More information about the Python-Dev
mailing list