File: optimization.rst

package info (click to toggle)
nipy 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,352 kB
  • sloc: python: 39,115; ansic: 30,931; makefile: 210; sh: 93
file content (45 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.. _optimization:

==============
 Optimization
==============

In the early stages of NIPY development, we are focusing on
functionality and usability.  In regards to optimization, we benefit
**significantly** from the optimized routines in scipy_ and numpy_.
As NIPY progresses it is likely we will spend more energy on
optimizing critical functions.  In our `py4science group at UC
Berkeley <https://cirl.berkeley.edu/view/Py4Science/WebHome>`_ we've
had several meetings on the various optimization options including
ctypes, weave and blitz, and cython.  It's clear there are many good
options, including standard C-extensions.  However, optimized code
tends to be less readable and more difficult to debug and maintain.
When we do optimize our code we will first profile the code to
determine the offending sections, then optimize those sections. Until
that need arises, we will follow the great advice from these fellow
programmers:


Kent Beck:
  "First make it work.  Then make it right.  Then make it fast."

`Donald Knuth on optimization
<http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize>`_:

  "We should forget about small efficiencies, say about 97% of the
  time: premature optimization is the root of all evil."


Tim Hochberg, from the Numpy list::

    0. Think about your algorithm.
    1. Vectorize your inner loop.
    2. Eliminate temporaries
    3. Ask for help
    4. Recode in C.
    5. Accept that your code will never be fast.

    Step zero should probably be repeated after every other step ;)


.. include:: ../../links_names.txt