Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66459 > unrolled thread

inheriting a large python code base

Started byRita <rmorgan466@gmail.com>
First post2014-02-15 12:10 -0500
Last post2014-02-21 13:36 -0800
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  inheriting a large python code base Rita <rmorgan466@gmail.com> - 2014-02-15 12:10 -0500
    Re: inheriting a large python code base craig@milhiser.com - 2014-02-21 13:36 -0800

#66459 — inheriting a large python code base

FromRita <rmorgan466@gmail.com>
Date2014-02-15 12:10 -0500
Subjectinheriting a large python code base
Message-ID<mailman.7008.1392484241.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

hi all,

i just inherited a large python code base and I would like to optimize the
code (run faster). The application is a scientific application so I really
don't understand the internal logic.

Here is what I have done so far, profile (cProfile) and was able to see
where the code was taking the longest time.

I was wondering if anyone else experienced something like this and how they
overcame a problem such a this...what techniques have you used to "optimize"
the code.




-- 
--- Get your facts first, then you can distort them as you please.--

[toc] | [next] | [standalone]


#66852

Fromcraig@milhiser.com
Date2014-02-21 13:36 -0800
Message-ID<85611dc7-4691-4514-9355-0f3a7fcda5e3@googlegroups.com>
In reply to#66459
Look at the algorithms and see if there are faster ways.  Great advice with the comments of writing test cases, getting into version control, taking passes through the code with tools, understanding what is slow and why it is considered slow.  Then you should invest the time to understand the internal logic and the algorithms.  Understand the performance O(N log N), O(N^2), O(2^N). See if there are better algorithms that should be used - is there an O(N).  Implement that algorithm, test, then compare performance.  Finally optimize the coding constructs.  Depending on how long your program takes (a few milli-secs, a few secs, a few hours, a few days), optimized coding constructs may make no measurable difference.  Finding better algorithms will.  But a better algorithm changing code from 2 milli-secs to 1 milli-sec is only useful in specific environments - so it may not be worth your effort.  Understand the performance of the code and the environment it is executed in.

That is how I have gone about it type of work.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web