Skip to content

Commit

Permalink
* deflarry.py(__align), RELEASE: 80x speed increase in binary operat…
Browse files Browse the repository at this point in the history
…ions

      (+, -, *, &, etc) timed with two larrys of shape (1000,) with unaligned
      labels. The cost is a 2% slowdown for shapes (10,).
  • Loading branch information
kwgoodman committed May 24, 2010
1 parent dd90e6c commit a1e9b6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,5 +1,9 @@
2010-05-23 Keith

* deflarry.py(__align): 80x speed increase in binary operations (+, -,
etc) timed with two larrys of shape (1000,) with unaligned labels. The
cost is a 2% slowdown for shapes (10,).

* doc/source/intro.rst: Tweak.

* doc/source/intro.rst: Added a new section: la at a glance.
Expand Down
2 changes: 2 additions & 0 deletions RELEASE
Expand Up @@ -23,6 +23,8 @@ New functions

Enhancements
------------
- Faster binary operations (+, -, *, &, etc) between two large unaligned
larrys; For shape (10000,) the speed up is 80x; for (10,) slowdown is 2%
- You can now use an optional dtype when creating larrys
- Add ability to compare (==, >, !=, etc) larrys with lists and tuples
- Documentation and unit tests
Expand Down
7 changes: 5 additions & 2 deletions la/deflarry.py
Expand Up @@ -2,6 +2,7 @@

from copy import deepcopy
import csv
from itertools import izip

import numpy as np

Expand Down Expand Up @@ -903,8 +904,10 @@ def __align(self, other):
if len(lab) == 0:
raise IndexError, 'A dimension has no matching labels'
lab.sort()
ids = map(ls.index, lab)
ido = map(lo.index, lab)
lsmap = dict(izip(ls, range(len(ls))))
lomap = dict(izip(lo, range(len(lo))))
ids = [lsmap[i] for i in lab]
ido = [lomap[i] for i in lab]
label.append(lab)
idxs.append(ids)
idxo.append(ido)
Expand Down

0 comments on commit a1e9b6a

Please sign in to comment.