forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
- Modules have the
Proxyimmutability by default (But can opt-out)- Use
PyModuleDef_Slotto allow modules to opt-in/out of immutability
- Use
- Add
Py_mod_reachableto module slots
MatP
- Add escape hatches (§6.2):
- Sub-interpreter Local
- Cell type
- Split
immutablemodule into a Python module and a C module - Add new
tp_reachable(same signature astp_traverse) toPyTypeObject(Needed for the PEP)- Add
dict_reachablesincedict_traversedoesn't visit unicode strings.
- Add
- Support immutability by construction (§5.3 in the paper)
- Add
register_shallow_freezable(𝑡𝑦𝑝𝑒) - Make these objects immutable on first observation
- Add
- Add
set_freezable()with the valuesYES,NO,EXPLICITandPROXY(For modules) to theimmutablemodule- Implement the
Explicitfreezability - Check for freezability in freezing code
- Remove special casing for
blocking_onandmodule_lockswhich should never be frozen - There is a check in
traverse_freezewhich should be removed in favour of this mechanism. Probably incheck_freezable
- Implement the
- Allow
freeze()to take multiple arguments - Make
freeze()return the (first) passed in object - Fix rollback of SCC given failed freeze.
- Remove old code from the
immutablemodule, for exampleimmutable_register_freezable - Remove not freezable type once explicit freezability is in.
- Add
mutable(obj, ...)context manager to temporarily setfreezabilitytoNo- Maybe add a C mechanism which could be used in a similar way
- C-Types should be unfreezable by default? Or the difference should be documented
Tobias
- Add
@freezable,@frozen,@explicitlyFreezableand@unfreezabledecorator
Fred
- Remove
is_freezable_builtinin favour ofset_freezable()for all the listed types - Remove
_PyImmutability_RegisterFreezableandstate->freezable_types - Investigate naming convention, should
isfrozenbeis_frozen?- Either adjust paper (which uses
is_frozen) - Or our implementation which uses
isfrozen
- Either adjust paper (which uses
- Add pre-freeze hook (and check for it)
- Change module and functions to use the pre-freeze hook instead of
if-statement
- Change module and functions to use the pre-freeze hook instead of
- Fix (most) "freeze: type 'XYZ' has no tp_traverse and no tp_reachable" warnings
- Expose mutable module state in
sys.mut_modules - Make
shadow_function_globalsless smart (Don't freeze values based on strings which might index) - Some test were failing for module objects in proxy mode
David
- How do we handle weak references??
_PyWeakref_GET_REFneeds a_Py_IsImmutablebranch which requires aTryIncrefwhich is hard for SCCs...- Freeing requires GILs of different interpreters
Pending TODOs, but not critical for PLDI or DPO:
- Add
ImmutableErrorto the immutable module (Error name and message is open to change) - Investigate if
_PyOwnership_is_c_wrapperis still needed - Improve RC overhead for frozen objects
- https://github.com/mjp41/cpython/blob/b6510b9c60b441f3bcdcdc2ce124c78fff44a98e/Objects/typeobject.c#L6599
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels