Re: Understanding memory location of Python variables

2018-06-18 Thread Jeremy Black
Also, I don't think you can rely on memory being allocated sequentially any more now that everyone has implemented some level of ASLR. https://en.wikipedia.org/wiki/Address_space_layout_randomization On Sat, Jun 16, 2018 at 12:22 PM Alister via Python-list < python-list@python.org> wrote: > On S

Re: Understanding memory location of Python variables

2018-06-18 Thread Daniel Montecillo
I am also wondering about this behavior. Thank you Chris A for providing the explanation. On Jun 16, 2018, at 5:45 PM, Chris Angelico mailto:ros...@gmail.com>> wrote: On Sun, Jun 17, 2018 at 2:38 AM, mailto:ip.b...@gmail.com>> wrote: Hi everyone, I'm intrigued by the output of the following

Re: Understanding memory location of Python variables

2018-06-17 Thread Peter Pearson
On Sat, 16 Jun 2018 09:38:07 -0700 (PDT), ip.b...@gmail.com wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally > contrary to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36

Re: Understanding memory location of Python variables

2018-06-17 Thread Dan Stromberg
On Sun, Jun 17, 2018 at 5:05 AM, Marko Rauhamaa wrote: > Bart : > > So, how /do/ you obtain the memory address of those values are > > located? For example, in order to pass it to some foreign C function > > that takes a void* parameter. > > That is dependent on the Python implementation. CPython

Re: Understanding memory location of Python variables

2018-06-17 Thread Marko Rauhamaa
Bart : > So, how /do/ you obtain the memory address of those values are > located? For example, in order to pass it to some foreign C function > that takes a void* parameter. That is dependent on the Python implementation. CPython supports native C and C++ extensions: https://docs.python.org/3

Re: Understanding memory location of Python variables

2018-06-17 Thread Steven D'Aprano
On Sun, 17 Jun 2018 11:01:41 +0100, Bart wrote: > So, how /do/ you obtain the memory address of those values are located? You don't. There is no implementation-independent Python function to get the memory address of an object. The concept of a fixed memory address for objects is not even a sen

Re: Understanding memory location of Python variables

2018-06-17 Thread Chris Angelico
On Sun, Jun 17, 2018 at 8:01 PM, Bart wrote: > On 17/06/2018 03:28, Grant Edwards wrote: >> >> On 2018-06-16, ip.b...@gmail.com wrote: >> >>> I'm intrigued by the output of the following code, which was totally >>> contrary to my expectations. Can someone tell me what is happening? >>> >> myN

Re: Understanding memory location of Python variables

2018-06-17 Thread Bart
On 17/06/2018 03:28, Grant Edwards wrote: On 2018-06-16, ip.b...@gmail.com wrote: I'm intrigued by the output of the following code, which was totally contrary to my expectations. Can someone tell me what is happening? myName = "Kevin" id(myName) 47406848 id(myName[0]) 36308576 id(myName

Re: Understanding memory location of Python variables

2018-06-16 Thread Grant Edwards
On 2018-06-16, ip.b...@gmail.com wrote: > I'm intrigued by the output of the following code, which was totally > contrary to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36308576 id(myName[1]) > 2476000 What'

Re: Understanding memory location of Python variables

2018-06-16 Thread Chris Angelico
On Sun, Jun 17, 2018 at 2:38 AM, wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally contrary > to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36308576 id(myName[1]

Re: Understanding memory location of Python variables

2018-06-16 Thread Steven D'Aprano
On Sat, 16 Jun 2018 09:38:07 -0700, ip.bcrs wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally > contrary to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36308576 i

Re: Understanding memory location of Python variables

2018-06-16 Thread Alister via Python-list
On Sat, 16 Jun 2018 13:19:04 -0400, Joel Goldstick wrote: > On Sat, Jun 16, 2018 at 12:38 PM, wrote: >> Hi everyone, >> >> I'm intrigued by the output of the following code, which was totally >> contrary to my expectations. Can someone tell me what is happening? >> > myName = "Kevin" > i

Re: Understanding memory location of Python variables

2018-06-16 Thread MRAB
On 2018-06-16 17:38, ip.b...@gmail.com wrote: Hi everyone, I'm intrigued by the output of the following code, which was totally contrary to my expectations. Can someone tell me what is happening? myName = "Kevin" id(myName) 47406848 id(myName[0]) 36308576 id(myName[1]) 2476000 I expecte

Re: Understanding memory location of Python variables

2018-06-16 Thread Joel Goldstick
On Sat, Jun 16, 2018 at 12:38 PM, wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally contrary > to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36308576 id(myName[1

Understanding memory location of Python variables

2018-06-16 Thread ip . bcrs
Hi everyone, I'm intrigued by the output of the following code, which was totally contrary to my expectations. Can someone tell me what is happening? >>> myName = "Kevin" >>> id(myName) 47406848 >>> id(myName[0]) 36308576 >>> id(myName[1]) 2476000 I expected myName[0] to be located at the same