[MATRIX-SIG] A proposal (LONG) - "reverse of take" revisited
Aaron Watters
arw@dante.mh.lucent.com
Wed, 2 Jul 1997 07:21:37 -0400
> axisoffset = (slice(None,None,None),)*axis
> for i in range(len(seq)):
> a[axisoffset+(seq[i],)] = b[axisoffset+(i,)]
hmmm. After looking at this code I see that part of my
problem was my lack of understanding of the overloading
of indexing. I didn't know that
ar[ array([1,2]) ]
would work. Since it does (without copying anything)
:) a Python implementation of
"give" or "set" or whatever you want to call it actually might
be fast enough for practical purposes. I suppose each
iteration of the loop would require only one header malloc,
which might be inexpensive enough, and a C implementation
might not be too much better. Comment withdrawn?
I knew it was likely I was being dumb.
Where are the details of all the functionality of Numeric
set out? I have to say that it's a shame there isn't
better documentation that I can find. Sorry if I missed it
in DA's tutorial or somewhere else I'm unaware of.
In particular things that aren't immediately obvious to
me are the reference vs. copy semantics, how indexing/slicing
works exactly, probably more I haven't run into yet.
-- Aaron Watters
note: fancy indexing is fine if you experts think it
would be a Good Thing, but remember that Guido
does not change the syntax lightly, for good reason.
Just imagine what damage the regex community
could have done by now if he hadn't resisted. My
preference would be to be conservative here until
maybe a clear consensus arrives in many months.
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________