This simple safe remote purchase contract is not only concise in Vyper, its intent is clear at a glance! By removing modifiers and other complex patterns, Vyper makes code harder to misunderstand.
The Vyper Way
@external
def purchase():
assert msg.value == 2 * self.value
assert self.state == State.LOCKED
self.state = State.INACTIVE
self.buyer = msg.sender
self.value = msg.value
A Solidity Contrast
modifier condition(bool condition_) {
require(condition_);
_;
}
modifier onlyBuyer() { ... }
modifier inState(State state_) { ... }
function purchase() external payable
inState(State.Locked)
condition(msg.value == (2 * value))
{
state = State.Inactive;
buyer = payable(msg.sender);
value = msg.value;
}