Explanation of list reference

Chris Angelico rosuav at gmail.com
Fri Feb 14 21:42:14 EST 2014


On Sat, Feb 15, 2014 at 1:34 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> At what level can you explain the following?
>
>>>> x = 1234567 * 1234567
>>>> x
> 1524155677489L

Well, for a start, I'd use Python 3, so there's no need to explain why
some numbers have an L after them :)

> As against
>
>>>> x = 2*3
>>>> 6 is x
> True
>
> "Interning" you will say.
> Is interning a simple matter for example at the level of questioning of the OP?

When it's utterly impossible for it to matter in any way, Python is
allowed to reuse objects.

I think that's simple enough to explain. There's nothing you can do to
distinguish one 6 from another, so Python's allowed to have them the
same.

ChrisA



More information about the Python-list mailing list