Module load times
stefan_ml at behnel.de
Thu Aug 13 21:12:08 CEST 2015
Joseph L. Casale schrieb am 13.08.2015 um 18:56:
> I have an auto generated module that provides functions exported from a
> c dll. Its rather large and we are considering some dynamic code generation
> and caching, however before I embark on that I want to test import times.
> As the module is all auto generated through XSL, things like __all__ are not
> used, a consumer only imports one class which has methods for their use.
> It is the internal supporting classes which are large such as the ctype function
> prototypes and structures.
How is the DLL binding implemented? Using "ctypes"? Or something else?
Obviously, instantiating a large ctypes wrapper will take some time. A
binary module would certainly be quicker here, both in terms of import time
and execution time. Since you're generating the code anyway, generating
Cython code instead shouldn't be difficult but would certainly yield faster
> My concern is simply reloading this in Python 3.3+ in a timeit loop is not
> accurate. What is the best way to do this?
What makes you think the import might be a problem? That's a one-time
thing. Or is your application a command-line tool or so that needs to start
and terminate quickly?
More information about the Python-list