Closed westurner closed 8 years ago
See also: https://github.com/jupyter/nbformat/pull/30 "ENH: v4/nbjson.py: json.loads(object_pairs_hook=collections.OrderedDict)"
From the README:
No functionality should be added to this repository
This package is an artifact of the Jupyter/IPython repo split, and we aren't planning to ever do another release of it, unless we find important bugs. Ultimately, we want to wean the other repos off of this one by shifting to standard utilities, such as six, etc. No new functionality should be added here. Any downstream changes that would rely on new features here should be implemented in the downstream repo instead of here.
No functionality should be added to this repository
I did read that.
I thought/think this solution is justifiable because:
nbformat.notebooknode.NotebookNode(ipython_genutils.ipstruct.Struct)
.
From https://mail.python.org/pipermail/python-ideas/2015-November/037163.html :
class OrderedDefaultDict(OrderedDict):
def __init__(self, default_factory=None, *a, **kw):
OrderedDict.__init__(self, *a, **kw)
self.default_factory = default_factory
def __missing__(self, key):
self[key] = value = default_factory()
return value
Instead of DictCls
as an easily-documented in-code constant, this could be:
Struct.__init__(dictcls=collections.OrderedDict)
)
See https://github.com/jupyter/nbformat/pull/30 for a discussion about:
PYTHONHASHSEED
and dict.__repr__
/ collections.OrderedDict.__repr__
and [doc]testsClosing along with jupyter/nbformat#30.
'Struct' is possibly an unfortunate name. The class offers some features like Structs in other languages - primarily accessing items using a.foo
attribute syntax - but it already does what we need, and we don't need it to be ordered. Naming things is hard ;-)