[Tutor] who makes FOR loop quicker

John Doe z2911 at bk.ru
Thu Aug 6 16:41:54 CEST 2015

Try this look. But I'm just a human and can make mistakes.:))

Passing value - allocates stack and creates NEW memory position.
Passing reference - makes stack pointer pointing to any position.
Dereference - makes stack pointer pointing to any position AND TAKES VALUE.

So, You can count how much in every case does CPU make steps.
And now add to this BIG ARRAY as input for calculation.

Always must keep in mind, that the NAME of variable exists for SCOPE of
You code, but VALUE - for CPU.

So, reference will be always, unless CPU have reached quantum-mechanics

Steven D'Aprano 於 08/06/2015 05:21 PM 寫道:
> On Thu, Aug 06, 2015 at 08:57:34AM -0400, Joel Goldstick wrote:
>> On Thu, Aug 6, 2015 at 4:34 AM, John Doe <z2911 at bk.ru> wrote:
>>> Can You, please, elaborate this "..Passing in Python is different than in C
>>> or other languages..."
>> I hesitate, because this question is usually the fuel of flaming wars.
> Very wise :-)
> But since I'm not so wise, here are some more comments.
>> So in short:
>> C can pass a value or a reference to a value (the address of the place
>> in memory where the value is stored)
> You are correct that C can pass a reference to a value, namely a
> pointer. But from the perspective of the C compiler, that pointer *is*
> the value, not the thing being pointed at. So passing a pointer as
> argument is no different from passing an int or a float or a bool, it's
> just a value, and the C compiler will use pass by value on the pointer
> itself.
> In C, one can use pointers to *simulate* pass by reference. But this is
> not the same thing as actual pass by reference. In pass by reference,
> you don't pass (a pointer to the variable you want), you pass (the
> variable you want), and the compiler does all the magic needed to make
> it work.

More information about the Tutor mailing list