NEWBIE: ishexdigit revisited

Terry Reedy tjreedy at udel.edu
Tue Dec 30 13:21:58 EST 2003


>>     def ishexnumber(sx):
>>         import re

> If I run this many times, as is likely in our application, does the
> 'import re' chew up memory?

No.  Imported modules are cached in sys.modules.  After the first import,
'import x' is equivalent to "x = sys.modules['x']" (or something like
this).






More information about the Python-list mailing list