importing module-performance

S.Selvam Siva s.selvamsiva at
Mon Feb 2 11:11:56 CET 2009

On Mon, Feb 2, 2009 at 3:11 PM, Chris Rebert <clp2 at> wrote:

> On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva <s.selvamsiva at>
> wrote:
> > Hi all,
> > I have a small query,
> > Consider there is a task A which i want to perform.
> >
> > To perform it ,i have two option.
> > 1)Writing a small piece of code(approx. 50 lines) as efficient as
> possible.
> > 2)import a suitable module to perform task A.
> >
> >
> > I am eager to know,which method will produce best performance?
> A. Your question seems much too vague to answer.
> B. Premature optimization is the root of all evil. In all likelihood,
> the time taken by the `import` will be absolutely trivial compared to
> the rest of the script, so don't bother micro-optimizing ahead of
> time; write readable code first, then worry about optimization once
> it's working perfectly.
> Cheers,
> Chris
> --
> Follow the path of the Iguana...

Thank you Chris,

 I faced a optimization problem as follow,

For fuzzy string comparison initially i used 15 lines of code which compares
a word with 29,000 words in a list .For each set of words compared, the
15-line code produce number of differences characters of the two words.

But when i used python-levenshtein module for same reason it has run faster
than the old method.This invoked me to raise that query.

Now i understood that, it is not an issue of importing the module/writing
the code, but the problem must be with my 15-line code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list