[Python-Dev] PEP 203 Augmented Assignment

Ka-Ping Yee ping@lfw.org
Thu, 27 Jul 2000 10:31:56 -0700 (PDT)

On Thu, 27 Jul 2000, Ka-Ping Yee wrote:
> So, how about:
>     __get__(index, ...)              # I want an ITEM.
>     __getslice__(slice-object, ...)  # I want a SLICE.


For __set__ and __setslice__, since there may be a variable number
of index arguments, it seems the value to set must *precede* the
indices.  The full interface:

    __set__(value, *indices)
    __setslice__(value, *slices)

I prefer putting the indices last to passing in a tuple of indices
for the following reasons:
1.  It would be annoying and slightly slower to have to
    declare __get__((index,)) instead of __get__(index).

2.  I want to encourage prediction of the number of indices.
    Since most multidimensional types are likely to have a
    fixed number of dimensions, it's better to have an
    interface look like, e.g.

        __get__(x, y, z)    # Clearly a 3-dimensional array!

    instead of
        __get__(indices)    # Don't know how many dimensions.

    The error is caught earlier, and the expectations of
    the programmer are more visible.

    To implement a variable number of dimensions, of course
    one can always write


    but this would not be the conventional thing to write:
    it would make clear that there is something special
    going on here.

-- ?!ng