Added variable swapping module

Did you test the setting of self.changed?

I think it needs to be "self.changed |= ret != obj"
ret != obj is true when the value has changed

changed = false
"self.changed |= val" will remain false until val = true, and remain true after the first true value.