Negative array indicies and slice()
Ian Kelly
ian.g.kelly at gmail.com
Tue Oct 30 18:02:06 EDT 2012
On Tue, Oct 30, 2012 at 3:55 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Tue, Oct 30, 2012 at 8:21 AM, Andrew Robinson
> <andrew3 at r3dsolutions.com> wrote:
>> D'Apriano mentioned the named values, start, stop, step in a slice() which
>> are an API and legacy issue; These three names must also be stored in the
>> interpreter someplace. Since slice is defined at the "C" level as a struct,
>> have you already found these names in the source code (hard-coded), or are
>> they part of a .py file associated with the interface to the "C" code?
>
> You mean the mapping of Python attribute names to C struct members?
> That's in sliceobject.c:
>
> static PyMemberDef slice_members[] = {
> {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY},
> {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY},
> {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY},
> {0}
> };
Note that the slice API also includes the slice.indices method.
They also implement rich comparisons, but this appears to be done by
copying the data to tuples and comparing the tuples, which is actually
a bit ironic considering this discussion. :-)
More information about the Python-list
mailing list