def clone(cls, obj, **kwargs):
assert isinstance(obj, Serializable)
d = obj.__getstate__()
d["__kwargs"] = dict(d["__kwargs"], **kwargs)
out = type(obj).__new__(type(obj))
out.__setstate__(d)
return out
After Change
// Split the entries in kwargs between positional and keyword arguments
// and update d["__args"] and d["__kwargs"], respectively.
if sys.version_info >= (3, 0):
spec = inspect.getfullargspec(obj.__init__)
else:
spec = inspect.getargspec(obj.__init__)
in_order_args = spec.args[1:]
d["__args"] = list(d["__args"])
for kw, val in kwargs.items():