this post was submitted on 16 Aug 2023
1 points (100.0% liked)

Python

5396 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago

Contributing immortal objects into Python introduces true immutability guarantees for the first time ever. It helps objects bypass both reference counts and garbage collection checks. This means that we can now share immortal objects across threads without requiring the GIL to provide thread safety.

This is actually really cool. In general, if you can make things immutable or avoid state, then that will help you structure things concurrently. With immortal objects you now can guarantee that immutability without costly locks. It will be interesting to see what the final round of benchmarks are when this is fully implemented.

[–] [email protected] 0 points 1 year ago (1 children)

Can't this result in ugly memory leaks?

[–] [email protected] 1 points 1 year ago

@Sternout @jnovinger
Maybe, but (apart from the "Accidental Immortalisation" case mentioned in PEP 683) these things are created deliberately by C extensions.
A sane extension shouldn't be building loads of them on the fly in the first place.