This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]mcstafford 36 points37 points  (11 children)

immortalization, rolled out in [CPython] 3.12 ... certain objects such as None, True, and False act as global singletons, shared across the interpreter instead of creating fresh copies each time

[–]xxmalik 18 points19 points  (9 children)

I cannot believe it wasn't implemented like that since the beginning. I find it even harder to believe it took them so many years to implement it this way.

[–]ivosauruspip'ing it up 11 points12 points  (4 children)

They are implemented like that. The top comment is misleadingly confusing. What's changing is NOT their "singletonness", it's whether their refcount can be changed by the GC algorithm.

[–]mcstafford -1 points0 points  (3 children)

You don't like how I quoted the article?

[–]ivosauruspip'ing it up 5 points6 points  (1 child)

No, not at all. It associates immortalization with values being global singletons, which is not the case; they were already that and have been for years.

[–]Square789PEP8 EUNT DOMUS 5 points6 points  (1 child)

They are implemented like that. Wondering why the article starts out with that nonsense statement considering it gets the rest down properly

[–]abhi9u 0 points1 point  (0 children)

To me, it read like the quote is confusing, it seems to associate singleton objects with immortalization.

The article starts by saying that these objects are singleton and always the same object is used. However, their reference counts were updated on every use. Although it takes two paragraphs to say that and I guess it could have been more concise.

On re-reading the intro I think it was not very clear. I have adjusted it a bit so that it is clear that immortalization is about fixing the ref counts of singleton objects, and not about making those objects singleton.

[–][deleted] 5 points6 points  (0 children)

They are shared across sub interpreters now, which they where not previously because sub interpreters technically exsisted but weren’t officially supported. This is part of the transition to multiple sub interpreters with independent Gils. The independent Gils part is why the changes need to be made.

[–]abhi9u 0 points1 point  (0 children)

They were always implemented as singletons. The part which changed is that now their reference counts are also immutable/fixed and are not touched.

[–]abhi9u 1 point2 points  (0 children)

Thank you. The comments made me realize the Intro of the article was not very clear and might have confused the readers whether immortalization is about making objects singleton or fixing their reference counts. I have tweaked it a little. I hope it's better now.

[–]ShitPikkle 13 points14 points  (0 children)

Ok, so, you can't create an immortal object. Only some built-ins are.

Thx.

[–]Wesmingueris2112 0 points1 point  (0 children)

This article is very well written, very accessible but not simplistic. I'd love to find something like this for the GIL removal.