Comparing two variables with 'is' operator which are declared in one line in Python
Question: According to the [Documentation](https://docs.python.org/2/c-api/int.html):

> The current implementation keeps an array of integer objects for all
> integers between `-5` and `256`, when you create an int in that range you
> actually just get back a reference to the existing object. So it should be
> possible to change the value of `1`. I suspect the behaviour of Python in
> this case is undefined. :-)

So the following behaviors are normal.

    
    
    >>> a = 256
    >>> b = 256
    >>> a is b
    True
    >>> c = 257
    >>> d = 257
    >>> c is d
    False
    

But when i declare two variables like these, i am getting **True** -

    
    
    >>> e = 258; f=258;
    >>> e is f
    True
    

I have checked the identity of the objects referenced by e and f-

    
    
    >>> id(e)
    43054020
    >>> id(f)
    43054020
    

They are same.

My question is what is happening when we are declaring e and f by separating
with semicolons? Why are they referencing to the same object (though the
values are out of the range of Python's array of integer objects) ?

It would be better, if you please explain it like you are explaining it to a
beginner.


Answer: This is _not_ an unexpected behavior, according to [Python Data
model](https://docs.python.org/2/reference/datamodel.html) it's an
implementation detail:

> Types affect almost all aspects of object behavior. Even the importance of
> object identity is affected in some sense: **for immutable types, operations
> that compute new values may actually return a reference to any existing
> object with the same type and value, while for mutable objects this is not
> allowed. E.g., after a = 1; b = 1, a and b may or may not refer to the same
> object with the value one, depending on the implementation** , but after c =
> []; d = [], c and d are guaranteed to refer to two different, unique, newly
> created empty lists. (Note that c = d = [] assigns the same object to both c
> and d.)

