提交 bcbec97e 编写于 作者: HansBug's avatar HansBug 😆

dev(hansbug): tiny update

上级 2f432f29
...@@ -16,8 +16,6 @@ cdef inline TreeStorage _dict_unpack(dict d): ...@@ -16,8 +16,6 @@ cdef inline TreeStorage _dict_unpack(dict d):
result[k] = _dict_unpack(v) result[k] = _dict_unpack(v)
elif isinstance(v, TreeValue): elif isinstance(v, TreeValue):
result[k] = v._detach() result[k] = v._detach()
elif isinstance(v, TreeStorage):
result[k] = v
else: else:
result[k] = v result[k] = v
...@@ -61,6 +59,7 @@ cdef class TreeValue: ...@@ -61,6 +59,7 @@ cdef class TreeValue:
raise TypeError( raise TypeError(
"Unknown initialization type for tree value - {type}.".format( "Unknown initialization type for tree value - {type}.".format(
type=repr(type(data).__name__))) type=repr(type(data).__name__)))
self._type = type(self) self._type = type(self)
def __getnewargs_ex__(self): # for __cinit__, when pickle.loads def __getnewargs_ex__(self): # for __cinit__, when pickle.loads
...@@ -69,13 +68,13 @@ cdef class TreeValue: ...@@ -69,13 +68,13 @@ cdef class TreeValue:
cpdef TreeStorage _detach(self): cpdef TreeStorage _detach(self):
return self._st return self._st
cdef object _unraw(self, object obj): cdef inline object _unraw(self, object obj):
if isinstance(obj, TreeStorage): if isinstance(obj, TreeStorage):
return self._type(obj) return self._type(obj)
else: else:
return obj return obj
cdef object _raw(self, object obj): cdef inline object _raw(self, object obj):
if isinstance(obj, TreeValue): if isinstance(obj, TreeValue):
return obj._detach() return obj._detach()
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册