I'm finding it increasingly useful for certain types of lazy initialization in a freethreaded world. Illustrative example:
# Python illustration for simplicity
some_useful_thing = some_dict.get("key", None)
if some_useful_thing is None:
some_useful_thing = slightly_expensive_construction()
some_useful_thing = some_dict.setdefault("key", some_useful_thing)
Essentially for problems where you'd rather do slightly_expensive_construction once (but if you accidentally end up doing it twice then it doesn't really matter). But the most important thing is that everyone uses the same cached attribute at the end of the process.
Obviously it's possible to access it through a Python function call in the current Stable ABI, but more direct access would be nice.
I'm finding it increasingly useful for certain types of lazy initialization in a freethreaded world. Illustrative example:
Essentially for problems where you'd rather do
slightly_expensive_constructiononce (but if you accidentally end up doing it twice then it doesn't really matter). But the most important thing is that everyone uses the same cached attribute at the end of the process.Obviously it's possible to access it through a Python function call in the current Stable ABI, but more direct access would be nice.