importing down in code rather than at top of file.

Tobiah toby at tobiah.org
Mon Aug 29 13:57:22 EDT 2016


Is it  worth while to defer the import of a large module that seldom
gets used in the script?


	import sys
	import os

	if hardly_ever_happens():
		
		import large_module
		large_module.do_task()



I imagine it takes a certain amount of processing
power and memory to import a module, so it seems
like I'd save those resources with the above pattern.

The down side would be that it's nice to see all of the
imports at the top which would follow convention.  Should
I care?


Tobiah






More information about the Python-list mailing list