Skip to content

ENH: Serialize null interface as literal #226

Description

@fumitoh

When Cells and Spaces are deleted, Their interfaces _impl point to the NullImpl object.
When a reference refers to deleted Cells and Spaces, These objects are pickled when the model is serialized.

Here is a sample script to reproduce the phenomenon.

import modelx as mx

@mx.defcells
def foo():
    return 1

mx.Model1.Space1.bar = foo

del mx.Model1.Space1.foo

mx.Model1.write('Ref2Deleted') 

The resulting file Ref2Deleted/Space1/.__init__.py looks like below

# modelx: pseudo-python
# This file is part of a modelx model.
# It can be imported as a Python module, but functions defined herein
# are model formulas and may not be executable as standard Python.

from modelx.serialize.jsonvalues import *

_formula = None

_bases = []

_allow_none = None

_spaces = []

# ---------------------------------------------------------------------------
# References

bar = ("Pickle", 2229981096848)

Saving the null object as binary is not transparent, so I want to have it serialized literally in the touple representing the ref's value.

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