A question on modification of a list via a function invocation

Rhodri James rhodri at kynesim.co.uk
Wed Sep 6 06:45:52 EDT 2017


On 05/09/17 23:29, Grant Edwards wrote:
> On 2017-09-05, Marko Rauhamaa<marko at pacujo.net>  wrote:
> 
>> Pointer arithmetics is not an essential part of C. One could argue that
>> it was a mistake to include it in the language.
> One may argue that it was a mistake, but I remember at least one
> implementation where pointer arithmetic was hugely more efficient than
> indexing into arrays.  Incrementing a pointer through an array was
> way, way faster than indexing through the array by incrementing an
> array subscript.
> 
> But, that was 25 years ago on an 8-bit CPU where where integer
> multiplies were expensive.  The last time I compare the two methods
> with a recent GCC on a 32-bit CPU, it generated pretty much the same
> code either way...

That's the optimiser at work, turning what you wrote into the best fit 
to the processor architecture.  On an ARM, for example, that would 
likely still be incrementing a pointer through an array.

-- 
Rhodri James *-* Kynesim Ltd



More information about the Python-list mailing list