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 Sat, 16 Jun 2018 13:19:04 -0400, Joel Goldstick wrote: > > > On Sat, Jun 16, 2018 at 12:38 PM, <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 expected myName[0] to be located at the same memory location as the > >> myName variable itself. I also expected myName[1] to be located > >> immediately after myName[0]. > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > > > > Others can probably give a more complete explanation, but small numbers, > > and apparently letters are cached since they are so common. > > also ID is not necessarily a memory location (at least not according to > the language specification) > the standard cpython implementation does user the memory location for an > object's ID but this is an implementation detail > > if you are tying to make use of ID in any way to manipulate computer > memory your program is fundamentaly broken > > > > -- > Can you MAIL a BEAN CAKE? > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list