提交 1afb8265 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Convert the world to the __props__ religion.

上级 1e4568e9
...@@ -216,6 +216,8 @@ class Print(Op): ...@@ -216,6 +216,8 @@ class Print(Op):
""" """
view_map = {0: [0]} view_map = {0: [0]}
__props__ = ('message', 'attrs')
def __init__(self, message="", attrs=("__str__",), global_fn=_print_fn): def __init__(self, message="", attrs=("__str__",), global_fn=_print_fn):
self.message = message self.message = message
self.attrs = tuple(attrs) # attrs should be a hashable iterable self.attrs = tuple(attrs) # attrs should be a hashable iterable
...@@ -237,13 +239,6 @@ class Print(Op): ...@@ -237,13 +239,6 @@ class Print(Op):
def R_op(self, inputs, eval_points): def R_op(self, inputs, eval_points):
return [x for x in eval_points] return [x for x in eval_points]
def __eq__(self, other):
return (type(self) == type(other) and self.message == other.message
and self.attrs == other.attrs)
def __hash__(self):
return hash(self.message) ^ hash(self.attrs)
def __setstate__(self, dct): def __setstate__(self, dct):
dct.setdefault('global_fn', _print_fn) dct.setdefault('global_fn', _print_fn)
self.__dict__.update(dct) self.__dict__.update(dct)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论