Skip to content

Immutability Implementation Adjustments for PLDI and the PEP #64

@xFrednet

Description

@xFrednet
  • Add new tp_reachable (same signature as tp_traverse) to PyTypeObject (Needed for the PEP not PLDI)
  • Split immutable module into a Python module and a C module
  • Add @freezable, @frozen, @explicitlyFreezable and @unfreezable decorator
  • Add set_freezable() with the values YES, NO, EXPLICIT and PROXY(For modules) to the immutable module
    • Implement the Explicit freezability
    • Check for freezability in freezing code
  • Allow freeze() to take multiple arguments
  • Make freeze() return the (first) passed in object
  • Remove old code from the immutable module, for example immutable_register_freezable
  • Add ImmutableError to the immutable module (Error name and message is open to change)
  • Modules & Types should be unfreezable by default
    • PLDI specific: Modules should have the Proxy immutability by default or different default should be documented
    • Investigate if _PyOwnership_is_c_wrapper is still needed
  • Make shadow_function_globals less smart (Don't freeze values based on strings which might index)
  • Add escape hatches (§6.2):
    • Sub-interpreter Local
    • Cell type
  • Add mutable(obj, ...) context manager to temporarily set freezability to No
    • Maybe add a C mechanism which could be used in a similar way
  • Investigate naming convention, should isfrozen be is_frozen?
    • Either adjust paper (which uses is_frozen)
    • Or our implementation which uses isfrozen
  • Support immutability by construction (§5.3 in the paper)
    • Add register_shallow_freezable(𝑡𝑦𝑝𝑒)
    • Make these objects immutable on first observation
  • Some test were failing for module objects in proxy mode
  • Expose mutable module state in sys.mut_modules
  • Add pre-freeze hook (and check for it)
    • Change module and functions to use the pre-freeze hook instead of if-statement

Pending TODOs, but not critical for PLDI or DPO:

  • Improve RC overhead for frozen objects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions