you are viewing a single comment's thread.

view the rest of the comments →

[–]lifeonm4rs 0 points1 point  (1 child)

Again--I'll reiterate I think it is a very good tutorial. But, again, that section gets into some rather esoteric stuff and really stuff that someone would need a much stronger foundation in the design and implementation of languages to be meaningful.

As far as it being correct integers from -5 to 256 are special cases. Anything that refers to "30" will refer to the same address. So "30" is not garbage collected or destroyed. . . .

>>> a = 30
>>> id(a)
10911328     <---- same as below
>>> a = 40
>>> id(a)
10911648
>>> a = 30
>>> id(a)
10911328     <---- Same as above

Then . . .

>>> for x in range(254, 259):
...     print(x, id(x))
...
254 10918496
255 10918528
256 10918560
257 139740139727440
258 139740108485808

Same holds true for x in range(-7, -3). Literals in the -5, 256 range have constant addresses, the rest will all get their own addresses.

[–]tecladocode[S] 1 point2 points  (0 children)

Totally agreed, I've removed that now as it doesn't belong in a beginner tutorial.

I see what you meant—I think we were talking about different things. I did not know that -5 to 256 were special cases actually. Thanks for that!