[MATRIX-SIG] A proposal (LONG) - "reverse of take" revisited

Chase, Chris chase@att.com
Fri, 11 Jul 1997 12:08:04 -0400


Allowing arrays to be indexes (or any sequence object for that matter)
in the array module is very doable.  But it is a huge amount of work.
At different times during the past year I have looked at concepts and
implementations for this.  But after looking at the code (last year and
again this week) it would require rewriting a majority of the routines
in the array module and associated files.  This is because the use of
strides is heavily embeded in the code and there is no separation
between array representation and the interface and helper functions.
The job is more difficult because the comments about what the code is
trying to do are very scarce (but I have a very old version of the
sources).  

Some side comments:

Slices that go outside array bounds are silently projected onto the
bounds while take() generates an error when the index vector goes
outside the bounds.  If arrays were allowed as indexes should they
behave like slices or like take()?

The behavior of the array module is that indexing an array produces a
reference to the original data unless a scalar is produced.  In allowing
arrays as indexes, the array reference representation would have to keep
copies of the index array.  This does not take any more space than
actually producing a copy of the data than producing a reference.

Reshaping has to generate a copy unless the input array was already
contiguous.  If arrays as well as slices are allowed as indexes and kept
in the array representation, then an array reshape could also produce a
reference to the original data.

Arrays as indexes kept in the representation also allow compact
representations of array replication (e.g. repeating certain
dimensions).

I am interested in attempting to make the modifications.  But I think
that the job is too big (i.e. too time-consuming of my spare time) to
complete alone.  Also there may be opposition to making extensive
changes within the code (although the array object interface would
remain the same) because some individuals may depend on the actual
representation/implementation.

Chris Chase
chase@att.com




_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________