[Matrix-SIG] RE: Shifted array ops (was: RE: [Matrix-SIG] QUERY: Array indexing)
Sun, 14 Mar 1999 22:47:36 -0500
[Frank Horowitz has an "aha!" experience thanks to Perry Stoll (thanks.
[Tim's toy VectorRotate class in non-NumPy Python]
> If I understand your suggestion correctly, you're doing some trickery
> with indexing *for an individual element* ...
Exactly, and in non-NumPy Python that doesn't generalize to whole-array
> Does the fact that they're overriding the operator class methods imply
> that the result of the calls to getdata index through the array at C
> speeds (courtesy of the NumPy __getitem__ support code)? Or is the
> result that the getdata indexes through the array at interpreter speeds?
I *still* haven't installed NumPy <wink>, but my non-NumPy example class
works at interpreter speed. Presumably combining NumPy slice objects with
NumPy whole-array ops works at C speed, though. Same idea under the covers:
don't copy the data, apply a transformation to the indices. Simple things
like that sure do go faster in C!
> Remember, I'm contemplating applying this stuff (over and over :-) to
> arrays with ~12 million elements. If it runs at interpreter speeds, I'll
> have to look for a different answer.
That part was unclear, since you had mentioned disk thrashing. A gimmick
that can stop *that* can afford to waste a lot of CPU and still win in the
end. That's what I use it for (in non-NumPy Python).
As with all things Python, though, you don't have to choose because
everything's perfect <wink>.
although-perfection-is-often-cleverly-hiding-in-plain-view-ly y'rs - tim