A question on modification of a list via a function invocation

Chris Angelico rosuav at gmail.com
Thu Sep 7 10:28:27 EDT 2017


On Thu, Sep 7, 2017 at 11:21 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Rustom Mody wrote:
>
>> I said: In that case please restate the definition of 'is' from the manual
>> which invokes the notion of 'memory' without bringing in memory.
>
>
> I don't know whether it's in the manual, but at least for
> mutable objects, there is a way to define the notion of
> "same object" that doesn't require talking about "memory":
>
> Two names refer to the same object if and only if mutations
> made through one are visible through the other.
>
> Python has definite rules concerning when mutable objects
> will be the same or not, and every correct implementation
> must conform to them. In that sense it's a fundamental
> concept that doesn't depend on implementation.

Yep. I'd call this a litmus test rather than a definition, but it's
absolutely true - and it's why languages without mutable objects don't
really care whether they're pass-by-X or pass-by-Y.

ChrisA



More information about the Python-list mailing list