On Tue, Jul 31, 2018 at 02:58:56AM +1000, Steven D'Aprano wrote:
> The *only* thing you have seen which is a language feature is this rule:
>
> - if two objects, a and b, have the same ID *at the same time*, then
> "a is b" will be true;
>
> - if "a is b" is false, then a and b must have diff
On Mon, Jul 30, 2018 at 09:21:01AM -0600, Mats Wichmann wrote:
> (id does not necessarily mean memory location, by the way)
id() *never* means memory location in Python. id() *always* returns an
opaque integer ID number which has no promised meaning except to be
unique while the object is alive
On Mon, Jul 30, 2018 at 3:20 PM, Sunil Tech wrote:
> Python memory allocation is varying in all these use cases. Please help me
> understand.
CPython is interning small integers and small strings as a form of optimisation.
"The current implementation keeps an array of integer objects for all
int
On Mon, Jul 30, 2018 at 06:50:59PM +0530, Sunil Tech wrote:
> Hi Team,
>
> I am investigating how the memory allocation happens in Python
You cannot investigate memory allocation in Python code, because the
Python execution model does not give you direct access to memory.
What you can investiga
On 07/30/2018 07:20 AM, Sunil Tech wrote:
> Hi Team,
>
> I am investigating how the memory allocation happens in Python
There are several things going on here, but the main thing to know is:
but Python language _implementations_ optimize when they can and think
it makes sense. So don't draw too m
On Mon, Jul 30, 2018 at 9:20 AM, Sunil Tech wrote:
> Hi Team,
>
> I am investigating how the memory allocation happens in Python
> For Eg:
> *Case 1:*
>
a = 10
b = 10
c = 10
id(a), id(b), id(c)
> (140621897573616, 140621897573616, 140621897573616)
a += 1
id(a)
> 14062
Hi Team,
I am investigating how the memory allocation happens in Python
For Eg:
*Case 1:*
>>> a = 10
>>> b = 10
>>> c = 10
>>> id(a), id(b), id(c)
(140621897573616, 140621897573616, 140621897573616)
>>> a += 1
>>> id(a)
140621897573592
*Case 2:*
>>> x = 500
>>> y = 500
>>> id(x)
4338740848
>>>