is importing redundantly harmful/wasteful?

Pettersen, Bjorn S BjornPettersen at fairisaac.com
Tue Sep 16 20:45:49 CEST 2003


> From: python at sarcastic-horse.com [mailto:python at sarcastic-horse.com] 
> 
> I'm writing a function and it needs to use regular expressions and the
> super-fantastic mx.DateTime module.  The first lines after 
> the doc string
> in the function are:
> 
>     import re, mx.DateTime
> 
> I'll be using this function in a bunch of different programs.  Some of
> those programs might need re and mx.DateTime for other tasks.
> 
> In some cases, I'll be redundantly importing these modules.  
> Should I care if I'm re-importing re and mx.DateTime even after
they've 
> been imported? 

No.

> Does python do some sort of checking for this stuff 

Yes.

> or do I need to?

No.

-- bjorn





More information about the Python-list mailing list