更新属性还是只实例化一个新对象更有效?
例如:
class Position(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def update_position(self, x, y, z):
self.x = x
self.y = y
self.z = z
def new_Position(self, message):
self.update_position(message[0], message[1], message[2])
def new_Position(message):
return Position(message[0], message[1], message[2])