Python "why" questions

MRAB python at
Thu Aug 19 21:43:51 CEST 2010

Russ P. wrote:
> On Aug 19, 11:42 am, Steven D'Aprano <st... at REMOVE-THIS-
>> wrote:
>> On Thu, 19 Aug 2010 11:03:53 -0700, Russ P. wrote:
>>> For those who insist that zero-based indexing is a good idea, why you
>>> suppose mathematical vector/matrix notation has never used that
>>> convention? I have studied and used linear algebra extensively, and I
>>> have yet to see a single case of vector or matrix notation with zero-
>>> based indexing in a textbook or a technical paper. Also, mathematical
>>> summation is traditionally shown as "1 to N", not "0 to N-1".
>> In my experience, it's more likely to be "0 to N" than either of the
>> above, thus combining the worst of both notations.
>>> Are
>>> mathematicians just too simple-minded and unsophisticated to understand
>>> the value of zero-based indexing?
>> No, mathematicians are addicted to tradition.
> That is probably true. But computer languages are addicted to more
> than tradition. They're addicted to compatibility and familiarity. I
> don't know where zero-based indexing started, but I know that C used
> it very early, probably for some minuscule performance advantage. When
> C++ came along, it tried to be somewhat compatible with C, so it
> continued using zero-based indexing. Then Java was loosely modeled
> after C++, so the convention continued. Python was written in C, so
> zero-based indexing was "natural." So the whole thing is based on a
> decision by some guy who was writing a language for operating systems,
> not mathematics or application programming.
C was derived ultimately from BCPL.

In C array indexing is syntactic sugar for pointer arithmetic with
dereferencing, so:


means the same as:

     *(p + i)

BCPL, IIRC, didn't use the familiar indexing syntax. !p was the
equivalent of *p and p!i was short for !(p + i), the equivalent of p[i].

More information about the Python-list mailing list